update holiday

This commit is contained in:
2026-01-01 05:21:25 +08:00
parent c5e9d073fa
commit 7423e29443
12 changed files with 273 additions and 37 deletions
+15 -3
View File
@@ -309,13 +309,24 @@ func _on_match_joined(match_id: String) -> void:
# Client will request room info when peer connection is established
@rpc("any_peer", "reliable")
func request_room_info(requester_id: int) -> void:
"""Client requests room info from host."""
func request_room_info(requester_id: int, requester_name: String, requester_character: String) -> void:
"""Client requests room info from host, sending their name and character."""
if not multiplayer.is_server():
return
# Update the player's name and character in the list
for player in players_in_room:
if player["id"] == requester_id:
player["name"] = requester_name
player["character"] = requester_character
break
# Send room data to requester
rpc_id(requester_id, "receive_room_info", current_room, players_in_room)
# Also sync updated player list to all other clients
rpc("sync_player_list", players_in_room)
emit_signal("player_list_changed")
@rpc("reliable")
func receive_room_info(room_data: Dictionary, player_list: Array) -> void:
@@ -346,7 +357,8 @@ func _on_peer_connected(peer_id: int) -> void:
if peer_id == 1 and not is_host:
# Wait a frame to ensure connection is stable
await get_tree().process_frame
rpc_id(1, "request_room_info", multiplayer.get_unique_id())
# Send our actual name and character to the host
rpc_id(1, "request_room_info", multiplayer.get_unique_id(), local_player_name, available_characters[local_character_index])
func _on_peer_disconnected(peer_id: int) -> void:
"""Called when peer disconnects."""
+6 -3
View File
@@ -32,6 +32,9 @@ func rotate_towards_target(target_pos: Vector2i):
var direction = Vector3(target_pos.x - player.current_position.x, 0, target_pos.y - player.current_position.y)
if direction != Vector3.ZERO:
target_rotation = atan2(direction.x, direction.z)
# Sync rotation to other clients
if player.is_multiplayer_authority():
player.rpc("sync_rotation", target_rotation)
func simple_move_to(grid_position: Vector2i) -> bool:
if not player.is_multiplayer_authority() or is_moving:
@@ -70,9 +73,9 @@ func simple_move_to(grid_position: Vector2i) -> bool:
# All checks passed, perform move
rotate_towards_target(grid_position)
# Play walk animation
if player.has_method("play_walk_animation"):
player.play_walk_animation()
# Play walk animation (synced across network)
if player.is_multiplayer_authority() and player.has_method("sync_walk_animation"):
player.rpc("sync_walk_animation")
var path = [Vector2(player.current_position.x, player.current_position.y), Vector2(grid_position.x, grid_position.y)]
path.pop_front()
+6 -6
View File
@@ -54,9 +54,9 @@ func grab_item(grid_position: Vector2i) -> bool:
if not player.is_multiplayer_authority():
return false
# Play pickup animation
if player.has_method("play_pickup_animation"):
player.play_pickup_animation()
# Play pickup animation (synced across network)
if player.is_multiplayer_authority() and player.has_method("sync_pickup_animation"):
player.rpc("sync_pickup_animation")
# === Optimistic Local Update (immediate visual feedback) ===
# Apply changes locally first, server will validate/sync
@@ -316,9 +316,9 @@ func auto_put_item() -> bool:
var cell = Vector3i(target_pos.x, 1, target_pos.y)
if player.is_multiplayer_authority():
# Play put animation
if player.has_method("play_put_animation"):
player.play_put_animation()
# Play put animation (synced across network)
if player.is_multiplayer_authority() and player.has_method("sync_put_animation"):
player.rpc("sync_put_animation")
# === Optimistic Local Update (immediate visual feedback) ===
enhanced_gridmap.set_cell_item(cell, item) # Add item to grid visually immediately
+3 -3
View File
@@ -100,9 +100,9 @@ func use_special_effect():
# Start cooldown
special_cooldown_timer = SPECIAL_COOLDOWN
# Play special animation (backflip)
if player.has_method("play_special_animation"):
player.play_special_animation()
# Play special animation (backflip) - synced across network
if player.is_multiplayer_authority() and player.has_method("sync_special_animation"):
player.rpc("sync_special_animation")
# Trigger random special effect via SpecialTilesManager
var special_tiles_manager = player.get_node_or_null("SpecialTilesManager")
+5 -1
View File
@@ -375,7 +375,11 @@ func initialize_leaderboard_with_players(players: Array):
var score_label = entry.get_node_or_null("ScoreLabel")
if name_label:
name_label.text = str(player.name) if player else "Player " + str(i + 1)
# Use display_name if available, otherwise fallback to node name
var player_display_name = player.display_name if player and player.get("display_name") else ""
if player_display_name.is_empty():
player_display_name = str(player.name) if player else "Player " + str(i + 1)
name_label.text = player_display_name
if score_label:
score_label.text = str(player.score) if player and player.get("score") else "0"
+1 -1
View File
@@ -2,7 +2,7 @@ extends Node
# Standard Nakama Configuration
const NAKAMA_SERVER_KEY = "defaultkey"
const NAKAMA_HOST = "77.237.232.232"
const NAKAMA_HOST = "localhost"
const NAKAMA_PORT = 7350
const NAKAMA_SCHEME = "http"