1
0

ApcComponent.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Content.Server.Power.NodeGroups;
  2. using Content.Shared.APC;
  3. using Robust.Shared.Audio;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  5. namespace Content.Server.Power.Components;
  6. [RegisterComponent]
  7. public sealed partial class ApcComponent : BaseApcNetComponent
  8. {
  9. [DataField("onReceiveMessageSound")]
  10. public SoundSpecifier OnReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
  11. public ApcChargeState LastChargeState;
  12. public TimeSpan? LastChargeStateTime;
  13. public ApcExternalPowerState LastExternalState;
  14. /// <summary>
  15. /// Time the ui was last updated automatically.
  16. /// Done after every <see cref="VisualsChangeDelay"/> to show the latest load.
  17. /// If charge state changes it will be instantly updated.
  18. /// </summary>
  19. public TimeSpan LastUiUpdate;
  20. [DataField("enabled")]
  21. public bool MainBreakerEnabled = true;
  22. /// <summary>
  23. /// APC state needs to always be updated after first processing tick.
  24. /// </summary>
  25. public bool NeedStateUpdate;
  26. public const float HighPowerThreshold = 0.9f;
  27. public static TimeSpan VisualsChangeDelay = TimeSpan.FromSeconds(1);
  28. // TODO ECS power a little better!
  29. // End the suffering
  30. protected override void AddSelfToNet(IApcNet apcNet)
  31. {
  32. apcNet.AddApc(Owner, this);
  33. }
  34. protected override void RemoveSelfFromNet(IApcNet apcNet)
  35. {
  36. apcNet.RemoveApc(Owner, this);
  37. }
  38. }