A class in Root.Township, Alta.StatSystem.
Stat definition asset for Hunger, a ThresholdStat. The value drops each stat update, regenerates health when well fed and deals starve damage when low, all scaled by server config settings.
Constructors
| Member | What it is |
|---|
HungerStat() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
8 private and internal fields
| Member | What it is |
|---|
private StatDefinition fullnessStatDefinition | The Fullness stat; starve damage only applies while it is below 1. |
private AnimationCurve fullStateRegen | Curve from hunger value (0 hungry, 1 full) to health regained per tick. |
private StatDefinition healthDefinition | The Health stat that regen and starve damage change. |
private static DamageData hungerDamage | Damage data with the Hunger source. Not used in this build. |
private float hungerStarveDamage | Health removed per tick while starving. |
private float hungerTick | Hunger drop per tick in the asset. Not used; the server config's HungerTick is used instead. |
private StatDefinition recentDamageDefinition | Stat for recent damage; more of it means less regen. |
private float starveDamageHealthCutoff | Starving stops dealing damage once health base is below this. |
Methods
| Member | What it is |
|---|
override void Applied(StatManager manager, Stat stat) | Hooks the stat manager's update to drop hunger by the server config's HungerTick each tick, then sets up the threshold levels. |
protected override ModifierSet[] GetSets(StatManager manager, Stat stat) | Adds health regen to the top two threshold levels and starve damage to the lowest level. |
2 private and internal methods
| Member | What it is |
|---|
private void ProcessHealthRegen(Stat stat, Stat health, Stat recentDamage) | Adds health from fullStateRegen by hunger value, reduced by recent damage and scaled by the server's health regen multiplier. |
private void ProcessStarveDamage(Stat stat, Stat fullnessStat, Stat health) | Server config permitting, removes hungerStarveDamage health per tick while Fullness is below 1 and health is above the cutoff. |
Used in
Members of other types that take, return or hold a HungerStat: