feat: Implement Tekton roaming NPC with movement, combat, carry, throw, and knock mechanics.

This commit is contained in:
Yogi Wiguna
2026-02-19 17:29:14 +08:00
parent a7a8106b7e
commit e90cbfe246
11 changed files with 235 additions and 84 deletions
+27 -5
View File
@@ -486,11 +486,20 @@ func _setup_client_game():
# Wait shorter time for host to be ready, then request full sync to correct positions/state
await get_tree().create_timer(1.0).timeout
rpc_id(1, "request_full_player_sync", my_id)
# Only request grid if we remain connected
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
rpc_id(1, "request_full_grid_sync")
# Ensure we see the server (Peer 1)
if 1 in multiplayer.get_peers():
rpc_id(1, "request_full_player_sync", my_id)
rpc_id(1, "request_full_grid_sync")
else:
print("Client: Connected but Peer 1 not found yet. Retrying in 1s...")
await get_tree().create_timer(1.0).timeout
if 1 in multiplayer.get_peers():
rpc_id(1, "request_full_player_sync", my_id)
rpc_id(1, "request_full_grid_sync")
func _auto_start_from_lobby():
"""Called when main.tscn is loaded from lobby - game is already connected."""
@@ -516,6 +525,9 @@ func _auto_start_from_lobby():
func _start_game():
if multiplayer.is_server():
# Allow socket/peer to stabilize before blasting RPCs
await get_tree().create_timer(2.0).timeout
GameStateManager.start_game()
rpc("sync_game_start", GameStateManager.players, TurnManager.turn_based_mode)
if TurnManager.turn_based_mode:
@@ -525,6 +537,7 @@ func _start_game():
# Start the global match timer (this also starts the first cycle)
if LobbyManager.game_mode == "Stop n Go":
# Only Server starts the mode logic (arena setup, missions, etc)
if stop_n_go_manager:
stop_n_go_manager.start_game_mode()
elif goals_cycle_manager:
@@ -693,7 +706,10 @@ func spawn_tekton_npc():
# 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)
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
if multiplayer.get_peers().size() > 0:
rpc("sync_spawn_tekton", valid_pos, tekton_id)
spawned_count += 1
print("[Main] Spawned Tekton %d at %s" % [spawned_count, valid_pos])
@@ -752,6 +768,11 @@ func _precalculate_static_positions():
func spawn_static_tektons():
"""Spawn fixed static tektons using StaticTektonManager."""
if not multiplayer.is_server(): return
# Disable for Stop n Go mode
if LobbyManager.game_mode == "Stop n Go":
return
var enhanced_gridmap = $EnhancedGridMap
if not enhanced_gridmap: return
@@ -1679,7 +1700,8 @@ func _deferred_init_leaderboard():
# Request leaderboard sync from server for accurate data
if not multiplayer.is_server():
rpc_id(1, "request_leaderboard_sync")
if 1 in multiplayer.get_peers():
rpc_id(1, "request_leaderboard_sync")
else:
# Server can update directly
_update_leaderboard_display()