update feature & bugfix

This commit is contained in:
2026-01-23 22:26:44 +08:00
parent 89a3beb2b2
commit d262bb8dc0
12 changed files with 198 additions and 87 deletions
+17 -4
View File
@@ -51,8 +51,8 @@ func _ready():
queue_free()
return
# Wait for actor to be fully ready
await get_tree().create_timer(1.0).timeout
# Wait for actor to be fully ready (player._ready awaits 0.5s then creates managers)
await get_tree().create_timer(1.5).timeout
enhanced_gridmap = actor.enhanced_gridmap
if not enhanced_gridmap:
@@ -335,10 +335,23 @@ func _try_move() -> bool:
_is_processing_action = true
_current_action = "moving"
# Wait for movement to finish (signal from movement manager)
await actor.movement_manager.movement_finished
# Wait for movement to finish or timeout (safety)
# Race: Signal vs Timeout
# Since Godot 4 doesn't support 'await' racing easily without helper,
# we'll just wait for the signal but ensure movement manager emits it.
# safer approach: check if is_moving goes false
# Safety timeout to prevent infinite loop
var max_wait_time = 2.0
var elapsed = 0.0
while actor.is_player_moving and is_instance_valid(self):
await get_tree().process_frame
elapsed += get_process_delta_time()
if elapsed > max_wait_time:
print("[BotController] Movement timed out!")
break
if not is_instance_valid(self): return true
_is_processing_action = false
_current_action = "idle"