light refactoring/rework (#19314)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Light
|
||||
{
|
||||
[NetworkedComponent]
|
||||
[RegisterComponent]
|
||||
[Access(typeof(SharedHandheldLightSystem))]
|
||||
public sealed partial class HandheldLightComponent : Robust.Shared.GameObjects.Component
|
||||
{
|
||||
public byte? Level;
|
||||
public bool Activated;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("wattage")]
|
||||
public float Wattage { get; set; } = .8f;
|
||||
|
||||
[DataField("turnOnSound")]
|
||||
public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_on.ogg");
|
||||
|
||||
[DataField("turnOnFailSound")]
|
||||
public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
|
||||
|
||||
[DataField("turnOffSound")]
|
||||
public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_off.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically set item-prefixes when toggling the flashlight.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Flashlights should probably be using explicit unshaded sprite, in-hand and clothing layers, this is
|
||||
/// mostly here for backwards compatibility.
|
||||
/// </remarks>
|
||||
[DataField("addPrefix")]
|
||||
public bool AddPrefix = false;
|
||||
|
||||
[DataField("toggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||
public string ToggleActionId = "ToggleLight";
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the light can be toggled via standard interactions
|
||||
/// (alt verbs, using in hand, etc)
|
||||
/// </summary>
|
||||
[DataField("toggleOnInteract")]
|
||||
public bool ToggleOnInteract = true;
|
||||
|
||||
[DataField("toggleAction")]
|
||||
public InstantAction? ToggleAction;
|
||||
|
||||
public const int StatusLevels = 6;
|
||||
|
||||
/// <summary>
|
||||
/// Specify the ID of the light behaviour to use when the state of the light is Dying
|
||||
/// </summary>
|
||||
[DataField("blinkingBehaviourId")]
|
||||
public string BlinkingBehaviourId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Specify the ID of the light behaviour to use when the state of the light is LowPower
|
||||
/// </summary>
|
||||
[DataField("radiatingBehaviourId")]
|
||||
public string RadiatingBehaviourId { get; set; } = string.Empty;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class HandheldLightComponentState : ComponentState
|
||||
{
|
||||
public byte? Charge { get; }
|
||||
|
||||
public bool Activated { get; }
|
||||
|
||||
public HandheldLightComponentState(bool activated, byte? charge)
|
||||
{
|
||||
Activated = activated;
|
||||
Charge = charge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum HandheldLightVisuals
|
||||
{
|
||||
Power
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum HandheldLightPowerStates
|
||||
{
|
||||
FullPower,
|
||||
LowPower,
|
||||
Dying,
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Light.Component
|
||||
{
|
||||
[NetworkedComponent]
|
||||
public abstract partial class SharedEmergencyLightComponent : Robust.Shared.GameObjects.Component
|
||||
{
|
||||
public bool Enabled { get; set; } = false;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class EmergencyLightComponentState : ComponentState
|
||||
{
|
||||
public bool Enabled;
|
||||
|
||||
public EmergencyLightComponentState(bool enabled)
|
||||
{
|
||||
Enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum EmergencyLightVisuals
|
||||
{
|
||||
On,
|
||||
Color
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Light.Component
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum ExpendableLightVisuals
|
||||
{
|
||||
State,
|
||||
Behavior
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ExpendableLightState
|
||||
{
|
||||
BrandNew,
|
||||
Lit,
|
||||
Fading,
|
||||
Dead
|
||||
}
|
||||
|
||||
[NetworkedComponent]
|
||||
public abstract partial class SharedExpendableLightComponent: Robust.Shared.GameObjects.Component
|
||||
{
|
||||
public static readonly AudioParams LoopedSoundParams = new(0, 1, "Master", 62.5f, 1, 1, true, 0.3f);
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public ExpendableLightState CurrentState { get; set; }
|
||||
|
||||
[DataField("turnOnBehaviourID")]
|
||||
public string TurnOnBehaviourID { get; set; } = string.Empty;
|
||||
|
||||
[DataField("fadeOutBehaviourID")]
|
||||
public string FadeOutBehaviourID { get; set; } = string.Empty;
|
||||
|
||||
[DataField("glowDuration")]
|
||||
public float GlowDuration { get; set; } = 60 * 15f;
|
||||
|
||||
[DataField("fadeOutDuration")]
|
||||
public float FadeOutDuration { get; set; } = 60 * 5f;
|
||||
|
||||
[DataField("spentDesc")]
|
||||
public string SpentDesc { get; set; } = string.Empty;
|
||||
|
||||
[DataField("spentName")]
|
||||
public string SpentName { get; set; } = string.Empty;
|
||||
|
||||
[DataField("litSound")]
|
||||
public SoundSpecifier? LitSound { get; set; }
|
||||
|
||||
[DataField("loopedSound")]
|
||||
public SoundSpecifier? LoopedSound { get; set; }
|
||||
|
||||
[DataField("dieSound")]
|
||||
public SoundSpecifier? DieSound { get; set; } = null;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Content.Shared.Light.Component
|
||||
{
|
||||
/// <summary>
|
||||
/// A component which applies a specific behaviour to a PointLightComponent on its owner.
|
||||
/// </summary>
|
||||
public abstract partial class SharedLightBehaviourComponent : Robust.Shared.GameObjects.Component
|
||||
{
|
||||
}
|
||||
}
|
||||
92
Content.Shared/Light/Components/HandheldLightComponent.cs
Normal file
92
Content.Shared/Light/Components/HandheldLightComponent.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedHandheldLightSystem))]
|
||||
public sealed partial class HandheldLightComponent : Component
|
||||
{
|
||||
public byte? Level;
|
||||
public bool Activated;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("wattage")]
|
||||
public float Wattage { get; set; } = .8f;
|
||||
|
||||
[DataField("turnOnSound")]
|
||||
public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_on.ogg");
|
||||
|
||||
[DataField("turnOnFailSound")]
|
||||
public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
|
||||
|
||||
[DataField("turnOffSound")]
|
||||
public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_off.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically set item-prefixes when toggling the flashlight.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Flashlights should probably be using explicit unshaded sprite, in-hand and clothing layers, this is
|
||||
/// mostly here for backwards compatibility.
|
||||
/// </remarks>
|
||||
[DataField("addPrefix")]
|
||||
public bool AddPrefix = false;
|
||||
|
||||
[DataField("toggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||
public string ToggleActionId = "ToggleLight";
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the light can be toggled via standard interactions
|
||||
/// (alt verbs, using in hand, etc)
|
||||
/// </summary>
|
||||
[DataField("toggleOnInteract")]
|
||||
public bool ToggleOnInteract = true;
|
||||
|
||||
[DataField("toggleAction")]
|
||||
public InstantAction? ToggleAction;
|
||||
|
||||
public const int StatusLevels = 6;
|
||||
|
||||
/// <summary>
|
||||
/// Specify the ID of the light behaviour to use when the state of the light is Dying
|
||||
/// </summary>
|
||||
[DataField("blinkingBehaviourId")]
|
||||
public string BlinkingBehaviourId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Specify the ID of the light behaviour to use when the state of the light is LowPower
|
||||
/// </summary>
|
||||
[DataField("radiatingBehaviourId")]
|
||||
public string RadiatingBehaviourId { get; set; } = string.Empty;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class HandheldLightComponentState : ComponentState
|
||||
{
|
||||
public byte? Charge { get; }
|
||||
|
||||
public bool Activated { get; }
|
||||
|
||||
public HandheldLightComponentState(bool activated, byte? charge)
|
||||
{
|
||||
Activated = activated;
|
||||
Charge = charge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum HandheldLightVisuals
|
||||
{
|
||||
Power
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum HandheldLightPowerStates
|
||||
{
|
||||
FullPower,
|
||||
LowPower,
|
||||
Dying,
|
||||
}
|
||||
@@ -2,15 +2,14 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Light.Component;
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
|
||||
/// TODO: Breaking and burning should probably be moved to another component eventually.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed partial class LightBulbComponent : Robust.Shared.GameObjects.Component
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class LightBulbComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The color of the lightbulb and the light it produces.
|
||||
@@ -1,7 +1,7 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Light.Component;
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Makes the color of lights on an entity fluctuate. Will update point-light color and modulate some or all of the
|
||||
@@ -10,10 +10,8 @@ namespace Content.Shared.Light.Component;
|
||||
/// <remarks>
|
||||
/// Networked ~~solely for admemes~~ for completely legitimate reasons, like hacked energy swords.
|
||||
/// </remarks>
|
||||
[NetworkedComponent]
|
||||
[RegisterComponent]
|
||||
[Access(typeof(SharedRgbLightControllerSystem))]
|
||||
public sealed partial class RgbLightControllerComponent : Robust.Shared.GameObjects.Component
|
||||
[NetworkedComponent, RegisterComponent, Access(typeof(SharedRgbLightControllerSystem))]
|
||||
public sealed partial class RgbLightControllerComponent : Component
|
||||
{
|
||||
[DataField("cycleRate")]
|
||||
public float CycleRate { get; set; } = 0.1f;
|
||||
21
Content.Shared/Light/Components/RotatingLightComponent.cs
Normal file
21
Content.Shared/Light/Components/RotatingLightComponent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Animates a point light's rotation while enabled.
|
||||
/// All animation is done in the client system.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||
[Access(typeof(SharedRotatingLightSystem))]
|
||||
public sealed partial class RotatingLightComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Speed to rotate at, in degrees per second
|
||||
/// </summary>
|
||||
[DataField("speed")]
|
||||
public float Speed = 90f;
|
||||
|
||||
[ViewVariables, AutoNetworkedField]
|
||||
public bool Enabled = true;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Handles station alert level and power changes for emergency lights.
|
||||
/// All logic is serverside, animation is handled by <see cref="RotatingLightComponent"/>.
|
||||
/// </summary>
|
||||
[Access(typeof(SharedEmergencyLightSystem))]
|
||||
public abstract partial class SharedEmergencyLightComponent : Component
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum EmergencyLightVisuals
|
||||
{
|
||||
On,
|
||||
Color
|
||||
}
|
||||
|
||||
public enum EmergencyLightVisualLayers
|
||||
{
|
||||
Base,
|
||||
LightOff,
|
||||
LightOn,
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
[NetworkedComponent]
|
||||
public abstract partial class SharedExpendableLightComponent : Component
|
||||
{
|
||||
public static readonly AudioParams LoopedSoundParams = new(0, 1, "Master", 62.5f, 1, 1, true, 0.3f);
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public ExpendableLightState CurrentState { get; set; }
|
||||
|
||||
[DataField("turnOnBehaviourID")]
|
||||
public string TurnOnBehaviourID { get; set; } = string.Empty;
|
||||
|
||||
[DataField("fadeOutBehaviourID")]
|
||||
public string FadeOutBehaviourID { get; set; } = string.Empty;
|
||||
|
||||
[DataField("glowDuration")]
|
||||
public float GlowDuration { get; set; } = 60 * 15f;
|
||||
|
||||
[DataField("fadeOutDuration")]
|
||||
public float FadeOutDuration { get; set; } = 60 * 5f;
|
||||
|
||||
[DataField("spentDesc")]
|
||||
public string SpentDesc { get; set; } = string.Empty;
|
||||
|
||||
[DataField("spentName")]
|
||||
public string SpentName { get; set; } = string.Empty;
|
||||
|
||||
[DataField("litSound")]
|
||||
public SoundSpecifier? LitSound { get; set; }
|
||||
|
||||
[DataField("loopedSound")]
|
||||
public SoundSpecifier? LoopedSound { get; set; }
|
||||
|
||||
[DataField("dieSound")]
|
||||
public SoundSpecifier? DieSound { get; set; } = null;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ExpendableLightVisuals
|
||||
{
|
||||
State,
|
||||
Behavior
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ExpendableLightState
|
||||
{
|
||||
BrandNew,
|
||||
Lit,
|
||||
Fading,
|
||||
Dead
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// A component which applies a specific behaviour to a PointLightComponent on its owner.
|
||||
/// </summary>
|
||||
public abstract partial class SharedLightBehaviourComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -2,14 +2,14 @@ using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Decals;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Light.Component;
|
||||
namespace Content.Shared.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is simplified version of <see cref="HandheldLightComponent"/>.
|
||||
/// It doesn't consume any power and can be toggle only by verb.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class UnpoweredFlashlightComponent : Robust.Shared.GameObjects.Component
|
||||
public sealed partial class UnpoweredFlashlightComponent : Component
|
||||
{
|
||||
[DataField("toggleFlashlightSound")]
|
||||
public SoundSpecifier ToggleSound = new SoundPathSpecifier("/Audio/Items/flashlight_pda.ogg");
|
||||
@@ -1,7 +1,5 @@
|
||||
namespace Content.Shared.Light
|
||||
{
|
||||
public abstract class SharedEmergencyLightSystem : EntitySystem
|
||||
{
|
||||
namespace Content.Shared.Light;
|
||||
|
||||
}
|
||||
public abstract class SharedEmergencyLightSystem : EntitySystem
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Clothing.EntitySystems;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Light.Components;
|
||||
using Content.Shared.Toggleable;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Light.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Light;
|
||||
|
||||
5
Content.Shared/Light/SharedRotatingLightSystem.cs
Normal file
5
Content.Shared/Light/SharedRotatingLightSystem.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Content.Shared.Light;
|
||||
|
||||
public abstract class SharedRotatingLightSystem : EntitySystem
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user