Skip to main content

Food and Water

SurvFoodComponent owns both resources. SetComponentActive loads defaults and sets Hungry plus Thirsty, enabling drain on food pulses. ResetToDefaults/SetComponentInactive return state to Neutral, which suppresses drain.


API and Pulse Behavior​

GetFoodValue, GetWaterValue and GetFoodTagContainer query state. AddFood/AddWater take a positive amount and cap it at the configured maximum. Values above their minimum remove Starving/Dehydrated tags.

With defaults, an unmodified food pulse drains 1.5 food when Hungry and 1.5 water when Thirsty. UpdateReduceModifier scales these losses. CrossAffect.Food.HigherFoodDrain and HigherWaterDrain double the corresponding loss. UpdateAddModifier is declared but native AddValue does not use AddModifier; it adds the supplied amount directly.

AddFoodGameplayTag appends a tag under Cube_Survival.Food. SetFoodGameplayTag resets the container to the supplied tag; ResetFoodGameplayTag sets Neutral. Use these on authority, even though their native implementations do not consistently call CheckPawn.


Presentation​

OnFoodChanged, OnWaterChanged and OnFoodStateChanged can update local widgets. OnStarving/OnDehydrating are broadcast from numeric OnRep callbacks and may repeat for received values below a threshold, rather than firing once at a transition. Client-private thresholds are not initialized by server-only activation, so use replicated state tags or explicit UI configuration for threshold display.

For food consumption from Cube Inventory, implement a project server action that validates the item, removes a confirmed quantity and applies AddFood/AddWater. Survival does not supply an automatic inventory bridge.