GDTKStatsManager.AutoSubscribe
Declaration#
public static List<SimpleEvent> AutoSubscribe(string formula, SimpleEvent changeEvent, StatSource target, StatSource other)Parameters#
| Name | Description |
|---|---|
| formula | Formula to generate subscriptions for |
| changeEvent | Event to raise via subscriptions |
| target | Originating Stat Source |
| other | Other 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#
| Name | Description |
|---|---|
| formula | Formula to generate subscriptions for |
| changeEvent | Event to raise via subscriptions |
| sources | Dictionary 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"); }
}