update bot
This commit is contained in:
@@ -158,6 +158,7 @@ func add_message_to_bar(player_name: String, message: String, type: int = Messag
|
||||
# Remove oldest messages if over limit
|
||||
while message_container.get_child_count() > MAX_MESSAGES:
|
||||
var oldest = message_container.get_child(0)
|
||||
message_container.remove_child(oldest)
|
||||
oldest.queue_free()
|
||||
|
||||
# Auto-remove after duration with fade-out
|
||||
|
||||
+31
-11
@@ -25,6 +25,7 @@ var original_movement_range: int = 1
|
||||
@export var enhanced_gridmap_path: NodePath = "/root/Main/EnhancedGridMap"
|
||||
var enhanced_gridmap: EnhancedGridMap
|
||||
@export var current_position: Vector2i
|
||||
var target_position: Vector2i = Vector2i(-1, -1) # For collision prediction
|
||||
var is_player_moving: bool = false:
|
||||
get: return movement_manager.is_moving if movement_manager else false
|
||||
set(value): if movement_manager: movement_manager.is_moving = value
|
||||
@@ -170,6 +171,9 @@ func _ready():
|
||||
# =========================================================================
|
||||
# BOT-SPECIFIC SETUP - BotController handles bot AI, we just disable input
|
||||
# =========================================================================
|
||||
# =========================================================================
|
||||
# BOT-SPECIFIC SETUP - BotController handles bot AI
|
||||
# =========================================================================
|
||||
if is_bot == true or is_in_group("Bots"):
|
||||
# Disable input processing for bots
|
||||
set_process_input(false)
|
||||
@@ -200,7 +204,8 @@ func _ready():
|
||||
# Sync bot status to network
|
||||
if is_multiplayer_authority():
|
||||
rpc("sync_bot_status", true)
|
||||
return # Bot initialization complete - BotController handles AI
|
||||
|
||||
# Continue to manager initialization...
|
||||
|
||||
# =========================================================================
|
||||
# HUMAN PLAYER SETUP
|
||||
@@ -235,11 +240,13 @@ func _init_managers():
|
||||
add_child(race_manager)
|
||||
race_manager.initialize(self, enhanced_gridmap)
|
||||
|
||||
input_manager = load("res://scripts/managers/player_input_manager.gd").new()
|
||||
input_manager.name = "InputManager"
|
||||
add_child(input_manager)
|
||||
input_manager.initialize(self, movement_manager, race_manager)
|
||||
|
||||
# Skip InputManager for bots
|
||||
if not (is_bot or is_in_group("Bots")):
|
||||
input_manager = load("res://scripts/managers/player_input_manager.gd").new()
|
||||
input_manager.name = "InputManager"
|
||||
add_child(input_manager)
|
||||
input_manager.initialize(self, movement_manager, race_manager)
|
||||
|
||||
playerboard_manager = load("res://scripts/managers/playerboard_manager.gd").new()
|
||||
playerboard_manager.name = "PlayerboardManager"
|
||||
add_child(playerboard_manager)
|
||||
@@ -600,8 +607,16 @@ func handle_grid_click(grid_position: Vector2i):
|
||||
# Modify is_position_occupied to check for selected spawn points
|
||||
func is_position_occupied(pos: Vector2i) -> bool:
|
||||
for player in get_tree().get_nodes_in_group("Players"):
|
||||
if player != self and player.spawn_point_selected and player.current_position == pos:
|
||||
if player == self:
|
||||
continue
|
||||
|
||||
if player.spawn_point_selected and player.current_position == pos:
|
||||
return true
|
||||
|
||||
# Check target position (where they are moving to)
|
||||
if player.is_player_moving and player.target_position == pos:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func find_valid_starting_position() -> Vector2i:
|
||||
@@ -752,6 +767,9 @@ func move_player_to_clicked_position(grid_position: Vector2i):
|
||||
@rpc("any_peer", "call_local")
|
||||
func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
is_player_moving = true
|
||||
if path.size() > 0:
|
||||
target_position = Vector2i(path[-1].x, path[-1].y)
|
||||
|
||||
var tween = create_tween()
|
||||
tween.set_trans(Tween.TRANS_CUBIC)
|
||||
tween.set_ease(Tween.EASE_IN_OUT)
|
||||
@@ -762,6 +780,7 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
tween.tween_callback(func():
|
||||
current_position = Vector2i(path[-1].x, path[-1].y)
|
||||
is_player_moving = false
|
||||
target_position = Vector2i(-1, -1)
|
||||
|
||||
# Check if we've reached the finish line (uses lap-aware finish locations)
|
||||
var current_finish_locs = race_manager.get_current_finish_locations() if race_manager else finish_locations
|
||||
@@ -770,11 +789,12 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
|
||||
# Only clear visuals if this is a human player
|
||||
# Clear visuals for everyone including bots
|
||||
if clear_visual:
|
||||
enhanced_gridmap.clear_path_visualization()
|
||||
|
||||
# Only restore UI state if this is a human player
|
||||
if not (is_bot or is_in_group("Bots")):
|
||||
if clear_visual:
|
||||
enhanced_gridmap.clear_path_visualization()
|
||||
|
||||
# Restore movement range highlights if it was the player's turn
|
||||
if main and main.ui_manager.current_action_state == main.ui_manager.ActionState.MOVING and is_my_turn:
|
||||
highlight_movement_range()
|
||||
|
||||
Reference in New Issue
Block a user