feat: fix the spawn tiles

This commit is contained in:
2026-06-26 13:56:59 +08:00
parent 00f9d98f4b
commit 798189d81b
+1 -48
View File
@@ -1824,9 +1824,6 @@ func _on_goal_count_updated(peer_id: int, count: int) -> void:
emit_signal("cleanser_granted", peer_id) emit_signal("cleanser_granted", peer_id)
print("[Gauntlet] Player %d granted Cleanser (mission %d)" % [peer_id, completions]) print("[Gauntlet] Player %d granted Cleanser (mission %d)" % [peer_id, completions])
# Respawn mission tiles in non-sticky locations
_respawn_mission_tiles()
# Sync cleanser count to HUD # Sync cleanser count to HUD
rpc("sync_cleanser_count", peer_id, player_cleansers.get(peer_id, 0)) rpc("sync_cleanser_count", peer_id, player_cleansers.get(peer_id, 0))
@@ -1834,51 +1831,7 @@ func _on_score_updated(peer_id: int, new_score: int) -> void:
"""Called when a player's score is updated.""" """Called when a player's score is updated."""
pass # Score sync handled by GoalsCycleManager pass # Score sync handled by GoalsCycleManager
func _respawn_mission_tiles() -> void:
"""Respawn mission tiles in non-sticky locations after mission completion."""
if not gridmap:
gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
# Goal items: Heart(7), Diamond(8), Star(9), Coin(10)
var goal_items = [7, 8, 9, 10]
var tiles_spawned: int = 0
# Find empty non-sticky cells to place new tiles
var empty_cells: Array = []
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos = Vector2i(x, z)
if _is_npc_zone(pos):
continue
# Skip boundary walls
if x == 0 or x == ARENA_COLUMNS - 1 or z == 0 or z == ARENA_ROWS - 1:
continue
# Skip sticky cells
if sticky_cells.has(pos):
continue
# Check if cell is empty on Layer 1
var current_item = gridmap.get_cell_item(Vector3i(x, 1, z))
if current_item == -1:
empty_cells.append(pos)
# Shuffle and place tiles
empty_cells.shuffle()
var tiles_to_place = min(empty_cells.size(), 6) # Light refill — avoid flooding the board while players collect
for i in range(tiles_to_place):
var pos = empty_cells[i]
var tile_type = goal_items[randi() % goal_items.size()]
gridmap.set_cell_item(Vector3i(pos.x, 1, pos.y), tile_type)
tiles_spawned += 1
# Sync to clients
if main_scene:
main_scene.rpc("sync_grid_item", pos.x, 1, pos.y, tile_type)
print("[Gauntlet] Respawned %d mission tiles" % tiles_spawned)
@rpc("authority", "call_local", "reliable") @rpc("authority", "call_local", "reliable")
func sync_cleanser_count(peer_id: int, count: int) -> void: func sync_cleanser_count(peer_id: int, count: int) -> void: