feat: give the player embodied hunger, energy, and starvation death
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user