feat: add npc simulation, instancing and visual scene

This commit is contained in:
Rijad Zuzo
2026-06-18 11:12:08 +02:00
parent a504ed8112
commit a3ad8d8a07
14 changed files with 94 additions and 8 deletions
+50
View File
@@ -0,0 +1,50 @@
class_name SimNPC
extends RefCounted
var id: int
var npc_name: String
var profession: String
var hunger: float
var energy: float
var strength: float
var intelligence: float
var current_task: String = "idle"
var position: Vector3
func _init(
_id: int,
_npc_name: String,
_profession: String,
_strength: float,
_intelligence: float
) -> void:
id = _id
npc_name = _npc_name
profession = _profession
strength = _strength
intelligence = _intelligence
hunger = randf_range(20.0, 80.0)
energy = randf_range(40.0, 100.0)
position = Vector3(randf_range(-8.0, 8.0), 0.0, randf_range(-8.0, 8.0))
func simulate_tick() -> void:
hunger += 5.0
energy -= 2.0
if hunger > 75.0:
current_task = "eat"
hunger -= 25.0
elif energy < 30.0:
current_task = "rest"
energy += 20.0
elif profession == "farmer":
current_task = "gather_food"
elif profession == "woodcutter":
current_task = "gather_wood"
elif profession == "guard":
current_task = "patrol"
elif profession == "scholar":
current_task = "study"
else:
current_task = "wander"