Skip to main content

StatBonusSkill

A class in Root.Township, the global namespace.

Profession skill asset that changes one of the player's stats while unlocked: multiplies, adds to or sets its max, base value or min. Reapplied whenever the player gets a new body.

Constructors​

MemberWhat it is
StatBonusSkill()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

5 private and internal fields
MemberWhat it is
private Dictionary<Player, float> defaultValuesPer player, the stat value from before a Set operation, restored on lock.
private StatBonusSkill.OperationTarget operationTargetWhich part of the stat changes: max, base value or min.
private StatBonusSkill.OperationType operationTypeHow value is applied: multiply, add or set.
private StatDefinition targetStatThe stat to change.
private float valueThe amount used by the operation.

Methods​

MemberWhat it is
override void Lock(PlayerProgressionManager player)Stops listening for new player controllers and undoes the change on the current one.
override void Unlock(PlayerProgressionManager player)Applies the bonus now and again each time the player's controller is set.
3 private and internal methods
MemberWhat it is
private void PrepareGetSet(PlayerController playerController, out Func<float> get, out Action<float> set)Builds getter and setter functions for the chosen part (max, base or min) of the target stat.
private void RemoveValue(PlayerController playerController)Undoes the change: divides, subtracts, or restores the value saved before a set.
private void SetValue(Player player, PlayerController playerController)On the next frame, applies the operation to the stat on the given player controller.