Inspector Fields
| Field | Type | Description |
_stat | Stat | The Stat asset this stamina system tracks. Used to look up the receiver when applying stat effects from equipment or items. |
Properties
| Property | Type | Description |
stat | Stat | Read-only accessor for the assigned stat asset. |
maxValue | int | Maximum stamina the player can have. Derived from the active equipment bonuses at initialization. |
currentValue | int | Current stamina points remaining. |
value | int (get/set) | Gets or sets currentValue, clamped to [0, maxValue]. |
Methods
| Method | Description |
Initialize() | Sets currentValue to maxValue and fires OnInitialize. Called automatically at the start of each run. |
Substract(int value = 1) | Spends value stamina points, clamped so the result never drops below zero. Fires OnValueUpdated and OnDepleted when the result reaches zero. |
Add(int value = 1) | Restores value stamina points, clamped to maxValue. Fires OnValueUpdated, OnValueChanged, and OnReplenished when fully restored. |
Events
| Event | Signature | Description |
OnInitialize | Action<int> | Fired on Initialize() with the starting stamina value. Subscribe here to set the initial HUD state. |
OnValueUpdated | Action<int> | Fired whenever stamina changes, passing the new total. Used by PlayerStaminaBar to refresh the display. |
OnValueChanged | Action<int> | Fired when stamina is added, passing the delta (amount gained). |
OnDepleted | Action | Fired when stamina reaches zero. |
OnReplenished | Action | Fired when stamina reaches the maximum value. |
Usage from instructions
Access stamina via ExecutionContext inside a Tick() coroutine:
protected override IEnumerator Tick(ExecutionContext ctx)
{
if (ctx.player.stamina.currentValue < 1)
{
NotificationCenter.Notify(NotificationCenter.MessageType.Warning, "Not enough stamina!");
resolution = false;
yield break;
}
ctx.player.stamina.Substract(1);
// ... perform action
}