feat: Implement the main game scene with core logic, UI, and network integration.

This commit is contained in:
Yogi Wiguna
2026-02-12 15:17:35 +08:00
parent a05e3123b4
commit 8837349896
3 changed files with 691 additions and 11 deletions
+19 -9
View File
@@ -611,20 +611,30 @@ func spawn_tekton_npc():
var enhanced_gridmap = $EnhancedGridMap
if not enhanced_gridmap: return
var valid_pos = Vector2i(-1, -1)
for _i in range(20): # Try 20 times
# Spawn 3 Tektons
var spawned_count = 0
var attempts = 0
while spawned_count < 3 and attempts < 50:
attempts += 1
# Find random valid position
var valid_pos = Vector2i(-1, -1)
var x = randi() % enhanced_gridmap.columns
var y = randi() % enhanced_gridmap.rows
var cell = Vector3i(x, 0, y)
# Check if walkable and no existing Tekton nearby?
if enhanced_gridmap.get_cell_item(cell) == 0: # Walkable floor
valid_pos = Vector2i(x, y)
break
if valid_pos != Vector2i(-1, -1):
# Generate a consistent ID/Name for sync
var tekton_id = Time.get_ticks_msec()
_create_tekton(valid_pos, tekton_id)
rpc("sync_spawn_tekton", valid_pos, tekton_id)
# Generate a consistent ID/Name for sync (add index to ensure uniqueness)
var tekton_id = Time.get_ticks_msec() + spawned_count
_create_tekton(valid_pos, tekton_id)
rpc("sync_spawn_tekton", valid_pos, tekton_id)
spawned_count += 1
print("[Main] Spawned Tekton %d at %s" % [spawned_count, valid_pos])
@rpc("call_remote", "reliable")
func sync_spawn_tekton(pos: Vector2i, tekton_id: int):
+2 -2
View File
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://dyovwailce5tf" path="res://scripts/tekton.gd" id="1_tekton"]
[ext_resource type="Script" uid="uid://c67yq846u8y68" path="res://scripts/tekton_controller.gd" id="2_controller"]
[ext_resource type="PackedScene" uid="uid://bye8rbeqmxy1m" path="res://assets/models/meshes/tekton/tekton_walking.glb" id="3_mesh"]
[ext_resource type="PackedScene" uid="uid://bdaghaxkmi3w1" path="res://scenes/tekton_mesh.tscn" id="3_d2kpk"]
[sub_resource type="BoxShape3D" id="BoxShape3D_tekton"]
size = Vector3(0.8, 1, 0.8)
@@ -15,7 +15,7 @@ script = ExtResource("2_controller")
[node name="Visuals" type="Node3D" parent="." unique_id=1698719440]
[node name="tekton_walking" parent="Visuals" unique_id=1701195793 instance=ExtResource("3_mesh")]
[node name="tekton" parent="Visuals" unique_id=2052742928 instance=ExtResource("3_d2kpk")]
transform = Transform3D(0.15, 0, 0, 0, 0.15, 0, 0, 0, 0.15, 0, 0, 0)
[node name="HitArea" type="Area3D" parent="." unique_id=2139590311]
File diff suppressed because one or more lines are too long