extends Node3D class_name CandySurvivalNPCController @onready var mekton_mesh = $MektonMesh var face_material: StandardMaterial3D func _ready() -> void: # Setup unique material for the body to change colors if mekton_mesh: var skeleton = mekton_mesh.get_node_or_null("Throwing Tiles/Skeleton3D") if skeleton: var body = skeleton.get_node_or_null("ted_body") if body and body is MeshInstance3D: var mat = body.get_surface_override_material(0) if not mat: if body.mesh: mat = body.mesh.surface_get_material(0) if mat: face_material = mat.duplicate() else: face_material = StandardMaterial3D.new() face_material.emission_enabled = true face_material.emission_energy_multiplier = 2.0 body.set_surface_override_material(0, face_material) @rpc("authority", "call_local", "reliable") func set_face_color_rpc(color_index: int) -> void: if not face_material: return # enum CandyColor { HEART=0, DIAMOND=1, STAR=2, COIN=3 } var c = Color.WHITE match color_index: 0: c = Color(1.0, 0.2, 0.2) # HEART (Red) 1: c = Color(0.2, 0.4, 1.0) # DIAMOND (Blue) 2: c = Color(1.0, 0.9, 0.2) # STAR (Yellow) 3: c = Color(1.0, 0.6, 0.0) # COIN (Orange/Gold) face_material.albedo_color = c face_material.emission = c # Also tint the OmniLight if we have one var light = $OmniLight3D if light: light.light_color = c @rpc("authority", "call_local", "reliable") func play_animation_rpc(anim_name: String) -> void: if mekton_mesh: var anim = mekton_mesh.get_node_or_null("AnimationPlayer") if anim and anim.has_animation(anim_name): anim.play(anim_name) func can_rpc() -> bool: if not multiplayer.has_multiplayer_peer(): return false return multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED