edit special power up

This commit is contained in:
2026-01-09 22:41:00 +08:00
parent 6aede0a382
commit 6948a4aed1
11 changed files with 326 additions and 468 deletions
+49 -2
View File
@@ -549,6 +549,55 @@ func sync_display_name(new_name: String) -> void:
"""Sync display name across network."""
display_name = new_name
$Name.text = display_name
@rpc("any_peer", "call_local", "reliable")
func sync_modulate(color: Color) -> void:
"""Sync visual modulation (e.g. freeze effect) across network."""
# Node3D doesn't have modulate. We must tint the active character meshes.
var active_char_node = null
match selected_character:
"Bob": active_char_node = character_bob
"Masbro": active_char_node = character_masbro
"Gatot": active_char_node = character_gatot
"Oldpop": active_char_node = character_oldpop
if active_char_node:
_apply_tint_recursive(active_char_node, color)
func _apply_tint_recursive(node: Node, color: Color):
if node is MeshInstance3D:
# Simple way to tint: use material_overlay with an unshaded material if possible,
# or transparency. But changing albedo on shared materials affects all instances!
# Using transparency/modulate equivalent in 3D is tricky without unique materials.
# A common trick is to use `instance_shader_parameter` if supported, or modifying visibility range? No.
# Best safe visual cue for "Help me create an ice effect" without shaders:
# Set `transparency` (alpha) if we want ghost, or `material_overlay`.
# For this quick fix, let's create a standard material overlay on the fly if needed
# or just rely on a debug geometry.
# Actually, geometry_instance_3d has `material_overlay`.
# Better approach for "Freeze": Just add a visible "Ice Block" mesh to the player
# instead of trying to tint the gltf model which might have complex materials.
# But user asked for "modulate". The closest 3D equivalent is material_overlay with a color.
var mat = StandardMaterial3D.new()
mat.albedo_color = color
mat.blend_mode = BaseMaterial3D.BLEND_MODE_MIX
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
# If color is WHITE (reset), clear the overlay
if color == Color.WHITE:
node.material_overlay = null
else:
# If color is Blue (frozen), make it semi-transparent overlay
mat.albedo_color = color
mat.albedo_color.a = 0.5 # Semi-transparent
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
node.material_overlay = mat
for child in node.get_children():
_apply_tint_recursive(child, color)
func _process(delta):
if is_multiplayer_authority():
@@ -1354,8 +1403,6 @@ func set_spawn_position(pos: Vector2i):
current_position.y * cell_size.z + cell_size.z * 0.5
) + cell_offset
func highlight_valid_obstacle_cells():
action_manager.highlight_valid_obstacle_cells()
@rpc("any_peer", "call_local", "reliable")
func complete_race(final_position: int):