API Reference of GS2-MegaField SDK for Game Engine

Model

EzAreaModel

Area divides space, and different areas can be treated as different spaces even if they have the same coordinates.

TypeRequireDefaultLimitationDescription
namestring~ 128 charsArea Model Name
metadatastring~ 2048 charsmetadata
layerModelsList<EzLayerModel>~ 1000 itemsList of layer models

EzLayerModel

Layers allow for multiple logical hierarchies within a single space. For example, it solves the problem of an Enemy being invisible in a space with a large number of characters. Characters are placed on Layer 1. If Enemies are placed on Layer 2, there is no need to worry about them becoming invisible, since each layer can specify the quantity to be acquired within a specified distance.

TypeRequireDefaultLimitationDescription
namestring~ 128 charsLayer Model Name
metadatastring~ 2048 charsmetadata

EzMyPosition

My Location

TypeRequireDefaultLimitationDescription
positionEzPositionPosition
vectorEzVectorVector
rfloat1~ 10000Radius

EzPosition

Position

TypeRequireDefaultLimitationDescription
xfloat~ 1048574X position
yfloat~ 1048574Y position
zfloat~ 1048574Z position

EzScope

Surroundings to be acquired

TypeRequireDefaultLimitationDescription
rfloat1 ~ 16777214Radius
limitint1 ~ 100Maximum number of result

EzSpatial

Spatial

TypeRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
areaModelNamestring~ 128 charsArea name
layerModelNamestring~ 128 charsLayer name
positionEzPositionPosition
vectorEzVectorVector

EzVector

Position

TypeRequireDefaultLimitationDescription
xfloat~ 1048574X position
yfloat~ 1048574Y position
zfloat~ 1048574Z position

Methods

describeAreaModels

Get list of Area Model

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name

Result

TypeDescription
itemsList<EzAreaModel>List of Area Models

Implementation Example

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

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

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

getAreaModel

Get Area Model

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
areaModelNamestring~ 128 charsArea Model Name

Result

TypeDescription
itemEzAreaModelArea Model

Implementation Example

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

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

describeLayerModels

Get list of Layer Model

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
areaModelNamestring~ 128 charsArea Model Name

Result

TypeDescription
itemsList<EzLayerModel>List of Layer Model

Implementation Example

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

    // Stop event handling
    domain.UnsubscribeLayerModels(callbackId);
    var domain = gs2.MegaField.Namespace(
        namespaceName: "namespace-0001"
    ).AreaModel(
        areaModelName: "area-0001"
    );
    var it = domain.LayerModels(
    );
    List<EzLayerModel> items = new List<EzLayerModel>();
    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->MegaField->Namespace(
        "namespace-0001" // namespaceName
    )->AreaModel(
        "area-0001" // areaModelName
    );
    
    // Start event handling
    const auto CallbackId = Domain->SubscribeLayerModels(
        []() {
            // Called when an element of the list changes.
        }
    );

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

getLayerModel

Get Layer Model

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
areaModelNamestring~ 128 charsArea Model Name
layerModelNamestring~ 128 charsLayer Model Name

Result

TypeDescription
itemEzLayerModel

Implementation Example

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

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

update

Send position

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
areaModelNamestring~ 128 charsArea name
layerModelNamestring~ 128 charsLayer name
positionEzMyPositionMy Location
scopesList<EzScope>~ 10 itemsList of Scope of acquisition by other players
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
itemsList<EzSpatial>List of Spatial

Implementation Example

    var domain = gs2.MegaField.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Spatial(
        areaModelName: "area-0001",
        layerModelName: "layer-0001"
    );
    var result = await domain.UpdateAsync(
        position: ,
        scopes: null
    );
    var item = await result.ModelAsync();
    var domain = gs2.MegaField.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Spatial(
        areaModelName: "area-0001",
        layerModelName: "layer-0001"
    );
    var future = domain.UpdateFuture(
        position: ,
        scopes: null
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.Model();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->MegaField->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Spatial(
        "area-0001", // areaModelName
        "layer-0001" // layerModelName
    );
    const auto Future = Domain->Update(
         // position
        // scopes
    );
    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();