From 82f2811c2608f5fd708b90fbf390f9d24145d7ca Mon Sep 17 00:00:00 2001 From: Yogi Wiguna Date: Tue, 31 Mar 2026 12:24:26 +0800 Subject: [PATCH] feat: implement main game scene and player logic with modular manager architecture --- project.godot | 1 - scenes/main.gd | 9 ++++++++- scenes/player.gd | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/project.godot b/project.godot index 38e80c7..4a1acee 100644 --- a/project.godot +++ b/project.godot @@ -62,7 +62,6 @@ grab_item={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) ] } - move_north={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) diff --git a/scenes/main.gd b/scenes/main.gd index 51ecd06..2487368 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -832,6 +832,12 @@ func _assign_random_spawn_positions(): var mid_x = enhanced_gridmap.columns / 2 var mid_z = enhanced_gridmap.rows / 2 + # If static positions were not calculated yet, do it now to avoid players spawning in them + if reserved_static_positions.is_empty() and LobbyManager.game_mode != "Stop n Go": + if not static_tekton_manager: + static_tekton_manager = preload("res://scripts/managers/static_tekton_manager.gd").new() + reserved_static_positions = static_tekton_manager.calculate_spawn_points(3, enhanced_gridmap) + for x in range(enhanced_gridmap.columns): for z in range(enhanced_gridmap.rows): var ground = enhanced_gridmap.get_cell_item(Vector3i(x, 0, z)) @@ -839,7 +845,8 @@ func _assign_random_spawn_positions(): var pos = Vector2i(x, z) # SAFETY CHECK: Is this reserved for a Static Tekton Stand? - # Stand clears 3x3, but we use a radius of 2 (5x5) for safety + # Stand clears 3x3, we use a strictly >= 1 check (so abs <= 1 is EXACTLY the 3x3 stand) + # Let's use a 3x3 check (1 radius) to avoid strictly the stand itself, plus 1 buffer = radius 2. var is_safe = true for reserved in reserved_static_positions: if abs(x - reserved.x) <= 2 and abs(z - reserved.y) <= 2: diff --git a/scenes/player.gd b/scenes/player.gd index 7edcf64..1079c9c 100644 --- a/scenes/player.gd +++ b/scenes/player.gd @@ -1317,18 +1317,18 @@ func is_position_occupied(pos: Vector2i) -> bool: if p.is_player_moving and p.target_position == pos: return true - # Prevent overlap with Static Tekton Stands (3x3 area) using active nodes + # Prevent overlap with Static Tekton Stands (3x3 area, with 1-tile buffer = 5x5 checked) if enhanced_gridmap: for stand in get_tree().get_nodes_in_group("StaticTektonStands"): var local_pos = enhanced_gridmap.to_local(stand.global_position) var stand_map_pos = enhanced_gridmap.local_to_map(local_pos) - if abs(pos.x - stand_map_pos.x) <= 1 and abs(pos.y - stand_map_pos.z) <= 1: + if abs(pos.x - stand_map_pos.x) <= 2 and abs(pos.y - stand_map_pos.z) <= 2: return true var main_node = get_tree().get_root().get_node_or_null("Main") if main_node and "reserved_static_positions" in main_node: for reserved in main_node.reserved_static_positions: - if abs(pos.x - reserved.x) <= 1 and abs(pos.y - reserved.y) <= 1: + if abs(pos.x - reserved.x) <= 2 and abs(pos.y - reserved.y) <= 2: return true return false