feat: Introduce an EnhancedGridMap with advanced grid generation, randomization, and data serialization features, along with a default MeshLibrary and a new main scene script.

This commit is contained in:
Yogi Wiguna
2026-02-03 12:20:02 +08:00
parent e8fc3f86c5
commit 16a46d7e76
3 changed files with 64 additions and 3 deletions
+30
View File
@@ -463,6 +463,10 @@ 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")
func _auto_start_from_lobby():
"""Called when main.tscn is loaded from lobby - game is already connected."""
@@ -1032,6 +1036,32 @@ func randomize_game_grid():
# For now, let's assume server authority + sync on connect handles it, or add sync loop if critical.
pass
@rpc("any_peer")
func request_full_grid_sync():
if multiplayer.is_server():
var sender_id = multiplayer.get_remote_sender_id()
print("[Main] Grid sync requested by %d" % sender_id)
var enhanced_gridmap = $EnhancedGridMap
if enhanced_gridmap:
var grid_data = enhanced_gridmap.get_floor_data(1) # Sync Floor 1 (Items)
print("[Main] Server: Prepared grid data. Size: %d. Sending to %d..." % [grid_data.size(), sender_id])
# Force send (Server is usually always connected)
rpc_id(sender_id, "sync_full_grid_data", grid_data)
print("[Main] Server: Sent rpc_id to %d" % sender_id)
@rpc("authority", "call_local", "reliable")
func sync_full_grid_data(data: PackedInt32Array):
print("[Main] sync_full_grid_data received. Items: %d" % (data.size() / 3))
var enhanced_gridmap = $EnhancedGridMap
if not enhanced_gridmap:
print("[Main] Error: EnhancedGridMap not found!")
return
# Apply the synced data to Floor 1
enhanced_gridmap.set_floor_data(1, data)
print("[Main] Grid sync complete.")
# =============================================================================
# Goals Cycle & Leaderboard UI