Load

TOCK by NullSave\Stats Cog\Scripts\StatsCog.cs

public override void Load(Stream stream)
public void Load(string filename)

Description

Loads data from a stream or file.

using UnityEngine;
using NullSave.TOCK.Stats;
using System.IO;

public class Example : MonoBehaviour
{

    public StatsCog statsCog;

    float clearTime;
    void Start()
    {
        clearTime = Time.time + 3;

        statsCog.AddEffect("Blindness");
        statsCog.AddEffect("Poison");
        statsCog.AddEffect("Poison");
        statsCog.AddEffect("Blindness");
        statsCog.AddEffect(statsCog.effects[3]);

        if (statsCog.EvaluateCondition("1 > 2"))
        {
            Debug.Log("Um, that's just no.");
        }
        else
        {
            Debug.Log("2 is greater than 1? Who knew?!");
        }

        StatValue stat = statsCog.FindStat("HP");
        stat.Initialize(statsCog);

        Debug.Log("HP + 2 = " + statsCog.GetExpressionValue("HP + 2");

        MemoryStream ms = new MemoryStream();
        statsCog.Save(ms);

        statsCog.RemoveEffect("Blindness");
        statsCog.RemoveEffect("Poison");
        statsCog.SendCommand("HP = HP + 2 * 1.4");

        statsCog.Load(ms);
    }

    private void Update()
    {
        if (clearTime > 0 && Time.time >= clearTime)
        {
            statsCog.ClearEffects();
            clearTime = 0;
        }
    }

}