1
0

BatteryComponent.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Server.Power.EntitySystems;
  2. using Content.Shared.Guidebook;
  3. namespace Content.Server.Power.Components
  4. {
  5. /// <summary>
  6. /// Battery node on the pow3r network. Needs other components to connect to actual networks.
  7. /// </summary>
  8. [RegisterComponent]
  9. [Virtual]
  10. [Access(typeof(BatterySystem))]
  11. public partial class BatteryComponent : Component
  12. {
  13. public string SolutionName = "battery";
  14. /// <summary>
  15. /// Maximum charge of the battery in joules (ie. watt seconds)
  16. /// </summary>
  17. [DataField]
  18. [GuidebookData]
  19. public float MaxCharge;
  20. /// <summary>
  21. /// Current charge of the battery in joules (ie. watt seconds)
  22. /// </summary>
  23. [DataField("startingCharge")]
  24. public float CurrentCharge;
  25. /// <summary>
  26. /// The price per one joule. Default is 1 credit for 10kJ.
  27. /// </summary>
  28. [DataField]
  29. public float PricePerJoule = 0.0001f;
  30. }
  31. /// <summary>
  32. /// Raised when a battery's charge or capacity changes (capacity affects relative charge percentage).
  33. /// </summary>
  34. [ByRefEvent]
  35. public readonly record struct ChargeChangedEvent(float Charge, float MaxCharge);
  36. }