feat: implement 3D arena support and dynamic environment management in main scene
This commit is contained in:
+26
-8
@@ -42,6 +42,9 @@ func _ready():
|
||||
# Connect to Nakama signals
|
||||
NakamaManager.match_joined.connect(_on_match_joined)
|
||||
|
||||
# Setup visual elevations for effects
|
||||
_setup_effect_elevation()
|
||||
|
||||
# Setup UI
|
||||
ui_manager.setup_playerboard_ui()
|
||||
ui_manager.setup_timer_labels(self )
|
||||
@@ -152,18 +155,33 @@ func _instantiate_3d_arena(scene_path: String):
|
||||
print("Instantiated 3D Arena: ", scene_path)
|
||||
|
||||
func _hide_ground_tiles():
|
||||
# Make normal, non-walkable, and Tekton floors invisible
|
||||
# by shrinking their scale to 0. This hides them visually while
|
||||
# avoiding "Parameter 'mesh' is null" or material override errors.
|
||||
# Make normal and auxiliary ground floors invisible
|
||||
# by shrinking their scale to 0. We EXCLUDE Item 4 (Wall) and 5 (Freeze)
|
||||
# so they can still be seen above the 3D arena.
|
||||
var em = $EnhancedGridMap
|
||||
if em and em.mesh_library:
|
||||
var ml = em.mesh_library.duplicate()
|
||||
for id in [0, 4, 6]:
|
||||
for id in [0, 6]:
|
||||
# Scale to 0 to hide it without triggering invalid mesh errors
|
||||
ml.set_item_mesh_transform(id, Transform3D().scaled(Vector3.ZERO))
|
||||
|
||||
em.mesh_library = ml
|
||||
print("[Main] Hide tiles 0, 4, 6 via zero-scale transform.")
|
||||
print("[Main] Hide tiles 0, 6 via zero-scale transform.")
|
||||
|
||||
func _setup_effect_elevation():
|
||||
var em = get_node_or_null("EnhancedGridMap")
|
||||
if em and em.mesh_library:
|
||||
var ml = em.mesh_library.duplicate()
|
||||
|
||||
# Height 0.8: Above 3D arena, but below pickups (Y=1.0)
|
||||
var lift_transform = Transform3D().translated(Vector3(0, 0.28, 0))
|
||||
|
||||
# Lift Wall (4) and Freeze (5)
|
||||
ml.set_item_mesh_transform(4, lift_transform)
|
||||
ml.set_item_mesh_transform(5, lift_transform)
|
||||
|
||||
em.mesh_library = ml
|
||||
print("[Main] MeshLibrary elevation applied: Wall(4) and Freeze(5) at Y=0.8")
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_portal_configs(configs: Array):
|
||||
@@ -1191,8 +1209,8 @@ func spawn_static_tektons():
|
||||
# ID: 99000 + i (Consistent IDs for Static Tektons)
|
||||
var id = 99000 + i
|
||||
|
||||
# Pick Shape on Server (0:Cyl, 1:Box, 2:Prism, 3:Sphere)
|
||||
var shape_idx = randi() % 4
|
||||
# Pick Shape on Server (0: Seat 1, 1: Seat 2)
|
||||
var shape_idx = randi() % 2
|
||||
|
||||
# Spawn on Server AND Sync to Clients (call_local handles both)
|
||||
rpc("sync_spawn_static_setup", pos, id, shape_idx)
|
||||
@@ -1234,7 +1252,7 @@ func _create_static_setup(pos: Vector2i, tekton_id: int, shape_idx: int):
|
||||
if "cell_size" in enhanced_gridmap:
|
||||
world_pos = Vector3(
|
||||
pos.x * enhanced_gridmap.cell_size.x + enhanced_gridmap.cell_size.x / 2,
|
||||
0,
|
||||
0.28, # Match the 0.28 elevation of the arena floor
|
||||
pos.y * enhanced_gridmap.cell_size.z + enhanced_gridmap.cell_size.z / 2
|
||||
)
|
||||
stand.global_position = world_pos
|
||||
|
||||
Reference in New Issue
Block a user