feat: give the player embodied hunger, energy, and starvation death

This commit is contained in:
2026-08-08 23:38:50 +02:00
parent 21b2eb06da
commit 9678526c5a
11 changed files with 488 additions and 65 deletions
+33
View File
@@ -0,0 +1,33 @@
class_name PlayerNeedsSystem
extends RefCounted
var state := PlayerStateRecord.create()
func advance(village: SimVillage) -> bool:
if state.is_dead():
return false
var hunger_rate := 0.125 * village.food_modifier
if state.advance(hunger_rate, 0.5):
state.die()
return true
return false
func eat(amount: float) -> float:
var eaten := state.eat(amount)
return eaten
func respawn() -> void:
if state.is_dead():
state.respawn()
func apply_death_consequence(standing: PlayerStandingRecord) -> void:
var reduced := standing.get_standing() * PlayerStateRecord.DEATH_STANDING_PENALTY
standing.data["standing"] = reduced
func restore(record: PlayerStateRecord) -> void:
state = record if record != null else PlayerStateRecord.create()