1
0

ParticleAcceleratorControlBoxComponent.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using Content.Server.ParticleAccelerator.Wires;
  2. using Content.Shared.Singularity.Components;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. namespace Content.Server.ParticleAccelerator.Components;
  5. // This component is in control of the PA's logic because it's the one to contain the wires for hacking.
  6. // And also it's the only PA component that meaningfully needs to work on its own.
  7. /// <summary>
  8. /// Is the computer thing people interact with to control the PA.
  9. /// Also contains primary logic for actual PA behavior, part scanning, etc...
  10. /// </summary>
  11. [RegisterComponent]
  12. public sealed partial class ParticleAcceleratorControlBoxComponent : Component
  13. {
  14. /// <summary>
  15. /// Whether the PA parts have been correctly arranged to make a functional device.
  16. /// </summary>
  17. [ViewVariables]
  18. public bool Assembled = false;
  19. /// <summary>
  20. /// Whether the PA is currently set to fire at the console.
  21. /// Requires <see cref="Assembled"/> to be true.
  22. /// </summary>
  23. [ViewVariables]
  24. public bool Enabled = false;
  25. /// <summary>
  26. /// Whether the PA actually has the power necessary to fire.
  27. /// Requires <see cref="Enabled"/> to be true.
  28. /// </summary>
  29. [ViewVariables]
  30. public bool Powered = false;
  31. /// <summary>
  32. /// Whether the PA is currently firing or charging to fire.
  33. /// Requires <see cref="Powered"/> to be true.
  34. /// </summary>
  35. [ViewVariables]
  36. public bool Firing = false;
  37. /// <summary>
  38. /// Block re-entrant rescanning.
  39. /// </summary>
  40. [ViewVariables(VVAccess.ReadWrite)]
  41. public bool CurrentlyRescanning = false;
  42. /// <summary>
  43. /// Whether the PA is currently firing or charging to fire.
  44. /// Bounded by <see cref="ParticleAcceleratorPowerState.Standby"/> and <see cref="MaxStrength"/>.
  45. /// Modified by <see cref="ParticleAcceleratorStrengthWireAction"/>.
  46. /// </summary>
  47. [ViewVariables(VVAccess.ReadWrite)]
  48. public ParticleAcceleratorPowerState SelectedStrength = ParticleAcceleratorPowerState.Standby;
  49. /// <summary>
  50. /// The maximum strength level this particle accelerator can be set to operate at.
  51. /// Modified by <see cref="ParticleAcceleratorLimiterWireAction"/>.
  52. /// </summary>
  53. [ViewVariables]
  54. public ParticleAcceleratorPowerState MaxStrength = ParticleAcceleratorPowerState.Level2;
  55. /// <summary>
  56. /// The power supply unit of the assembled particle accelerator.
  57. /// Implies the existance of a <see cref="ParticleAcceleratorPowerBoxComponent"/> attached to this entity.
  58. /// </summary>
  59. [ViewVariables]
  60. public EntityUid? PowerBox;
  61. /// <summary>
  62. /// Whether the PA is currently firing or charging to fire.
  63. /// Implies the existance of a <see cref="ParticleAcceleratorEndCapComponent"/> attached to this entity.
  64. /// </summary>
  65. [ViewVariables]
  66. public EntityUid? EndCap;
  67. /// <summary>
  68. /// Whether the PA is currently firing or charging to fire.
  69. /// Implies the existance of a <see cref="ParticleAcceleratorFuelChamberComponent"/> attached to this entity.
  70. /// </summary>
  71. [ViewVariables]
  72. public EntityUid? FuelChamber;
  73. /// <summary>
  74. /// Whether the PA is currently firing or charging to fire.
  75. /// Implies the existance of a <see cref="ParticleAcceleratorEmitterComponent"/> attached to this entity.
  76. /// </summary>
  77. [ViewVariables]
  78. public EntityUid? PortEmitter;
  79. /// <summary>
  80. /// Whether the PA is currently firing or charging to fire.
  81. /// Implies the existance of a <see cref="ParticleAcceleratorEmitterComponent"/> attached to this entity.
  82. /// </summary>
  83. [ViewVariables]
  84. public EntityUid? ForeEmitter;
  85. /// <summary>
  86. /// Whether the PA is currently firing or charging to fire.
  87. /// Implies the existance of a <see cref="ParticleAcceleratorEmitterComponent"/> attached to this entity.
  88. /// </summary>
  89. [ViewVariables]
  90. public EntityUid? StarboardEmitter;
  91. /// <summary>
  92. /// The amount of power the particle accelerator must be provided with relative to the expected power draw to function.
  93. /// </summary>
  94. [ViewVariables]
  95. public const float RequiredPowerRatio = 0.999f;
  96. /// <summary>
  97. /// The amount of power (in watts) the PA draws just by existing as a functional machine.
  98. /// </summary>
  99. [DataField("powerDrawBase")]
  100. [ViewVariables(VVAccess.ReadWrite)]
  101. public int BasePowerDraw = 500;
  102. /// <summary>
  103. /// The amount of power (in watts) the PA draws per level when turned on.
  104. /// </summary>
  105. [DataField("powerDrawMult")]
  106. [ViewVariables(VVAccess.ReadWrite)]
  107. public int LevelPowerDraw = 1500;
  108. /// <summary>
  109. /// The time at which the PA last fired a wave of particles.
  110. /// </summary>
  111. [DataField("lastFire")]
  112. [ViewVariables(VVAccess.ReadWrite)]
  113. public TimeSpan LastFire;
  114. /// <summary>
  115. /// The time at which the PA will next fire a wave of particles.
  116. /// </summary>
  117. [DataField("nextFire")]
  118. [ViewVariables(VVAccess.ReadWrite)]
  119. public TimeSpan NextFire;
  120. /// <summary>
  121. /// Delay between consecutive PA shots.
  122. /// </summary>
  123. // Fun fact:
  124. // On /vg/station (can't check TG because lol they removed singulo),
  125. // the PA emitter parts have var/fire_delay = 50.
  126. // For anybody from the future not BYOND-initiated, that's 5 seconds.
  127. // However, /obj/machinery/particle_accelerator/control_box/process(),
  128. // which calls emit_particle() on the emitters,
  129. // only gets called every *2* seconds, because of CarnMC timing.
  130. // So the *actual* effective firing delay of the PA is 6 seconds, not 5 as listed in the code.
  131. // So...
  132. // I have reflected that here to be authentic.
  133. [DataField("chargeTime")]
  134. [ViewVariables(VVAccess.ReadWrite)]
  135. public TimeSpan ChargeTime = TimeSpan.FromSeconds(6.0);
  136. /// <summary>
  137. /// Whether the interface has been disabled via a cut wire or not.
  138. /// Modified by <see cref="ParticleAcceleratorKeyboardWireAction"/>.
  139. /// </summary>
  140. [ViewVariables]
  141. public bool InterfaceDisabled = false;
  142. /// <summary>
  143. /// Whether the ability to change the strength of the PA has been disabled via a cut wire or not.
  144. /// Modified by <see cref="ParticleAcceleratorStrengthWireAction"/>.
  145. /// </summary>
  146. [ViewVariables]
  147. public bool StrengthLocked = false;
  148. /// <summary>
  149. /// Time at which the admin alarm sound effect can next be played.
  150. /// </summary>
  151. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  152. public TimeSpan EffectCooldown;
  153. /// <summary>
  154. /// Time between admin alarm sound effects. Prevents spam
  155. /// </summary>
  156. [DataField]
  157. public TimeSpan CooldownDuration = TimeSpan.FromSeconds(10f);
  158. /// <summary>
  159. /// Whether the PA can be turned on.
  160. /// Modified by <see cref="ParticleAcceleratorPowerWireAction"/>.
  161. /// </summary>
  162. [ViewVariables]
  163. public bool CanBeEnabled = true;
  164. }