1
0

ApcPowerReceiverBatteryChangedEvent.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Content.Shared.Power.EntitySystems;
  2. using Robust.Shared.GameStates;
  3. namespace Content.Shared.Power.Components;
  4. /// <summary>
  5. /// Attached to APC powered entities that possess a rechargeable internal battery.
  6. /// If external power is interrupted, the entity will draw power from this battery instead.
  7. /// Requires <see cref="Content.Server.Power.Components.ApcPowerReceiverComponent"/> and <see cref="Content.Server.Power.Components.BatteryComponent"/> to function.
  8. /// </summary>
  9. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  10. [Access(typeof(SharedPowerNetSystem), typeof(SharedPowerReceiverSystem))]
  11. public sealed partial class ApcPowerReceiverBatteryComponent : Component
  12. {
  13. /// <summary>
  14. /// Indicates whether power is currently being drawn from the battery.
  15. /// </summary>
  16. [DataField, AutoNetworkedField]
  17. public bool Enabled = false;
  18. /// <summary>
  19. /// The passive load the entity places on the APC power network.
  20. /// If not connected to an active APC power network, this amount
  21. /// of power is drained from the battery every second.
  22. /// </summary>
  23. [DataField]
  24. public float IdleLoad = 5f;
  25. /// <summary>
  26. /// Determines how much battery charge the entity's battery gains
  27. /// per second when connected to an active APC power network.
  28. /// </summary>
  29. [DataField]
  30. public float BatteryRechargeRate = 50f;
  31. /// <summary>
  32. /// While the battery is being recharged, the load this entity places on the APC
  33. /// power network is increased by the <see cref="BatteryRechargeRate"/> multiplied
  34. /// by this factor.
  35. /// </summary>
  36. [DataField]
  37. public float BatteryRechargeEfficiency = 1f;
  38. }
  39. /// <summary>
  40. /// Raised whenever an ApcPowerReceiverBattery starts / stops discharging
  41. /// </summary>
  42. [ByRefEvent]
  43. public readonly record struct ApcPowerReceiverBatteryChangedEvent(bool Enabled);