HandheldLightComponent.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Robust.Shared.Audio;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  6. namespace Content.Shared.Light.Components;
  7. [RegisterComponent, NetworkedComponent, Access(typeof(SharedHandheldLightSystem))]
  8. public sealed partial class HandheldLightComponent : Component
  9. {
  10. public byte? Level;
  11. public bool Activated;
  12. [ViewVariables(VVAccess.ReadWrite)]
  13. [DataField("wattage")]
  14. public float Wattage { get; set; } = .8f;
  15. [DataField("turnOnSound")]
  16. public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_on.ogg");
  17. [DataField("turnOnFailSound")]
  18. public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
  19. [DataField("turnOffSound")]
  20. public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_off.ogg");
  21. /// <summary>
  22. /// Whether to automatically set item-prefixes when toggling the flashlight.
  23. /// </summary>
  24. /// <remarks>
  25. /// Flashlights should probably be using explicit unshaded sprite, in-hand and clothing layers, this is
  26. /// mostly here for backwards compatibility.
  27. /// </remarks>
  28. [DataField("addPrefix")]
  29. public bool AddPrefix = false;
  30. [DataField("toggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
  31. public string ToggleAction = "ActionToggleLight";
  32. /// <summary>
  33. /// Whether or not the light can be toggled via standard interactions
  34. /// (alt verbs, using in hand, etc)
  35. /// </summary>
  36. [DataField("toggleOnInteract")]
  37. public bool ToggleOnInteract = true;
  38. [DataField("toggleActionEntity")]
  39. public EntityUid? ToggleActionEntity;
  40. [DataField]
  41. public EntityUid? SelfToggleActionEntity;
  42. public const int StatusLevels = 6;
  43. /// <summary>
  44. /// Specify the ID of the light behaviour to use when the state of the light is Dying
  45. /// </summary>
  46. [DataField("blinkingBehaviourId")]
  47. public string BlinkingBehaviourId { get; set; } = string.Empty;
  48. /// <summary>
  49. /// Specify the ID of the light behaviour to use when the state of the light is LowPower
  50. /// </summary>
  51. [DataField("radiatingBehaviourId")]
  52. public string RadiatingBehaviourId { get; set; } = string.Empty;
  53. [Serializable, NetSerializable]
  54. public sealed class HandheldLightComponentState : ComponentState
  55. {
  56. public byte? Charge { get; }
  57. public bool Activated { get; }
  58. public HandheldLightComponentState(bool activated, byte? charge)
  59. {
  60. Activated = activated;
  61. Charge = charge;
  62. }
  63. }
  64. }
  65. [Serializable, NetSerializable]
  66. public enum HandheldLightVisuals
  67. {
  68. Power
  69. }
  70. [Serializable, NetSerializable]
  71. public enum HandheldLightPowerStates
  72. {
  73. FullPower,
  74. LowPower,
  75. Dying,
  76. }