API Reference of GS2-Buff SDK for Game Engine

Model

EzBuffEntryModel

Buff Model

The amount of buff is managed by BuffEntryModel, and it is possible to associate multiple BuffEntryModels with a specific entry. The application order of BuffEntryModel is managed by the priority of BuffEntryModel, and the smaller the value of priority, the higher the priority.

There are two types of buff application methods, “Add” and “Mul”. Add is an instruction to add to the buff application rate, and Mul is an instruction to multiply the buff application rate. The default rate is 1.0, and setting Add 0.2 will make the buff application rate 1.2. Setting Mul 0.5 will make the buff application rate 0.5 times.

BuffEntryModel can be associated with events of GS2-Schedule, and it is possible to set to apply buffs only during the event holding period.

TypeRequireDefaultLimitationDescription
namestring~ 128 charsBuff entity name
metadatastring~ 2048 charsmetadata
targetTypeenum {
    “model”,
    “action”
}
~ 128 charsType of target to apply buff
targetModelEzBuffTargetModel{targetType} == “model”Model to apply buff
targetActionEzBuffTargetAction{targetType} == “action”Action to apply buff
expressionenum {
    “rate_add”,
    “mul”,
    “value_add”
}
~ 128 charsApplication type of buff
applyPeriodScheduleEventIdstring~ 1024 charsEvent ID to apply buff

Enumeration type definition to specify as targetType

Enumerator String DefinitionDescription
modelModel
actionAction

Enumeration type definition to specify as expression

Enumerator String DefinitionDescription
rate_addRate Add
mulMul
value_addValue Add

EzBuffTargetModel

Buff Target Model

TypeRequireDefaultLimitationDescription
targetModelNameenum {
"Gs2Exchange:RateModel",
"Gs2Exchange:IncrementalRateModel",
"Gs2Experience:Status",
"Gs2Formation:Mold",
"Gs2Idle:CategoryModel",
"Gs2Idle:Status",
"Gs2Inventory:Inventory",
"Gs2LoginReward:BonusModel",
"Gs2Mission:MissionTaskModel",
"Gs2Quest:QuestModel",
"Gs2Showcase:DisplayItem",
"Gs2Showcase:RandomDisplayItemModel",
"Gs2SkillTree:NodeModel",
"Gs2Stamina:Stamina",
}
~ 128 charsTypes of model to apply buffs
targetFieldNamestring~ 64 charsField name to which the buff is applied
conditionGrnsList<EzBuffTargetGrn>1 ~ 10 itemsList of buff application condition GRNs
ratefloat~ 1000000Rate

EzBuffTargetAction

Buff Target Action

TypeRequireDefaultLimitationDescription
targetActionNameenum {
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SubExperience",
"Gs2Experience:SubExperienceByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:ConsumeItemSet",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:ConsumeSimpleItems",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:ConsumeBigItem",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2Limit:CountUp",
"Gs2Limit:CountUpByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:Withdraw",
"Gs2Money:WithdrawByUserId",
"Gs2Money2:DepositByUserId",
"Gs2Money2:Withdraw",
"Gs2Money2:WithdrawByUserId",
"Gs2Stamina:ConsumeStamina",
"Gs2Stamina:ConsumeStaminaByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
}
~ 128 charsTypes of action to apply buffs
targetFieldNamestring~ 64 charsField name to which the buff is applied
conditionGrnsList<EzBuffTargetGrn>1 ~ 10 itemsList of buff application condition GRNs
ratefloat~ 1000000Rate

EzBuffTargetGrn

Buff Target GRN pattern

TypeRequireDefaultLimitationDescription
targetModelNamestring~ 64 charsBuff application condition model name
targetGrnstring~ 1024 charsBuff application condition GRN

Methods

getBuffEntryModel

Get buff rate model information

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
buffEntryNamestring~ 128 charsBuff entity name

Result

TypeDescription
itemEzBuffEntryModelBuff entity model

Implementation Example

    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    ).BuffEntryModel(
        buffEntryName: "character-level"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    ).BuffEntryModel(
        buffEntryName: "character-level"
    );
    var future = domain.ModelFuture();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Buff->Namespace(
        "namespace-0001" // namespaceName
    )->BuffEntryModel(
        "character-level" // buffEntryName
    );
    const auto Future = Domain->Model();
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
Value change event handling
    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    ).BuffEntryModel(
        buffEntryName: "character-level"
    );
    
    // 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.Buff.Namespace(
        namespaceName: "namespace-0001"
    ).BuffEntryModel(
        buffEntryName: "character-level"
    );
    var future = domain.ModelFuture();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Buff->Namespace(
        "namespace-0001" // namespaceName
    )->BuffEntryModel(
        "character-level" // buffEntryName
    );
    
    // Start event handling
    const auto CallbackId = Domain->Subscribe(
        [](TSharedPtr<Gs2::Buff::Model::FBuffEntryModel> value) {
            // Called when the value changes
            // The "value" is passed the value after the change.
        }
    );

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

listBuffEntryModels

Get list of buff rate model information

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name

Result

TypeDescription
itemsList<EzBuffEntryModel>List of buff rate models

Implementation Example

    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    );
    var items = await domain.BuffEntryModelsAsync(
    ).ToListAsync();
    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    );
    var it = domain.BuffEntryModels(
    );
    List<EzBuffEntryModel> items = new List<EzBuffEntryModel>();
    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->Buff->Namespace(
        "namespace-0001" // namespaceName
    );
    const auto It = Domain->BuffEntryModels(
    );
    TArray<Gs2::UE5::Buff::Model::FEzBuffEntryModelPtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }
Value change event handling
    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    );
    
    // Start event handling
    var callbackId = domain.SubscribeBuffEntryModels(
        () => {
            // Called when an element of the list changes.
        }
    );

    // Stop event handling
    domain.UnsubscribeBuffEntryModels(callbackId);
    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    );
    var it = domain.BuffEntryModels(
    );
    List<EzBuffEntryModel> items = new List<EzBuffEntryModel>();
    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->Buff->Namespace(
        "namespace-0001" // namespaceName
    );
    
    // Start event handling
    const auto CallbackId = Domain->SubscribeBuffEntryModels(
        []() {
            // Called when an element of the list changes.
        }
    );

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

applyBuff

Perform buff

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
itemsList<EzBuffEntryModel>List of applied buff models
newContextStackstringRequest of context in which buff is applied

Implementation Example

    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Buff(
    );
    var result = await domain.ApplyBuffAsync(
    );
    var item = await result.ModelAsync();
    var domain = gs2.Buff.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Buff(
    );
    var future = domain.ApplyBuffFuture(
    );
    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->Buff->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Buff(
    );
    const auto Future = Domain->ApplyBuff(
    );
    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();