Skip to main content

FixedStatChangeHook

A class in Root.Township, Alta.Intelligence.

AI hook that changes one of the creature's stats (its base, min or max) by a fixed value when the action starts or ends, and can undo it on end.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Dictionary<IAgent, float> addedExtrasPer creature, the difference a set operation made, used to revert it.
private FixedStatChangeHook.OperationTarget operationTargetWhich part of the stat to change: base, minimum or maximum.
private FixedStatChangeHook.OperationType operationTypeSet, add or multiply.
private FixedStatChangeHook.OperationTime statOperationFlags for when to act: on start, on end, and revert on end.
private float valueThe value to set, add or multiply by. Default 0.5.

Methods​

MemberWhat it is
protected override void AffectOnEnd(IActiveAction finished)On end, applies the change again if set to affect on end, or else reverts it if set to revert on end.
protected override void AffectOnStart(IActiveAction active)On start, applies the change if set to affect on start.
4 private and internal methods
MemberWhat it is
private float GetAffectedStat(IAgent topic)Reads the chosen part (base, min or max) of the creature's affected stat, or 0 if it has none.
private void OperateOnStat(IAgent topic)Sets, adds or multiplies the chosen part by value. For a set, remembers the difference so it can be reverted.
private void RevertOperateOnStat(IAgent topic)Undoes the change: subtracts the remembered difference, subtracts the value, or divides by it.
private void SetAffectedStat(IAgent topic, float value)Writes the chosen part of the creature's affected stat.