feat: fix some bug

This commit is contained in:
2026-04-24 22:56:11 +08:00
parent 8c5004d535
commit b76dd2e737
9 changed files with 105 additions and 156 deletions
+5 -9
View File
@@ -123,7 +123,7 @@ var _is_processing_action: bool = false
var selected_gridmap_position = Vector2i(-1, -1)
var selected_playerboard_slot = -1
var targeted_playerboard_slot = -1
var action_points: int = 2
#var has_performed_action: bool = false
# Modifier for player models
var rotation_speed: float = 10.0
@@ -1784,7 +1784,6 @@ func grid_to_world(grid_position: Vector2i) -> Vector3:
return world_position
func start_turn():
action_points = 2
has_moved_this_turn = false
has_performed_action = false
is_my_turn = true
@@ -1996,7 +1995,7 @@ func _execute_grab(grid_pos: Vector2i, cell: Vector3i, item_id: int):
# This function runs on the server when requested by a client
# -----------------------------------------------------------------
@rpc("any_peer", "reliable")
func request_server_grab(grid_pos: Vector2i, x: int, y: int, z: int, item_id: int):
func request_server_grab(grid_pos: Vector2i, x: int, y: int, z: int, item_id: int, expected_slot: int = -1):
# 1. Only the server (peer 1) should process this
if not multiplayer.is_server():
return
@@ -2006,8 +2005,9 @@ func request_server_grab(grid_pos: Vector2i, x: int, y: int, z: int, item_id: in
push_error("Security: Non-authority tried to grab item!")
return
# 3. Call the execution logic
playerboard_manager._execute_grab(grid_pos, Vector3i(x, y, z), item_id)
# 3. Call the execution logic (pass expected_slot for deterministic placement)
playerboard_manager._execute_grab(grid_pos, Vector3i(x, y, z), item_id, expected_slot)
# -----------------------------------------------------------------
# Auto-put: no manual selection needed
@@ -2074,7 +2074,6 @@ func request_server_put(grid_position: Vector2i, slot_index: int, x: int, y: int
# Update player state
has_performed_action = true
action_points -= 1
selected_playerboard_slot = -1
# Notify about action completion
@@ -2161,9 +2160,6 @@ func highlight_adjacent_cells():
func highlight_empty_adjacent_cells():
action_manager.highlight_empty_adjacent_cells()
@rpc("any_peer", "call_local")
func sync_action_points(points: int):
action_manager.sync_action_points(points)
func highlight_random_valid_cells():
action_manager.highlight_random_valid_cells()