Hunger

This component lets your prefab starve over time. That’s the entire game concept in a single component.

Component Hunger Fields

TypeNameDescription
numbermaxhow much fits into the tummy
numberhungerrate, hurtratehow fast one starves
booleanburningtoggle hunger
numberperiodhow often hunger calculates (adjust the rates respectively)
functionredirectOverrides hunger calculations. Args: inst, delta, overtime

Component Hunger Methods

NameParameterReturnsDescription
Pause-nilsets "burning" to false
Resume-nilsets "burning" to true
SetMaxvalnilalso fills the belly
IsStarving-booleanwhether the current value is at 0 or below
DoDeltaval, overtime, ignore_invinciblenilchanges the current value by "val", overtime means without blinking
GetPercent-number (percent)current percent of belly filled
SetPercentpercentnilsets the current value in a very crude way
DoDectime, ignore_damagenilupdate over time, "ignore_damage" means whether health is affected
SetRaterate (per second)nilchanges the rate of hunger
SetKillRaterate (per second)nilchanges the rate of starvation

Component Hunger Events

NameDataFires in/when...
hungerdeltaoldpercent, newpercent, overtimeFires after calculations
startstarvingnilFires at the end of DoDelta, if now starving
stopstarvingnilFires at the end of DoDelta, if no longer starving

Example