SharedEmitterComponent.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System.Threading;
  2. using Content.Shared.DeviceLinking;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Serialization;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
  8. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
  9. namespace Content.Shared.Singularity.Components;
  10. [RegisterComponent, NetworkedComponent]
  11. public sealed partial class EmitterComponent : Component
  12. {
  13. public CancellationTokenSource? TimerCancel;
  14. // whether the power switch is in "on"
  15. [ViewVariables] public bool IsOn;
  16. // Whether the power switch is on AND the machine has enough power (so is actively firing)
  17. [ViewVariables] public bool IsPowered;
  18. /// <summary>
  19. /// counts the number of consecutive shots fired.
  20. /// </summary>
  21. [ViewVariables]
  22. public int FireShotCounter;
  23. /// <summary>
  24. /// The entity that is spawned when the emitter fires.
  25. /// </summary>
  26. [DataField("boltType", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
  27. public string BoltType = "EmitterBolt";
  28. [DataField("selectableTypes", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
  29. public List<string> SelectableTypes = new();
  30. /// <summary>
  31. /// The current amount of power being used.
  32. /// </summary>
  33. [DataField("powerUseActive")]
  34. public int PowerUseActive = 600;
  35. /// <summary>
  36. /// The amount of shots that are fired in a single "burst"
  37. /// </summary>
  38. [DataField("fireBurstSize")]
  39. public int FireBurstSize = 3;
  40. /// <summary>
  41. /// The time between each shot during a burst.
  42. /// </summary>
  43. [DataField("fireInterval")]
  44. public TimeSpan FireInterval = TimeSpan.FromSeconds(2);
  45. /// <summary>
  46. /// The current minimum delay between bursts.
  47. /// </summary>
  48. [DataField("fireBurstDelayMin")]
  49. public TimeSpan FireBurstDelayMin = TimeSpan.FromSeconds(4);
  50. /// <summary>
  51. /// The current maximum delay between bursts.
  52. /// </summary>
  53. [DataField("fireBurstDelayMax")]
  54. public TimeSpan FireBurstDelayMax = TimeSpan.FromSeconds(10);
  55. /// <summary>
  56. /// The visual state that is set when the emitter is turned on
  57. /// </summary>
  58. [DataField("onState")]
  59. public string? OnState = "beam";
  60. /// <summary>
  61. /// The visual state that is set when the emitter doesn't have enough power.
  62. /// </summary>
  63. [DataField("underpoweredState")]
  64. public string? UnderpoweredState = "underpowered";
  65. /// <summary>
  66. /// Signal port that turns on the emitter.
  67. /// </summary>
  68. [DataField("onPort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
  69. public string OnPort = "On";
  70. /// <summary>
  71. /// Signal port that turns off the emitter.
  72. /// </summary>
  73. [DataField("offPort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
  74. public string OffPort = "Off";
  75. /// <summary>
  76. /// Signal port that toggles the emitter on or off.
  77. /// </summary>
  78. [DataField("togglePort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
  79. public string TogglePort = "Toggle";
  80. /// <summary>
  81. /// Map of signal ports to entity prototype IDs of the entity that will be fired.
  82. /// </summary>
  83. [DataField("setTypePorts", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<string, SinkPortPrototype>))]
  84. public Dictionary<string, string> SetTypePorts = new();
  85. }
  86. [NetSerializable, Serializable]
  87. public enum EmitterVisuals : byte
  88. {
  89. VisualState
  90. }
  91. [Serializable, NetSerializable]
  92. public enum EmitterVisualLayers : byte
  93. {
  94. Lights
  95. }
  96. [NetSerializable, Serializable]
  97. public enum EmitterVisualState
  98. {
  99. On,
  100. Underpowered,
  101. Off
  102. }