GS2-Stamina SDK for Game Engine API Reference

Specifications of models and API references for GS2-Stamina SDK for Game Engine

Model

EzStamina

Stamina

Stamina is a point that is recovered over time in real time. Generally, this stamina is used to limit the number of times a player can play a game per day and to allow the game provider to control the speed of game progression by allowing players to consume stamina to play the game.

TypeConditionRequiredDefaultValue LimitsDescription
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
valueint
0 ~ 2147483646Stamina Value
The current stamina amount for this user, excluding any overflow.
This value increases automatically over time based on the recovery interval and recovery value, up to maxValue.
It is computed from the elapsed time since lastRecoveredAt using the formula: recoverSteps = elapsedMinutes / recoverIntervalMinutes.
overflowValueint
0 ~ 2147483646Overflow Value
The amount of stamina stored in excess of the normal maximum (maxValue).
This is only used when the StaminaModel has isOverflow enabled. The total effective stamina is value + overflowValue, capped at maxCapacity.
When stamina is consumed, overflow is consumed first before the base value.
maxValueint
1 ~ 2147483646Maximum Stamina
The per-user maximum stamina value, resolved from the StaminaModel and optionally overridden by a MaxStaminaTable based on the player’s GS2-Experience rank.
When overflow is disabled, this value is floored at initialCapacity. When overflow is enabled, it is capped at maxCapacity.
Natural time-based recovery stops at this value.
recoverIntervalMinutesint1 ~ 2147483646Stamina Recovery Interval (Minutes)
The per-user recovery interval in minutes, resolved from the StaminaModel and optionally overridden by a RecoverIntervalTable based on the player’s GS2-Experience rank.
If no table is configured, the value falls back to the model’s default recoverIntervalMinutes.
recoverValueint1 ~ 2147483646Stamina Recovery Amount
The per-user recovery amount per tick, resolved from the StaminaModel and optionally overridden by a RecoverValueTable based on the player’s GS2-Experience rank.
If no table is configured, the value falls back to the model’s default recoverValue.
nextRecoverAtlongNext Recovery Time
The Unix timestamp (in milliseconds) when the next stamina recovery tick will occur.
Calculated as lastRecoveredAt + recoverIntervalMinutes (in ms). When stamina is already at maxValue, this field may be unset.

EzStaminaModel

Stamina Model

Parameters such as the maximum value of stamina, recovery interval, and amount of recovery can be defined. You can also control the maximum value and the amount of recovery in conjunction with GS2-Experience.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsStamina Model name
Stamina Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadatastring~ 128 charsMetadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
recoverIntervalMinutesint
0 ~ 2147483646Recover Interval Minutes
The number of minutes between each stamina recovery tick.
Every time this interval elapses, the player’s stamina increases by the recover value amount.
Can be overridden per-user via GS2-Experience rank using a RecoverIntervalTable.
Set to 0 to disable automatic time-based recovery.
recoverValueint10 ~ 2147483646Recover Value
The amount of stamina recovered per recovery tick.
Each time the recover interval elapses, stamina increases by this value until the maximum is reached.
Can be overridden per-user via GS2-Experience rank using a RecoverValueTable.
Defaults to 1.
initialCapacityint
0 ~ 2147483646Initial Capacity
The default maximum stamina value for all players.
When overflow is disabled, this serves as the floor for the per-user maximum value.
Can be overridden per-user via GS2-Experience rank using a MaxStaminaTable.
isOverflowbool
Is Overflow
Whether stamina can exceed the initial capacity through means such as item usage.
When enabled, stamina can be set above initialCapacity up to maxCapacity. Natural time-based recovery still caps at the normal maximum.
When disabled, the per-user maximum value is clamped to at least initialCapacity.
maxCapacityint{isOverflow} == true
✓*
0 ~ 2147483646Max Capacity
The absolute upper limit of stamina when overflow is enabled.
Even with overflow, stamina cannot exceed this value. Only shown when isOverflow is true.
For example, if initialCapacity is 100 and maxCapacity is 200, items can boost stamina up to 200 but natural recovery stops at 100.

* Required if isOverflow is true
maxStaminaTableEzMaxStaminaTableMax Stamina Table
Reference to a MaxStaminaTable that dynamically determines the maximum stamina value based on the player’s GS2-Experience rank.
When set, the player’s max stamina is looked up from the table using their current rank index, overriding initialCapacity.
If not set, all players share the same initialCapacity as their maximum.
recoverIntervalTableEzRecoverIntervalTableRecover Interval Table
Reference to a RecoverIntervalTable that dynamically determines the recovery interval based on the player’s GS2-Experience rank.
When set, the player’s recovery interval is looked up from the table using their current rank index, overriding recoverIntervalMinutes.
If not set, all players share the same recoverIntervalMinutes.
recoverValueTableEzRecoverValueTableRecover Value Table
Reference to a RecoverValueTable that dynamically determines the recovery amount based on the player’s GS2-Experience rank.
When set, the player’s recovery value is looked up from the table using their current rank index, overriding recoverValue.
If not set, all players share the same recoverValue.

EzMaxStaminaTable

Maximum Stamina Table

This entity defines the maximum value of stamina for each rank of GS2-Experience.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsMaximum Stamina Table Name
Maximum Stamina Table-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadatastring~ 128 charsMetadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
experienceModelIdstring
~ 1024 charsExperience Model ID
The GRN of the GS2-Experience ExperienceModel used to look up the player’s current rank.
The rank index is used as an array index into the values list to determine the per-user maximum stamina.
valuesList<int>
1 ~ 1024 itemsMaximum Stamina Values by Rank
An array of maximum stamina values indexed by the player’s GS2-Experience rank index.
The value at index i is used as the maximum stamina for players at rank i. The array length should match the number of ranks defined in the referenced ExperienceModel.

EzRecoverIntervalTable

Recovery Interval Table

This entity defines the stamina recovery interval for each rank of GS2-Experience.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsStamina recovery interval table name
Stamina recovery interval table-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadatastring~ 128 charsMetadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
experienceModelIdstring
~ 1024 charsExperience Model ID
The GRN of the GS2-Experience ExperienceModel used to look up the player’s current rank.
The rank index is used as an array index into the values list to determine the per-user recovery interval.
valuesList<int>
1 ~ 1024 itemsRecovery Interval Values by Rank
An array of recovery interval values (in minutes) indexed by the player’s GS2-Experience rank index.
The value at index i is used as the recovery interval for players at rank i, overriding the model’s default recoverIntervalMinutes.

EzRecoverValueTable

Stamina Recovery Amount Table

This entity defines the amount of stamina recovery for each rank of GS2-Experience.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsStamina Recovery Amount Table name
Stamina Recovery Amount Table-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadatastring~ 128 charsMetadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
experienceModelIdstring
~ 1024 charsExperience Model ID
The GRN of the GS2-Experience ExperienceModel used to look up the player’s current rank.
The rank index is used as an array index into the values list to determine the per-user recovery amount.
valuesList<int>
1 ~ 1024 itemsRecovery Amount Values by Rank
An array of recovery amount values indexed by the player’s GS2-Experience rank index.
The value at index i is used as the recovery amount per tick for players at rank i, overriding the model’s default recoverValue.

Methods

getStaminaModel

Get a specific stamina type definition

Retrieves the definition for a specific type of stamina. The response includes the recovery interval (how often stamina recovers), recovery amount (how much recovers each time), maximum capacity, and overflow settings. Use this to display the rules for a specific stamina type — for example, showing “Action Stamina: recovers 1 every 5 minutes, max 100” on a stamina detail screen.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model name
Stamina Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

TypeDescription
itemEzStaminaModelStamina Model

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).StaminaModel(
        staminaName: "stamina-0001"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).StaminaModel(
        staminaName: "stamina-0001"
    );
    var future = domain.ModelFuture();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->StaminaModel(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->Model();
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
Value change event handling
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).StaminaModel(
        staminaName: "stamina-0001"
    );
    
    // Start event handling
    var callbackId = domain.Subscribe(
        value => {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

    // Stop event handling
    domain.Unsubscribe(callbackId);
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).StaminaModel(
        staminaName: "stamina-0001"
    );
    
    // Start event handling
    var callbackId = domain.Subscribe(
        value => {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

    // Stop event handling
    domain.Unsubscribe(callbackId);
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->StaminaModel(
        "stamina-0001" // staminaName
    );
    
    // Start event handling
    const auto CallbackId = Domain->Subscribe(
        [](TSharedPtr<Gs2::Stamina::Model::FStaminaModel> value) {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

    // Stop event handling
    Domain->Unsubscribe(CallbackId);

listStaminaModels

Get a list of stamina type definitions

Retrieves all stamina model definitions configured in the game. A stamina model defines the rules for a type of stamina — how fast it recovers over time, how much recovers at once, what the maximum capacity is, and whether it can overflow beyond the max. For example, you might have separate stamina models for “Action Stamina” (recovers 1 every 5 minutes, max 100) and “Arena Tickets” (recovers 1 every 2 hours, max 5). Some stamina models can also be linked to player level (via GS2-Experience), so higher-level players automatically get a higher max stamina or faster recovery. Use this to display available stamina types and their rules on a help screen or settings page.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

TypeDescription
itemsList<EzStaminaModel>List of Stamina Models

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    );
    var items = await domain.StaminaModelsAsync(
    ).ToListAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    );
    var it = domain.StaminaModels(
    );
    List<EzStaminaModel> items = new List<EzStaminaModel>();
    while (it.HasNext())
    {
        yield return it.Next();
        if (it.Error != null)
        {
            onError.Invoke(it.Error, null);
            break;
        }
        if (it.Current != null)
        {
            items.Add(it.Current);
        }
        else
        {
            break;
        }
    }
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    );
    const auto It = Domain->StaminaModels(
    );
    TArray<Gs2::UE5::Stamina::Model::FEzStaminaModelPtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }
Value change event handling
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    );
    
    // Start event handling
    var callbackId = domain.SubscribeStaminaModels(
        () => {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    domain.UnsubscribeStaminaModels(callbackId);
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    );
    
    // Start event handling
    var callbackId = domain.SubscribeStaminaModels(
        () => {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    domain.UnsubscribeStaminaModels(callbackId);
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    );
    
    // Start event handling
    const auto CallbackId = Domain->SubscribeStaminaModels(
        []() {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    Domain->UnsubscribeStaminaModels(CallbackId);

apply

Apply time-based natural recovery to stamina

Calculates how much stamina has recovered since the last update based on elapsed time, and applies that recovery to the current value. Stamina recovers automatically over time — for example, if the recovery interval is 5 minutes and recovery amount is 1, the player gains 1 stamina every 5 minutes up to the maximum. Normally, the server calculates recovery automatically when you read the stamina value. Call this explicitly when you need to ensure the latest recovered value is written to the server — for example, before checking if the player has enough stamina for an action that is not managed by GS2 transactions.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
gameSessionGameSession
GameSession

Result

TypeDescription
itemEzStaminaStamina
staminaModelEzStaminaModelStamina Model

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var result = await domain.ApplyAsync(
    );
    var item = await result.ModelAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var future = domain.ApplyFuture(
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->Apply(
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();

consume

Use (consume) stamina

Deducts the specified amount from the player’s current stamina. If the player doesn’t have enough stamina, the request fails with an error — the stamina is never reduced below zero. For example, if a quest costs 20 stamina and the player only has 15, the consumption fails and you can show a “Not enough stamina” message. Note: In most cases, stamina consumption is handled automatically by GS2-Quest or GS2-Showcase when starting a quest or making a purchase. You only need to call this directly if you want to consume stamina outside of those flows — for example, consuming stamina for a custom mini-game or training feature.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
gameSessionGameSession
GameSession
consumeValueint
1 ~ 2147483646Amount of stamina consumed

Result

TypeDescription
itemEzStaminaStamina
staminaModelEzStaminaModelStamina Model

Error

Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.

TypeBase TypeDescription
InsufficientExceptionBadRequestExceptionInsufficient remaining stamina.

Implementation Example

try {
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var result = await domain.ConsumeAsync(
        consumeValue: 50
    );
    var item = await result.ModelAsync();
} catch(Gs2.Gs2Stamina.Exception.InsufficientException e) {
    // Insufficient remaining stamina.
}
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var future = domain.ConsumeFuture(
        consumeValue: 50
    );
    yield return future;
    if (future.Error != null)
    {
        if (future.Error is Gs2.Gs2Stamina.Exception.InsufficientException)
        {
            // Insufficient remaining stamina.
        }
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->Consume(
        50 // consumeValue
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        auto e = Future->GetTask().Error();
        if (e->IsChildOf(Gs2::Stamina::Error::FInsufficientError::Class))
        {
            // Insufficient remaining stamina.
        }
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();

getStamina

Get the player’s current stamina for a specific type

Retrieves the player’s current stamina value for a specific stamina type, along with its model definition. The response includes the current value, maximum capacity, recovery interval, recovery amount, and overflow amount. Use this to display a specific stamina gauge — for example, showing “Action Stamina: 45/100” with a progress bar and “Full recovery in 4h 35m” on a quest start screen.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
gameSessionGameSession
GameSession

Result

TypeDescription
itemEzStaminaStamina
staminaModelEzStaminaModelStamina Model

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var future = domain.ModelFuture();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->Model();
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
Value change event handling
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    
    // Start event handling
    var callbackId = domain.Subscribe(
        value => {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

    // Stop event handling
    domain.Unsubscribe(callbackId);
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    
    // Start event handling
    var callbackId = domain.Subscribe(
        value => {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

    // Stop event handling
    domain.Unsubscribe(callbackId);
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    
    // Start event handling
    const auto CallbackId = Domain->Subscribe(
        [](TSharedPtr<Gs2::Stamina::Model::FStamina> value) {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

    // Stop event handling
    Domain->Unsubscribe(CallbackId);

listStaminas

Get a list of the player’s stamina values

Retrieves all of the player’s current stamina values across all stamina types. Each entry shows the current stamina amount, maximum capacity, and recovery status for each stamina type. Use this to display a stamina overview — for example, showing “Action Stamina: 85/100 (full in 1h 15m)” and “Arena Tickets: 3/5 (next in 1h 30m)” on the home screen or status bar.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
gameSessionGameSession
GameSession
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data items to retrieve

Result

TypeDescription
itemsList<EzStamina>List of Staminas
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var items = await domain.StaminasAsync(
    ).ToListAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var it = domain.Staminas(
    );
    List<EzStamina> items = new List<EzStamina>();
    while (it.HasNext())
    {
        yield return it.Next();
        if (it.Error != null)
        {
            onError.Invoke(it.Error, null);
            break;
        }
        if (it.Current != null)
        {
            items.Add(it.Current);
        }
        else
        {
            break;
        }
    }
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    const auto It = Domain->Staminas(
    );
    TArray<Gs2::UE5::Stamina::Model::FEzStaminaPtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }
Value change event handling
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    
    // Start event handling
    var callbackId = domain.SubscribeStaminas(
        () => {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    domain.UnsubscribeStaminas(callbackId);
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    
    // Start event handling
    var callbackId = domain.SubscribeStaminas(
        () => {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    domain.UnsubscribeStaminas(callbackId);
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    
    // Start event handling
    const auto CallbackId = Domain->SubscribeStaminas(
        []() {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    Domain->UnsubscribeStaminas(CallbackId);

setMaxValue

Update max stamina based on the player’s level

Updates the player’s maximum stamina capacity based on their current level (rank) from GS2-Experience. The stamina model can be configured with a “max stamina table” that maps player levels to max stamina values — for example, level 1 = max 50, level 10 = max 80, level 50 = max 150. When you call this, it reads the player’s current level from the signed GS2-Experience status and looks up the corresponding max stamina from the table. Call this after the player levels up to update their stamina cap — for example, when the player gains a level, call this so their max stamina increases from 80 to 85.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
gameSessionGameSession
GameSession
keyIdstring“grn:gs2:{region}:{ownerId}:key:default:key:default”~ 1024 charsEncryption Key GRN
signedStatusBodystring
~ 524288 charsGS2-Experience status body to be signed
signedStatusSignaturestring
~ 128 charsGS2-Experience Status Signature

Result

TypeDescription
itemEzStaminaStamina
oldEzStaminaStamina
staminaModelEzStaminaModelStamina Model

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var result = await domain.SetMaxValueAsync(
        signedStatusBody: "statusBody...",
        signedStatusSignature: "statusSignature...",
        keyId: "key-0001"
    );
    var item = await result.ModelAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var future = domain.SetMaxValueFuture(
        signedStatusBody: "statusBody...",
        signedStatusSignature: "statusSignature...",
        keyId: "key-0001"
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->SetMaxValue(
        "statusBody...", // signedStatusBody
        "statusSignature...", // signedStatusSignature
        "key-0001" // keyId
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();

setRecoverInterval

Update stamina recovery interval based on the player’s level

Updates how frequently the player’s stamina recovers based on their current level (rank) from GS2-Experience. The stamina model can be configured with a “recovery interval table” that maps player levels to recovery intervals (in minutes) — for example, level 1 = recover every 6 minutes, level 20 = every 5 minutes, level 50 = every 3 minutes. Call this after the player levels up so their stamina recovers more frequently — for example, when the player reaches level 20, recovery interval changes from 6 minutes to 5 minutes per stamina point.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
gameSessionGameSession
GameSession
keyIdstring“grn:gs2:{region}:{ownerId}:key:default:key:default”~ 1024 charsEncryption Key GRN
signedStatusBodystring
~ 524288 charsGS2-Experience status body to be signed
signedStatusSignaturestring
~ 128 charsGS2-Experience Status Signature

Result

TypeDescription
itemEzStaminaStamina
oldEzStaminaStamina
staminaModelEzStaminaModelStamina Model

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var result = await domain.SetRecoverIntervalAsync(
        signedStatusBody: "statusBody...",
        signedStatusSignature: "statusSignature...",
        keyId: "key-0001"
    );
    var item = await result.ModelAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var future = domain.SetRecoverIntervalFuture(
        signedStatusBody: "statusBody...",
        signedStatusSignature: "statusSignature...",
        keyId: "key-0001"
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->SetRecoverInterval(
        "statusBody...", // signedStatusBody
        "statusSignature...", // signedStatusSignature
        "key-0001" // keyId
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();

setRecoverValue

Update stamina recovery amount based on the player’s level

Updates how much stamina the player recovers per interval based on their current level (rank) from GS2-Experience. The stamina model can be configured with a “recovery value table” that maps player levels to recovery amounts — for example, level 1 = recover 1 per interval, level 20 = recover 2, level 50 = recover 3. Call this after the player levels up so their stamina recovers faster — for example, when the player reaches level 20, their recovery increases from 1 to 2 per interval, meaning they regain stamina twice as fast.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
staminaNamestring
~ 128 charsStamina Model Name
The name of the StaminaModel that defines the recovery parameters, capacity, and table references for this stamina instance.
This links the per-user stamina state to its corresponding model definition.
gameSessionGameSession
GameSession
keyIdstring“grn:gs2:{region}:{ownerId}:key:default:key:default”~ 1024 charsEncryption Key GRN
signedStatusBodystring
~ 524288 charsGS2-Experience status body to be signed
signedStatusSignaturestring
~ 128 charsGS2-Experience Status Signature

Result

TypeDescription
itemEzStaminaStamina
oldEzStaminaStamina
staminaModelEzStaminaModelStamina Model

Implementation Example

    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var result = await domain.SetRecoverValueAsync(
        signedStatusBody: "statusBody...",
        signedStatusSignature: "statusSignature...",
        keyId: "key-0001"
    );
    var item = await result.ModelAsync();
    var domain = gs2.Stamina.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Stamina(
        staminaName: "stamina-0001"
    );
    var future = domain.SetRecoverValueFuture(
        signedStatusBody: "statusBody...",
        signedStatusSignature: "statusSignature...",
        keyId: "key-0001"
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Stamina->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Stamina(
        "stamina-0001" // staminaName
    );
    const auto Future = Domain->SetRecoverValue(
        "statusBody...", // signedStatusBody
        "statusSignature...", // signedStatusSignature
        "key-0001" // keyId
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();