2023-04-19 22:10:08 +12:00
|
|
|
using Content.Server.Power.EntitySystems;
|
|
|
|
|
|
2021-07-04 18:11:52 +02:00
|
|
|
namespace Content.Server.Power.Components
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
2021-07-04 18:11:52 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Battery node on the pow3r network. Needs other components to connect to actual networks.
|
|
|
|
|
/// </summary>
|
2020-06-28 09:23:26 -06:00
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
[Virtual]
|
2024-03-06 00:34:50 -05:00
|
|
|
[Access(typeof(BatterySystem))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public partial class BatteryComponent : Component
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
2023-07-08 06:32:31 +03:00
|
|
|
public string SolutionName = "battery";
|
2022-01-05 17:20:25 +13:00
|
|
|
|
2020-10-29 20:17:03 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Maximum charge of the battery in joules (ie. watt seconds)
|
|
|
|
|
/// </summary>
|
2024-03-06 00:34:50 -05:00
|
|
|
[DataField]
|
|
|
|
|
public float MaxCharge;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2020-10-29 20:17:03 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current charge of the battery in joules (ie. watt seconds)
|
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("startingCharge")]
|
2024-03-06 00:34:50 -05:00
|
|
|
public float CurrentCharge;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2020-10-29 20:17:03 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// True if the battery is fully charged.
|
|
|
|
|
/// </summary>
|
2024-03-06 00:34:50 -05:00
|
|
|
[ViewVariables]
|
|
|
|
|
public bool IsFullyCharged => MathHelper.CloseToPercent(CurrentCharge, MaxCharge);
|
2020-10-29 20:17:03 +02:00
|
|
|
|
2022-10-15 23:10:48 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// The price per one joule. Default is 1 credit for 10kJ.
|
|
|
|
|
/// </summary>
|
2024-03-06 00:34:50 -05:00
|
|
|
[DataField]
|
2022-10-15 23:10:48 +02:00
|
|
|
public float PricePerJoule = 0.0001f;
|
2020-06-28 09:23:26 -06:00
|
|
|
}
|
2022-01-05 17:20:25 +13:00
|
|
|
|
2023-04-19 22:10:08 +12:00
|
|
|
/// <summary>
|
|
|
|
|
/// Raised when a battery's charge or capacity changes (capacity affects relative charge percentage).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ByRefEvent]
|
2023-04-23 12:25:12 +10:00
|
|
|
public readonly record struct ChargeChangedEvent(float Charge, float MaxCharge);
|
2020-06-28 09:23:26 -06:00
|
|
|
}
|