feat: add proper death from starvation and survival tasks urgency

This commit is contained in:
Rijad Zuzo
2026-06-21 23:37:58 +02:00
parent eef2068747
commit b5e2493c2a
6 changed files with 165 additions and 20 deletions
+28
View File
@@ -20,10 +20,16 @@ var path_index := 0
var current_target := Vector3.INF
var arrival_distance := 0.6
var is_dead_visual := false
var dead_material := StandardMaterial3D.new()
func debug_log(message: String) -> void:
if DEBUG_LOGS:
print("[NPCVisual] ", name, " | ", message)
func _ready() -> void:
dead_material.albedo_color = Color(0.25, 0.25, 0.25, 1.0)
func setup_from_sim(npc: SimNPC) -> void:
sim_id = npc.id
npc_name = npc.npc_name
@@ -59,6 +65,11 @@ func set_target_position(pos: Vector3) -> void:
debug_log("New target: %s Path points: %s" % [pos, current_path.size()])
func _physics_process(delta: float) -> void:
if is_dead_visual:
velocity = Vector3.ZERO
move_and_slide()
return
if current_target == Vector3.INF:
velocity = Vector3.ZERO
move_and_slide()
@@ -104,3 +115,20 @@ func _report_arrival_once() -> void:
debug_log("Arrived at target")
arrived_at_target.emit(sim_id)
func apply_dead_visual_state() -> void:
is_dead_visual = true
velocity = Vector3.ZERO
current_path = PackedVector3Array()
path_index = 0
current_target = Vector3.INF
has_reported_arrival = true
scale = Vector3(0.8, 0.25, 1.2)
rotation_degrees.x = 90.0
for child in get_children():
if child is MeshInstance3D:
child.material_override = dead_material
debug_log("Applied dead visual state")