-
Notifications
You must be signed in to change notification settings - Fork 12
Health Controller
HealthController class is responsible for controlling all player's health parameters, such as:
- Food Level
- Water Level
- Stamina
- Top Blood Pressure
- Bottom Blood Pressure
- Heart Rate
- Body Temperature
- Fatigue Level
- Movement speed and movement ability
The main code of this class is being called once per HealthUpdateInterval constant real seconds (currently, once per second) and modifies player parameters according to environment, player condition (running, walking, sleeping, etc.), current side effects, player's current diseases and injuries.
All player parameters are linked to the game time, so we can easily fast-forward time in game, and all parameters will be calculated correctly. This is crucial for sleep and blackouts -- where time is being fast-forwarded by minutes or hours.
HealthController also "animates" current player parameters, so they are not "staying still" all the time.
Generally speaking, the task of the Health Controller is to take the "healthy" ("etalon") player state every HealthUpdateInterval real seconds, add to it all the disease and monitors bonuses, update all disease and medical monitors and notify the world outside about the health events if any.
This class contains the following sub-controllers:
- UnderwaterEffectsController
- RunningHealthEffectsController
- FatigueHealthEffectsController
- InventoryHealthEffectsController
- MedicalAgentsSideEffectsController
- ActiveMedicalAgentsMonitorsNode
HealthController triggers the following game events:
Health-related deaths (from natural causes):
- Disease death
- Overdose death
- Heart failure death
- Vitals death (low or high blood pressure, low or high body temperature, low or high heart rate)
- Blood level death
- Dehydration death
- Starvation death
Visual effects (dizziness, blackouts and LSD):
Not the actual visual effects but events that you may listen to to initiate ones.
- Disease dizziness
- Disease blackout
- Fatigue dizziness
- Fatigue blackout
- Blood level dizziness
- Blood level blackout
- Low body temperature dizziness
- Low body temperature blackouts
- LSD effect trigger
Force sleep
- Fatigue force-sleep
- Sedative force-sleep
Other health-related events
- Sneeze
- Cough
- High pressure
- Intense running
Other Deaths:
- Hypothermia death
- Hyperthermia death
- Drowning death (when oxygen ends)
- Drowning event (when stamina ends while swimming or underwater)
Other events:
- Player freezed by inventory overload
HealthController contains the following public properties:
- Status (current core health parameters)
- IsTired
- IsExhausted
- IsExtremelyExhausted
- IsSleepDisorder
- IsSleepAllowedByMedicine
- IsInventoryOverload
- UnconsciousMode
- Medicine
UnconsciousMode can be set from outside. If true
, this flag tells HealthController to trigger Unconscious Mode behavior (this property is true when player is sleeping for example). In this mode some optional checks are not being made, but health update frequency is increased.
HealthController
has OnConsumeItem method that is called by the InventoryController's TryUse method if item is a consumable. HealthController
notifies every active disease, medical agent and consumables side effects controller in turn.
Also, when applying bandages, splints, making injections, we need to call OnApplianceTaken of the HealthController
to update the Appliances collection and notify all active diseases and injuries for them to correctly perform treatment. See here to read more.