update feature & bugfix
This commit is contained in:
@@ -42,10 +42,7 @@ func rotate_towards_target(target_pos: Vector2i):
|
||||
|
||||
func simple_move_to(grid_position: Vector2i) -> bool:
|
||||
if is_moving:
|
||||
# Calculate direction for buffering
|
||||
var direction = grid_position - player.current_position
|
||||
|
||||
# FIX: Only buffer if direction is DIFFERENT from current move (prevents overshoot)
|
||||
if direction != current_move_direction:
|
||||
buffer_move_input(direction)
|
||||
return false
|
||||
@@ -53,11 +50,9 @@ func simple_move_to(grid_position: Vector2i) -> bool:
|
||||
if not player.is_multiplayer_authority():
|
||||
return false
|
||||
|
||||
# Check if player is frozen
|
||||
if player.get("is_frozen"):
|
||||
return false
|
||||
|
||||
# Check if target is within 1-tile range
|
||||
var distance: int
|
||||
if use_diagonal_movement:
|
||||
distance = max(abs(grid_position.x - player.current_position.x), abs(grid_position.y - player.current_position.y))
|
||||
@@ -67,32 +62,23 @@ func simple_move_to(grid_position: Vector2i) -> bool:
|
||||
if distance != 1:
|
||||
return false # Only single-step moves allowed
|
||||
|
||||
# Check if target position is within grid bounds
|
||||
if not enhanced_gridmap.is_position_valid(grid_position):
|
||||
return false
|
||||
|
||||
# Check for finish line logic (delegated back to player or race manager)
|
||||
if player.has_method("can_move_to_finish") and not player.can_move_to_finish(grid_position):
|
||||
return false
|
||||
|
||||
# Check walkability and obstacles
|
||||
var cell_item = enhanced_gridmap.get_cell_item(Vector3i(grid_position.x, 0, grid_position.y))
|
||||
if cell_item == -1 or cell_item in enhanced_gridmap.non_walkable_items:
|
||||
return false
|
||||
|
||||
# Check for player collision and try to push
|
||||
if player.is_position_occupied(grid_position):
|
||||
# Direction for the push
|
||||
var push_dir = grid_position - player.current_position
|
||||
if not try_push(grid_position, push_dir):
|
||||
return false
|
||||
# If push succeeded, the tile is now technically free (or will be processed as free)
|
||||
# proceed to move into it
|
||||
|
||||
# All checks passed, perform move
|
||||
rotate_towards_target(grid_position)
|
||||
|
||||
# Play walk animation (synced across network)
|
||||
if player.is_multiplayer_authority() and player.has_method("sync_walk_animation"):
|
||||
player.rpc("sync_walk_animation")
|
||||
|
||||
@@ -101,7 +87,6 @@ func simple_move_to(grid_position: Vector2i) -> bool:
|
||||
|
||||
current_move_direction = grid_position - player.current_position
|
||||
|
||||
# Use the existing RPC to move
|
||||
player.rpc("start_movement_along_path", path, not (player.is_bot or player.is_in_group("Bots")))
|
||||
|
||||
return true
|
||||
@@ -119,15 +104,21 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
|
||||
|
||||
# Check if pushed destination is valid
|
||||
if not enhanced_gridmap.is_position_valid(pushed_to_pos):
|
||||
# Blocked by world bounds -> Double Push!
|
||||
other_player.rpc("apply_stagger", 1.5)
|
||||
return false
|
||||
|
||||
# Check walkability of pushed destination
|
||||
var cell_item = enhanced_gridmap.get_cell_item(Vector3i(pushed_to_pos.x, 0, pushed_to_pos.y))
|
||||
if cell_item == -1 or cell_item in enhanced_gridmap.non_walkable_items:
|
||||
# Blocked by obstacle -> Double Push!
|
||||
other_player.rpc("apply_stagger", 1.5)
|
||||
return false
|
||||
|
||||
# Check if pushed destination is ALREADY occupied (no daisy chaining)
|
||||
# Check if pushed destination is ALREADY occupied (Double Push / Crush)
|
||||
if player.is_position_occupied(pushed_to_pos):
|
||||
# Blocked by another player -> Double Push!
|
||||
other_player.rpc("apply_stagger", 1.5)
|
||||
return false
|
||||
|
||||
# Check if other player is currently moving (don't push moving players to avoid sync issues)
|
||||
|
||||
Reference in New Issue
Block a user