Skip to main content

GDTKStatsManager.AutoSubscribe

Declaration#

public static List<SimpleEvent> AutoSubscribe(string formula, SimpleEvent changeEvent, StatSource target, StatSource other)

Parameters#

NameDescription
formulaFormula to generate subscriptions for
changeEventEvent to raise via subscriptions
targetOriginating Stat Source
otherOther Stat Source

Description#

Automatically subscribe to other stats as needed to resolve a formula

Usage#

Example
using NullSave.GDTK.Stats;using UnityEngine;
public class Example : MonoBehaviour{
    public void ExampleMethod(StatSource other)    {        GDTKStatsManager.AutoSubscribe("health", SubscriptionUpdate, other);    }
    private void SubscriptionUpdate()    {        Debug.Log("A part of the formula updated");       }
}

Declaration#

public static List<SimpleEvent> AutoSubscribe(string formula, SimpleEvent changeEvent, Dictionary<string, StatSource> sources)

Parameters#

NameDescription
formulaFormula to generate subscriptions for
changeEventEvent to raise via subscriptions
sourcesDictionary of all Stat Sources available

Description#

Automatically subscribe to other stats as needed to resolve a formula

Usage#

Example
using NullSave.GDTK;using NullSave.GDTK.Stats;using System.Collections.Generic;using UnityEngine;
public class Example : MonoBehaviour{
    public void ExampleMethod(StatSource requester, StatSource other)    {        Dictionary<string, StatSource> source = new Dictionary<string, StatSource>        {            { "", requester },            { "other", other },            { "global", ToolRegistry.GetComponent<GlobalStats>().source }        };
        GDTKStatsManager.AutoSubscribe("health", SubscriptionUpdate, source);    }
    private void SubscriptionUpdate()    {        Debug.Log("A part of the formula updated");       }
}