2025-02-23 07:39:44 -06:00
using Content.Shared.Power.EntitySystems ;
2025-02-24 00:57:27 +11:00
using Robust.Shared.GameStates ;
2025-02-23 07:39:44 -06:00
2025-02-24 00:57:27 +11:00
namespace Content.Shared.Power.Components ;
2025-02-23 07:39:44 -06:00
/// <summary>
/// Attached to APC powered entities that possess a rechargeable internal battery.
2025-02-24 00:57:27 +11:00
/// If external power is interrupted, the entity will draw power from this battery instead.
/// Requires <see cref="Content.Server.Power.Components.ApcPowerReceiverComponent"/> and <see cref="Content.Server.Power.Components.BatteryComponent"/> to function.
2025-02-23 07:39:44 -06:00
/// </summary>
2025-02-24 00:57:27 +11:00
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedPowerNetSystem), typeof(SharedPowerReceiverSystem))]
2025-02-23 07:39:44 -06:00
public sealed partial class ApcPowerReceiverBatteryComponent : Component
{
/// <summary>
/// Indicates whether power is currently being drawn from the battery.
/// </summary>
2025-02-24 00:57:27 +11:00
[DataField, AutoNetworkedField]
2025-02-23 07:39:44 -06:00
public bool Enabled = false ;
/// <summary>
/// The passive load the entity places on the APC power network.
/// If not connected to an active APC power network, this amount
/// of power is drained from the battery every second.
/// </summary>
[DataField]
2025-02-24 00:57:27 +11:00
public float IdleLoad = 5f ;
2025-02-23 07:39:44 -06:00
/// <summary>
2025-02-24 00:57:27 +11:00
/// Determines how much battery charge the entity's battery gains
2025-02-23 07:39:44 -06:00
/// per second when connected to an active APC power network.
/// </summary>
[DataField]
2025-02-24 00:57:27 +11:00
public float BatteryRechargeRate = 50f ;
2025-02-23 07:39:44 -06:00
/// <summary>
2025-02-24 00:57:27 +11:00
/// While the battery is being recharged, the load this entity places on the APC
2025-02-23 07:39:44 -06:00
/// power network is increased by the <see cref="BatteryRechargeRate"/> multiplied
/// by this factor.
/// </summary>
[DataField]
2025-02-24 00:57:27 +11:00
public float BatteryRechargeEfficiency = 1f ;
2025-02-23 07:39:44 -06:00
}
/// <summary>
/// Raised whenever an ApcPowerReceiverBattery starts / stops discharging
/// </summary>
[ByRefEvent]
public readonly record struct ApcPowerReceiverBatteryChangedEvent ( bool Enabled ) ;