feat: Add a multiplayer-synchronized portal door with visual elements, player detection, and dynamic color.
This commit is contained in:
+37
-5
@@ -28,6 +28,9 @@ func _ready():
|
||||
|
||||
# Visual feedback: indicate door is active
|
||||
_update_visuals()
|
||||
|
||||
# Adjust GroundIndicator position based on spawn_offset metadata
|
||||
_adjust_indicator_position()
|
||||
|
||||
func _on_body_entered(body: Node3D):
|
||||
if not is_active: return
|
||||
@@ -76,6 +79,15 @@ func _update_visuals():
|
||||
var mat = frame.get_surface_override_material(0)
|
||||
if mat:
|
||||
mat.albedo_color = portal_color.lerp(Color.BLACK, 0.4)
|
||||
|
||||
var ground = get_node_or_null("GroundIndicator")
|
||||
if ground:
|
||||
var mat = ground.get_surface_override_material(0)
|
||||
if mat:
|
||||
mat.albedo_color = portal_color
|
||||
mat.albedo_color.a = 0.4
|
||||
mat.emission = portal_color
|
||||
mat.emission_energy_multiplier = 2.0
|
||||
|
||||
func _initialize_unique_materials():
|
||||
var vortex = get_node_or_null("Vortex")
|
||||
@@ -96,9 +108,29 @@ func _initialize_unique_materials():
|
||||
|
||||
if mat:
|
||||
frame.set_surface_override_material(0, mat.duplicate())
|
||||
|
||||
var ground = get_node_or_null("GroundIndicator")
|
||||
if ground:
|
||||
var mat = ground.get_surface_override_material(0)
|
||||
if not mat:
|
||||
mat = ground.mesh.surface_get_material(0)
|
||||
if mat:
|
||||
ground.set_surface_override_material(0, mat.duplicate())
|
||||
|
||||
func get_teleport_target_position() -> Vector2i:
|
||||
# This function will be called by the manager to determine WHERE the player spawns
|
||||
# usually just outside the target door's position.
|
||||
# For now, let's just return a placeholder that the manager will override.
|
||||
return Vector2i.ZERO
|
||||
func _adjust_indicator_position():
|
||||
# This uses the spawn_offset metadata set by PortalModeManager
|
||||
# to push the ground indicator "into" the room.
|
||||
if not has_meta("spawn_offset"): return
|
||||
|
||||
var ground = get_node_or_null("GroundIndicator")
|
||||
if not ground: return
|
||||
|
||||
var offset_2d = get_meta("spawn_offset") # Vector2i
|
||||
var offset_3d = Vector3(offset_2d.x, 0, offset_2d.y)
|
||||
|
||||
# Convert the global direction (into the room) to local coordinates
|
||||
var local_dir = to_local(global_position + offset_3d).normalized()
|
||||
|
||||
# Nudge the indicator in that direction
|
||||
ground.position = local_dir * 0.5 # Reduced from 0.6 to close the gap
|
||||
ground.position.y = 0.05 # Keep it just above the floor
|
||||
|
||||
Reference in New Issue
Block a user