Skip to main content

StatAffectingArea

A class in Root.Township, Alta.StatSystem.

Server trigger area that changes a stat by a fixed amount per second on every rigidbody inside it that has a matching StatAffectAccessor. Removes itself on clients.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private Dictionary<Rigidbody, Stat> affectedStatsThe stat being changed for each rigidbody inside.
private float affectValuePerSecondStat change per second. Negative drains.
private HashSet<Rigidbody> alreadyCheckedRigidbodies already seen, so several colliders on one body count once.
private bool isOnlyAffectingIfTargetHasStatOnly changes a stat whose base is above 0 (for example phantom heads only add nightmare to those who have some).
private AreaFilter targetFilter for which kinds of target the area affects.
private StatDefinition targetStatThe stat to change.
private static List<Rigidbody> toRemoveShared scratch list of destroyed rigidbodies to drop.
private IUnityUpdateMethod updateManagersThe registered UpdateManagers method.
private static UpdateModule updateModuleShared update module for all stat affecting areas.

Methods​

6 private and internal methods
MemberWhat it is
private void Awake()Destroys this component on clients, sets up the lookups on the server.
private void OnDestroy()Removes the update method.
private void OnDisable()Server: forgets everything inside and stops updating.
private void OnTriggerEnter(Collider other)Adds a rigidbody's stat when its accessor passes the target filter and has the stat. Starts the update on the first one.
private void OnTriggerExit(Collider other)Removes the rigidbody and stops updating when none are left.
private void UpdateManagers()Adds affectValuePerSecond times delta time to each stat, and drops destroyed rigidbodies.