feat: Introduce PlayerMovementManager to manage player movement, rotation, attack mode push mechanics, and grid-based collision detection.

This commit is contained in:
Yogi Wiguna
2026-02-20 17:54:58 +08:00
parent e90cbfe246
commit 0e4d69f7b9
8 changed files with 193 additions and 61 deletions
+9 -10
View File
@@ -237,9 +237,9 @@ func _ready():
set_process_input(false)
set_process_unhandled_input(false)
# Set initial position for bots
# Set initial position for bots (Only if NOT randomized/Stop N Go by server)
if enhanced_gridmap:
if is_multiplayer_authority():
if is_multiplayer_authority() and not LobbyManager.get_randomize_spawn() and LobbyManager.game_mode != "Stop n Go":
current_position = _find_random_spawn_position()
update_player_position(current_position)
spawn_point_selected = true
@@ -270,12 +270,12 @@ func _ready():
enhanced_gridmap.set_diagonal_movement(use_diagonal_movement)
# Only set position if not using random spawn (host will assign via RPC)
if not LobbyManager.get_randomize_spawn() and not spawn_point_selected:
if not LobbyManager.get_randomize_spawn() and LobbyManager.game_mode != "Stop n Go" and not spawn_point_selected:
current_position = find_valid_starting_position()
update_player_position(current_position)
# Ensure proper initial positioning
if not LobbyManager.get_randomize_spawn() and not spawn_point_selected:
if not LobbyManager.get_randomize_spawn() and LobbyManager.game_mode != "Stop n Go" and not spawn_point_selected:
global_position = Vector3(
current_position.x * 1 + 1 * 0.5,
1.0,
@@ -1888,11 +1888,7 @@ func set_spawn_position(pos: Vector2i):
# Clear any spawn highlights
clear_spawn_highlights()
# Update visual position
var new_pos = Vector3(
current_position.x * cell_size.x + cell_size.x * 0.5,
cell_size.y,
current_position.y * cell_size.z + cell_size.z * 0.5
) + cell_offset
var new_pos = grid_to_world(pos)
print("[Player %s] set_spawn_position: Grid %s -> World %s (CellSize: %s)" % [name, pos, new_pos, cell_size])
@@ -2068,7 +2064,10 @@ func update_active_player_indicator():
color = Color.YELLOW
# Apply visual tint to character model across network
rpc("sync_modulate", color)
if can_rpc():
rpc("sync_modulate", color)
else:
sync_modulate(color) # Apply locally if offline/not ready
func knock_tekton():
# ... legacy or helper function ...