public void AddClock(BuffClock clock) { Clocks.Add(clock); Action removeCallback = null; removeCallback = () => { Clocks.Remove(clock); clock.StackSize.OnValueChanged -= RecalculateStackSizeCallback; clock.OnRemove -= removeCallback; clock.OnTick -= OnTick; if (Clocks.Count == 0) { RemoveBuff(); } else { RecalculateStackSize(); } }; clock.StackSize.OnValueChanged += RecalculateStackSizeCallback; clock.OnRemove += removeCallback; clock.OnTick += OnTick; RecalculateStackSizeCallback(0); }
public void Update(float deltaTime) { for (int i = Clocks.Count - 1; i >= 0; i--) { BuffClock clock = Clocks[i]; clock.Update(deltaTime); } }
public Buff(BuffTemplate _buffTemplate, RPGCharacter _target, BuffClock baseClock) { buffTemplate = _buffTemplate; buffTemplate.SetupGraph(this); buffInput = buffTemplate.GetNode <BuffInputNode>(); buffInput.Target.GetEntry(this).Value = _target; AddClock(baseClock); BaseStackSize.onChanged += RecalculateStackSize; OnRemove += () => { buffTemplate.RemoveGraph(this); }; buffInput.SetTarget(this, this); }
public void RemoveClock(BuffClock clock) { clock.OnTick -= OnTick; clock.RemoveClock(); }