feat: Implement cycle timer toggle, refactor continuous input, and improve movement synchronization.

This commit is contained in:
2026-01-07 05:41:38 +08:00
parent 251b677a2e
commit 6aede0a382
11 changed files with 210 additions and 58 deletions
+44 -35
View File
@@ -9,6 +9,43 @@ func initialize(p_player: Node3D, p_movement_manager: Node, p_race_manager: Node
movement_manager = p_movement_manager
race_manager = p_race_manager
func _process(delta):
# Early return conditions
if not is_instance_valid(player) or not player.is_multiplayer_authority() or player.is_bot or player.is_in_group("Bots"):
return
if TurnManager.turn_based_mode:
return
# Continuous movement input
var target_position = player.current_position
if Input.is_action_pressed("move_north"):
target_position += Vector2i(0, -1)
elif Input.is_action_pressed("move_northeast"):
target_position += Vector2i(1, -1)
elif Input.is_action_pressed("move_east"):
target_position += Vector2i(1, 0)
elif Input.is_action_pressed("move_southeast"):
target_position += Vector2i(1, 1)
elif Input.is_action_pressed("move_south"):
target_position += Vector2i(0, 1)
elif Input.is_action_pressed("move_southwest"):
target_position += Vector2i(-1, 1)
elif Input.is_action_pressed("move_west"):
target_position += Vector2i(-1, 0)
elif Input.is_action_pressed("move_northwest"):
target_position += Vector2i(-1, -1)
# Action inputs (still momentary)
if Input.is_action_just_pressed("action_grab"):
player.grab_item(player.current_position)
elif Input.is_action_just_pressed("action_put"):
player.auto_put_item()
if target_position != player.current_position:
movement_manager.simple_move_to(target_position)
func handle_unhandled_input(event):
# Early return if not authorized human player
if not player.is_multiplayer_authority() or player.is_bot or player.is_in_group("Bots"):
@@ -19,41 +56,13 @@ func handle_unhandled_input(event):
if not main:
return
# --- Real-time Keyboard/Touch Input ---
if not TurnManager.turn_based_mode and not movement_manager.is_moving:
var target_position = player.current_position
var input_handled = true
# Turn-based mouse input (handled in unhandled_input)
if not player.is_multiplayer_authority() or (TurnManager.turn_based_mode and (not player.is_my_turn or movement_manager.is_moving)):
return
if Input.is_action_just_pressed("move_north"):
target_position += Vector2i(0, -1)
elif Input.is_action_just_pressed("move_northeast"):
target_position += Vector2i(1, -1)
elif Input.is_action_just_pressed("move_east"):
target_position += Vector2i(1, 0)
elif Input.is_action_just_pressed("move_southeast"):
target_position += Vector2i(1, 1)
elif Input.is_action_just_pressed("move_south"):
target_position += Vector2i(0, 1)
elif Input.is_action_just_pressed("move_southwest"):
target_position += Vector2i(-1, 1)
elif Input.is_action_just_pressed("move_west"):
target_position += Vector2i(-1, 0)
elif Input.is_action_just_pressed("move_northwest"):
target_position += Vector2i(-1, -1)
elif Input.is_action_just_pressed("action_grab"):
player.grab_item(player.current_position)
elif Input.is_action_just_pressed("action_put"):
player.auto_put_item()
else:
input_handled = false
if target_position != player.current_position:
movement_manager.simple_move_to(target_position)
if input_handled:
player.get_viewport().set_input_as_handled()
return
# --- End Real-time Input ---
# --- Real-time Keyboard/Touch Input moved to _process ---
# Handle spawn point selection if not yet selected
# Handle spawn point selection if not yet selected
if not player.spawn_point_selected and player.highlighted_spawn_points.size() > 0:
@@ -65,7 +74,7 @@ func handle_unhandled_input(event):
var click_position = player.raycast_to_grid(from, to)
if click_position in player.highlighted_spawn_points:
if player.select_spawn_point(click_position):
return
return
# Turn-based mouse input
if not player.is_multiplayer_authority() or (TurnManager.turn_based_mode and (not player.is_my_turn or movement_manager.is_moving)):