Skip to main content

StatChangeHook

An abstract class in Root.Township, Alta.Intelligence.

Base AI hook that grabs a stat on the creature or its target when its action starts, and lets subclasses change it at the start and end. FixedStatChangeHook and ProgressStatChangeHook build on it.

Constructors​

MemberWhat it is
protected StatChangeHook()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
protected Dictionary<IAgent, Stat> affectedStatsThe stat being changed, per running creature. Entries are only removed when the action ends.
2 private and internal fields
MemberWhat it is
private bool isTargetChange the stat on the creature's target instead of the creature.
private StatDefinition targetStatWhich stat to change.

Methods​

MemberWhat it is
protected abstract void AffectOnEnd(IActiveAction finished)Subclass: change the stat when the action finishes or is cancelled.
protected abstract void AffectOnStart(IActiveAction active)Subclass: change the stat when the action starts.
protected override void FinishedOrCancelled(IActiveAction finished)Calls AffectOnEnd and forgets the creature's stat, if one was found at the start.
protected override void Used(IActiveAction active)When the action starts, finds targetStat on the creature (or its target), stores it and calls AffectOnStart.