SendCommand

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

public void SendCommand(string command)

Description

Sends a command for processing.

Valid Commands

addAdds a StatEffect. Example: add Blindness
removeRemovesa StatEffect. Example: remove Blindness
removeAllRemoves all instances of a StatEffect. Example: removeAll Poison
clearClears all active StatEffects. Example: clear
setmaxSets a StatValue to its current allowed maximum. Example: setmax HP
valueSets the current value of a StatValue. Example: value HP = END * 4
minSets the current minimum value of a StatValue. Example: min HP = 7
maxSets the current maximum value of a StatValue. Example: max HP = END * (4 + AP) / 2

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;
        }
    }

}