update holiday
This commit is contained in:
+54
-6
@@ -12,6 +12,9 @@ var powerup_manager
|
||||
# Score tracking
|
||||
var score: int = 0
|
||||
|
||||
# Display name (synced across network)
|
||||
var display_name: String = ""
|
||||
|
||||
# Special effect states
|
||||
var is_frozen: bool = false
|
||||
var is_invisible: bool = false
|
||||
@@ -115,9 +118,22 @@ const AVAILABLE_CHARACTERS: Array[String] = ["Bob", "Masbro", "Gatot", "Oldpop"]
|
||||
# Delegated to RaceManager
|
||||
|
||||
func _ready():
|
||||
# Ensure name is set first
|
||||
# Ensure name is set first (node name = authority ID for multiplayer identification)
|
||||
name = str(get_multiplayer_authority())
|
||||
$Name.text = str(name)
|
||||
|
||||
# Look up player's display name from LobbyManager
|
||||
var my_id = get_multiplayer_authority()
|
||||
for player_data in LobbyManager.get_players():
|
||||
if player_data.get("id") == my_id:
|
||||
display_name = player_data.get("name", "Player")
|
||||
break
|
||||
if display_name.is_empty():
|
||||
display_name = "Player %d" % my_id
|
||||
$Name.text = display_name
|
||||
|
||||
# Sync name to other peers if this is our local player
|
||||
if is_multiplayer_authority():
|
||||
rpc("sync_display_name", display_name)
|
||||
|
||||
# Wait briefly to ensure proper scene setup
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
@@ -354,6 +370,30 @@ func play_idle_animation() -> void:
|
||||
if anim_player and anim_player.has_animation("animation-pack/idle"):
|
||||
anim_player.play("animation-pack/idle")
|
||||
|
||||
# =============================================================================
|
||||
# Network-Synced Animation Functions
|
||||
# =============================================================================
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_walk_animation() -> void:
|
||||
"""Sync walk animation across network."""
|
||||
play_walk_animation()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_pickup_animation() -> void:
|
||||
"""Sync pickup/grab animation across network."""
|
||||
play_pickup_animation()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_put_animation() -> void:
|
||||
"""Sync put/drop animation across network."""
|
||||
play_put_animation()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_special_animation() -> void:
|
||||
"""Sync special ability animation across network."""
|
||||
play_special_animation()
|
||||
|
||||
# =============================================================================
|
||||
# Screen Shake
|
||||
# =============================================================================
|
||||
@@ -486,10 +526,16 @@ func sync_bot_status(is_bot_status: bool):
|
||||
behavior_tree.set_physics_process(false)
|
||||
behavior_tree.set_process(false)
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_display_name(new_name: String) -> void:
|
||||
"""Sync display name across network."""
|
||||
display_name = new_name
|
||||
$Name.text = display_name
|
||||
|
||||
func _process(delta):
|
||||
if is_multiplayer_authority():
|
||||
# Visual debugging - show connection status in name label
|
||||
$Name.text = str(name) + "\n(Auth: " + str(get_multiplayer_authority()) + ")"
|
||||
# Visual debugging - show display name with connection status
|
||||
$Name.text = display_name if not display_name.is_empty() else str(name)
|
||||
|
||||
# Periodically verify our existence to others
|
||||
_verify_timer += delta
|
||||
@@ -819,8 +865,8 @@ func display_message(message, type: int = 0):
|
||||
# Send message to the main scene's message bar instead of player bubble
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
if main and main.has_method("add_message_to_bar"):
|
||||
var player_name = $Name.text.split("\n")[0] if $Name else str(name)
|
||||
main.add_message_to_bar(player_name, message, type)
|
||||
var player_name_str = display_name if not display_name.is_empty() else str(name)
|
||||
main.add_message_to_bar(player_name_str, message, type)
|
||||
|
||||
func initialize_random_goals(_size: int, min_value: int, max_value: int, null_count: float) -> Array[int]:
|
||||
goals.clear()
|
||||
@@ -1171,6 +1217,8 @@ func _highlight_adjacent_playerboard_slots():
|
||||
func sync_rotation(new_rotation: float):
|
||||
if not is_multiplayer_authority():
|
||||
rotation.y = new_rotation
|
||||
if movement_manager:
|
||||
movement_manager.target_rotation = new_rotation
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_grid_item(x: int, y: int, z: int, item: int):
|
||||
|
||||
Reference in New Issue
Block a user