feat: Implement the main game scene with core logic, UI, and network integration.
This commit is contained in:
+19
-9
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user