fix: empty-path re-entrancy, retry_count reset, := to = for Variant
This commit is contained in:
@@ -98,6 +98,7 @@ func simulate_tick() -> void:
|
||||
village.apply_npc_task(npc)
|
||||
|
||||
village_was_changed = true
|
||||
npc.retry_count = 0
|
||||
|
||||
npc.task_complete = true
|
||||
npc.task_state = SimNPC.TASK_STATE_IDLE
|
||||
@@ -110,6 +111,15 @@ func simulate_tick() -> void:
|
||||
if DEBUG_LOGS:
|
||||
print("[SimulationManager] ", npc.npc_name, " gathered food while starving and is going to eat immediately.")
|
||||
|
||||
if npc.task_state == SimNPC.TASK_STATE_TRAVELING and npc.target_id == &"":
|
||||
npc.retry_count += 1
|
||||
if npc.retry_count >= 5:
|
||||
if DEBUG_LOGS:
|
||||
print("[SimulationManager] ", npc.npc_name, " stuck traveling without target for ", npc.retry_count, " attempts, replanning")
|
||||
npc.task_state = SimNPC.TASK_STATE_IDLE
|
||||
npc.current_task = ""
|
||||
npc.retry_count = 0
|
||||
|
||||
if DEBUG_LOGS:
|
||||
print(
|
||||
npc.npc_name,
|
||||
@@ -176,6 +186,8 @@ func notify_npc_arrived(npc_id: int) -> void:
|
||||
print("[SimulationManager] ", npc.npc_name, " arrived but target ", npc.target_id, " is unavailable, replanning")
|
||||
release_npc_reservation(npc.id)
|
||||
npc.task_state = SimNPC.TASK_STATE_IDLE
|
||||
npc.current_task = ""
|
||||
npc.retry_count += 1
|
||||
return
|
||||
|
||||
npc.start_working()
|
||||
|
||||
Reference in New Issue
Block a user