implement auto tile pickup and visual candy stacking on player head

This commit is contained in:
god
2026-07-06 02:31:17 +08:00
parent b3a421bb55
commit 717e8cedae
3 changed files with 63 additions and 4 deletions
+39
View File
@@ -601,6 +601,45 @@ func _get_all_mesh_instances(node: Node) -> Array:
result.append_array(_get_all_mesh_instances(child))
return result
# -----------------------------------------------------------------
# RPCs
# -----------------------------------------------------------------
@rpc("any_peer", "call_local", "reliable")
func sync_candy_stack(count: int, color_id: int) -> void:
var visuals = get_node_or_null("Visuals")
if not visuals: return
var old_stack = visuals.get_node_or_null("CandyStack")
if old_stack:
old_stack.queue_free()
if count <= 0: return
var stack_node = Node3D.new()
stack_node.name = "CandyStack"
visuals.add_child(stack_node)
stack_node.position = Vector3(0, 2.0, 0)
# Determine base tile and override material based on the mode config or default tile meshes
var mesh_path = "res://assets/models/tiles/tile_heart.tres"
match color_id:
0: mesh_path = "res://assets/models/tiles/tile_heart.tres"
1: mesh_path = "res://assets/models/tiles/tile_diamond.tres"
2: mesh_path = "res://assets/models/tiles/tile_star.tres"
3: mesh_path = "res://assets/models/tiles/tile_coin.tres"
var tile_mesh = load(mesh_path)
if not tile_mesh: return
for i in range(count):
var mi = MeshInstance3D.new()
mi.mesh = tile_mesh
mi.position = Vector3(0, i * 0.4, 0)
mi.scale = Vector3(0.5, 0.5, 0.5)
stack_node.add_child(mi)
@rpc("any_peer", "call_local", "reliable")
func sync_character(character_name: String) -> void:
"""Sync character selection across all clients."""