This commit is contained in:
2026-01-28 02:29:43 +08:00
parent d71f5d67e3
commit 6949e20a1f
13 changed files with 285 additions and 100 deletions
+8 -12
View File
@@ -170,22 +170,18 @@ func _check_and_refill_grid_if_needed(server_gridmap: Node):
var has_items = false
var item_list = server_gridmap.mesh_library.get_item_list() if server_gridmap.mesh_library else []
# We can't efficiently iterate all cells, but we can check usage via get_used_cells_by_item is too specific
# Iterating columns/rows is safe for this map size (10x10 usually)
for x in range(server_gridmap.columns):
for z in range(server_gridmap.rows):
var item = server_gridmap.get_cell_item(Vector3i(x, 1, z))
if item != -1:
has_items = true
break
if has_items:
# Iterate used cells to check for ANY item on floor 1
var used_cells = server_gridmap.get_used_cells()
for cell in used_cells:
if cell.y == 1: # Floor 1
has_items = true
break
if not has_items:
print("[PlayerboardManager] Floor 1 empty! Respawning tiles with Scarcity...")
# Call randomize_floor on floor 1
# Since Main owns gridmap, we can sync this or just do it server side (which we are)
server_gridmap.randomize_floor(1)
# Call randomize_floor on floor 1 using ScarcityController
# ScarcityController is a global class, so we can pass its static function as a Callable
server_gridmap.randomize_floor(1, ScarcityController.get_random_tile_id)
# We need to sync the ENTIRE floor to clients.
# EnhancedGridMap doesn't have a "Sync Floor" RPC built-in to Main, only single cells or array update.