feat: add actions based on village resources and profession

This commit is contained in:
Rijad Zuzo
2026-06-19 16:16:47 +02:00
parent f251423f62
commit fbe3487b56
3 changed files with 40 additions and 12 deletions
+37 -10
View File
@@ -28,23 +28,50 @@ func _init(
position = Vector3(randf_range(-8.0, 8.0), 0.0, randf_range(-8.0, 8.0))
func simulate_tick() -> void:
func simulate_tick(village: SimVillage) -> void:
hunger += 5.0
energy -= 2.0
hunger = clamp(hunger, 0.0, 100.0)
energy = clamp(energy, 0.0, 100.0)
if hunger > 75.0:
current_task = "eat"
hunger -= 25.0
elif energy < 30.0:
if village.food > 0:
current_task = "eat"
hunger -= 25.0
else:
current_task = "gather_food"
return
if energy < 30.0:
current_task = "rest"
energy += 20.0
elif profession == "farmer":
return
if village.food < 15.0:
current_task = "gather_food"
elif profession == "woodcutter":
return
if village.wood < 10.0:
current_task = "gather_wood"
elif profession == "guard":
return
if village.safety < 40.0 and profession == "guard":
current_task = "patrol"
elif profession == "scholar":
return
if village.knowledge < 10.0 and profession == "scholar":
current_task = "study"
else:
current_task = "wander"
return
match profession:
"farmer":
current_task = "gather_food"
"woodcutter":
current_task = "gather_wood"
"guard":
current_task = "patrol"
"scholar":
current_task = "study"
_:
current_task = "wander"