Skip to main content

Class BatteryDrainSystem

A component that enables time-based battery consumption for a BatterySystem. When enabled, it linearly drains the battery over time based on the configured battery life.

[RequireComponent(typeof(BatterySystem))]
[DisallowMultipleComponent]
public class BatteryDrainSystem : MonoBehaviour

Inheritance​

Properties​

MaxBatteryLife​

Return the total duration (in seconds) that the battery is expected to last when drained continuously over time.

public float MaxBatteryLife { get; }

Property Value​

float

Remarks​

The battery is considered "full" at BatteryLevelMax and "empty" at BatteryLevelMin.

RemainingBatteryLife​

Gets the remaining battery life in seconds.

public float RemainingBatteryLife { get; }

Property Value​

float

Methods​

DrainBattery(float)​

Drains the battery proportionally to the specified duration.

public void DrainBattery(float drainAmount)

Parameters​

NameTypeDescription
drainAmountfloatThe time duration (in seconds) to simulate battery drain.