feat: add tutorial section
This commit is contained in:
@@ -123,14 +123,18 @@ func grab_item(grid_position: Vector2i) -> bool:
|
||||
if multiplayer.is_server():
|
||||
# HOST/SERVER: Broadcast to all clients
|
||||
main.rpc("sync_grid_item", cell.x, cell.y, cell.z, -1)
|
||||
# Use main's RPC which properly looks up player by ID on each client
|
||||
var peer_id = player.name.to_int()
|
||||
main.rpc("sync_playerboard", peer_id, player.playerboard)
|
||||
player.has_performed_action = true
|
||||
player.consume_action_points(1)
|
||||
player.rpc("force_action_state_none")
|
||||
else:
|
||||
# CLIENT: Send RPC request to server for validation
|
||||
# CLIENT: Optimistic Local Update for lag compensation
|
||||
player.has_performed_action = true
|
||||
player.consume_action_points(1)
|
||||
player.force_action_state_none()
|
||||
|
||||
# Send RPC request to server for validation
|
||||
player.rpc_id(1, "request_server_grab", grid_position, cell.x, cell.y, cell.z, item)
|
||||
|
||||
return true # Action applied locally
|
||||
@@ -277,6 +281,10 @@ func _force_sync_to_client(cell: Vector3i, server_item: int):
|
||||
# Sync their Playerboard (which they thought they updated)
|
||||
main.rpc_id(peer_id, "sync_playerboard", peer_id, player.playerboard)
|
||||
|
||||
# Restore Action Points locally for the client (sync action points back)
|
||||
# player is the caller peer since this is the server instance of the player's manager
|
||||
player.rpc_id(peer_id, "sync_action_points", player.action_points)
|
||||
|
||||
print("Server: Forced sync to client %d due to action failure." % peer_id)
|
||||
|
||||
func bot_try_grab_item() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user