34 lines
755 B
GDScript
34 lines
755 B
GDScript
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()
|