Inspector Fields

FieldTypeDescription
_statStatThe Stat asset this stamina system tracks. Used to look up the receiver when applying stat effects from equipment or items.

Properties

PropertyTypeDescription
statStatRead-only accessor for the assigned stat asset.
maxValueintMaximum stamina the player can have. Derived from the active equipment bonuses at initialization.
currentValueintCurrent stamina points remaining.
valueint (get/set)Gets or sets currentValue, clamped to [0, maxValue].

Methods

MethodDescription
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

EventSignatureDescription
OnInitializeAction<int>Fired on Initialize() with the starting stamina value. Subscribe here to set the initial HUD state.
OnValueUpdatedAction<int>Fired whenever stamina changes, passing the new total. Used by PlayerStaminaBar to refresh the display.
OnValueChangedAction<int>Fired when stamina is added, passing the delta (amount gained).
OnDepletedActionFired when stamina reaches zero.
OnReplenishedActionFired 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
}