LevelStatModifier
A class in Root.Township, Alta.StatSystem.
Networked component that holds a saved level from 0 to maxLevel and applies a flat modifier to a stat based on that level. The server changes the level and syncs it.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
NetworkEntityBehaviour,ISavable<LevelStatModifierData>,ISavableSave<LevelStatModifierData>,ISavableSaveBase - Derived types
LevelStatModifierData - Documented in Stats
Constructors
| Member | What it is |
|---|---|
LevelStatModifier() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private Stat affectingStat | Server: the stat being modified. |
private int currentLevel | The current level. Saved. |
private int maxLevel | Highest level. |
private StatModifier modifier | Server: the flat stat modifier applied for the current level. |
private int oldLevel | Unused. |
private IntEvent onCurrentLevelChanged | Event fired with the new level on both server and clients. |
private MethodSync sync | Network sync for the level. |
private StatManager targetManager | The stat manager holding the target stat. |
private StatDefinition targetStat | The stat to modify. |
private AnimationCurve valueAtLevel | Curve giving the modifier value for each level. |
Methods
| Member | What it is |
|---|---|
void DecreaseLevel(int amount = 1) | Server: lowers the level (not below 0), updates the modifier and syncs. |
void Empty() | Server: sets the level to 0, updates the modifier and syncs. |
void IncreaseLevel(int amount = 1) | Server: raises the level (capped at maxLevel), updates the modifier and syncs. |
override void Initialize() | Creates the level sync. |
override void InitializeAsServer(SpawnData data) | Finds the target stat and applies the saved level if above 0. |
override void OnConnected(Player player) | Sends the level to a joining player if above 0. |