feat: Add core game managers, main scene, enhanced gridmap, and essential assets, including a new special tiles manager for power-up effects and inventory.

This commit is contained in:
Yogi Wiguna
2026-03-11 15:29:07 +08:00
parent 4b7a64a119
commit 18c3dbecd6
9 changed files with 97 additions and 15 deletions
+69 -6
View File
@@ -470,10 +470,11 @@ func _spawn_safe_zone():
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
# Collect valid center positions (not too close to edges so the zone fits)
# Collect valid center positions (account for wall footprint: radius + 1)
var spawn_buffer = SAFE_ZONE_RADIUS + 1
var valid_positions: Array[Vector2i] = []
for x in range(SAFE_ZONE_RADIUS, gridmap.columns - SAFE_ZONE_RADIUS):
for z in range(SAFE_ZONE_RADIUS, gridmap.rows - SAFE_ZONE_RADIUS):
for x in range(spawn_buffer, gridmap.columns - spawn_buffer):
for z in range(spawn_buffer, gridmap.rows - spawn_buffer):
var tile = gridmap.get_cell_item(Vector3i(x, 0, z))
# Only walkable tiles (not start/finish)
if tile == TILE_WALKABLE:
@@ -648,16 +649,59 @@ func sync_safe_zone(centers: Array, radius: int):
if not gridmap: return
# Paint safe zones on Floor 0 (Floor layer)
# This ensures items and walls on Floor 1 are visible ON TOP of the safe zone
# Also paint walls (ID 16) around the zone with 1 door on each side
for center in safe_zone_centers:
# 1. Paint the safe floor
for dx in range(-radius, radius + 1):
for dz in range(-radius, radius + 1):
var x = center.x + dx
var z = center.y + dz
if x >= 0 and x < gridmap.columns and z >= 0 and z < gridmap.rows:
# ONLY replace standard walkable floor (don't overwrite Start/Finish/Walls on Layer 0)
if gridmap.get_cell_item(Vector3i(x, 0, z)) == TILE_WALKABLE:
gridmap.set_cell_item(Vector3i(x, 0, z), TILE_SAFE)
# 2. Paint the walls (item ID 16) ON LAYER 1 to block movement
# We scan from -3 to +3 to handle symmetric wall indices around the 5x5 zone
for dx in range(-radius - 1, radius + 2):
for dz in range(-radius - 1, radius + 2):
var x = center.x + dx
var z = center.y + dz
if x >= 0 and x < gridmap.columns and z >= 0 and z < gridmap.rows:
# big room logic: 5x5 span (Indices -2 to 2)
# North/West use -radius/-radius-1, South/East use radius/radius+1
var is_north = dz == -radius - 1 and dx >= -radius and dx <= radius
var is_south = dz == radius and dx >= -radius and dx <= radius
var is_west = dx == -radius and dz >= -radius and dz <= radius
var is_east = dx == radius + 1 and dz >= -radius and dz <= radius
var orientation = 0
var is_wall = false
if is_north:
orientation = 0
is_wall = true
elif is_south:
orientation = 0
is_wall = true
elif is_west:
orientation = 22
is_wall = true
elif is_east:
orientation = 22
is_wall = true
if is_wall:
# Door logic: Skip center (0) on the respective border line
var is_door = (is_north and dx == 0) or (is_south and dx == 0) or \
(is_west and dz == 0) or (is_east and dz == 0)
if is_door:
continue
gridmap.set_cell_item(Vector3i(x, 1, z), 16, orientation)
# Update pathfinding for bots and movement checks
gridmap.initialize_astar()
# Notify local player
var my_id = multiplayer.get_unique_id()
@@ -683,8 +727,27 @@ func sync_clear_safe_zone(centers_to_clear: Array):
var z = center.y + dz
if x >= 0 and x < gridmap.columns and z >= 0 and z < gridmap.rows:
# Restore Floor 0 back to standard walkable floor
if gridmap.get_cell_item(Vector3i(x, 0, z)) == TILE_SAFE:
var current = gridmap.get_cell_item(Vector3i(x, 0, z))
if current == TILE_SAFE:
gridmap.set_cell_item(Vector3i(x, 0, z), TILE_WALKABLE)
# Also clean up walls ON LAYER 1
# Scan -3 to +3 range to ensure all shifted walls are cleared
for dx in range(-SAFE_ZONE_RADIUS - 1, SAFE_ZONE_RADIUS + 2):
for dz in range(-SAFE_ZONE_RADIUS - 1, SAFE_ZONE_RADIUS + 2):
var x = center.x + dx
var z = center.y + dz
if x >= 0 and x < gridmap.columns and z >= 0 and z < gridmap.rows:
# Clear any wall items on Floor 1
if gridmap.get_cell_item(Vector3i(x, 1, z)) != -1:
gridmap.set_cell_item(Vector3i(x, 1, z), -1)
# Clear local state
safe_zone_centers = []
safe_zone_spawned = false
# Restore navigation
gridmap.initialize_astar()
print("[StopNGo] Safe Zones cleared.")
# Ensure local state is also updated in case this was just an RPC call