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.
- Listed in Creatures and AI
- Inherits or implements
StatChangeHook - Nested types
OperationTarget,OperationTime,OperationType - Documented in Actions and decisions
Constructors
| Member | What it is |
|---|---|
FixedStatChangeHook() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<IAgent, float> addedExtras | Per creature, the difference a set operation made, used to revert it. |
private FixedStatChangeHook.OperationTarget operationTarget | Which part of the stat to change: base, minimum or maximum. |
private FixedStatChangeHook.OperationType operationType | Set, add or multiply. |
private FixedStatChangeHook.OperationTime statOperation | Flags for when to act: on start, on end, and revert on end. |
private float value | The value to set, add or multiply by. Default 0.5. |
Methods
| Member | What 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
| Member | What 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. |