feat: Introduce PlayerMovementManager to manage player movement, rotation, attack mode push mechanics, and grid-based collision detection.
This commit is contained in:
@@ -116,8 +116,13 @@ func _run_ai_tick():
|
||||
# Don't make new decisions while moving
|
||||
if actor.is_player_moving:
|
||||
return
|
||||
|
||||
# STOP N GO: Red light freezing logic
|
||||
if _should_freeze_for_stop_n_go():
|
||||
# print("[BotController] %s freezes for STOP phase!" % actor.name)
|
||||
return
|
||||
|
||||
print("[BotController] AI Tick: evaluating priorities...")
|
||||
# print("[BotController] AI Tick: evaluating priorities...")
|
||||
|
||||
# Evaluate board status
|
||||
var board_fullness = _get_board_fullness_ratio()
|
||||
@@ -401,7 +406,6 @@ func _try_move() -> bool:
|
||||
else:
|
||||
# PATHFINDING FAILED! (Likely stuck on wall/stand)
|
||||
# Attempt UNSTUCK move to any adjacent valid tile
|
||||
print("[BotController] Pathfinding failed for %s. Attempting UNSTUCK move." % actor.name)
|
||||
return await _try_unstuck_move()
|
||||
|
||||
# Execute SINGLE STEP movement using player manager
|
||||
@@ -409,6 +413,7 @@ func _try_move() -> bool:
|
||||
_is_processing_action = true
|
||||
_current_action = "moving"
|
||||
|
||||
|
||||
# Safety timeout to prevent infinite loop
|
||||
var max_wait_time = 2.0
|
||||
var elapsed = 0.0
|
||||
@@ -427,6 +432,20 @@ func _try_move() -> bool:
|
||||
|
||||
return false
|
||||
|
||||
func _should_freeze_for_stop_n_go() -> bool:
|
||||
"""Check if the bot should intentionally skip its turn during STOP phase outside of safe zones."""
|
||||
var main = get_tree().root.get_node_or_null("Main")
|
||||
if not main: return false
|
||||
|
||||
var sng_manager = main.get_node_or_null("StopNGoManager")
|
||||
if sng_manager and sng_manager.get("is_active") and sng_manager.get("current_phase") == 1: # Phase.STOP is 1
|
||||
# Check if we are outside the safe zone
|
||||
var tile = enhanced_gridmap.get_cell_item(Vector3i(actor.current_position.x, 0, actor.current_position.y))
|
||||
if tile != sng_manager.TILE_SAFE:
|
||||
return true # Red Light! Freeze!
|
||||
|
||||
return false
|
||||
|
||||
func _try_unstuck_move() -> bool:
|
||||
"""Randomly move to ANY adjacent valid tile to escape sticky situations."""
|
||||
var neighbors = enhanced_gridmap.get_neighbors(actor.current_position, 0)
|
||||
|
||||
Reference in New Issue
Block a user