feat: Introduce an enhanced gridmap addon with procedural generation, pathfinding, and initial core game scripts and assets.

This commit is contained in:
Yogi Wiguna
2026-02-23 12:31:42 +08:00
parent f72f641332
commit 92fd76f4b8
7 changed files with 67 additions and 39 deletions
+4 -10
View File
@@ -105,7 +105,7 @@ func highlight_empty_adjacent_cells():
var current_cell = Vector3i(player.current_position.x, 1, player.current_position.y)
if enhanced_gridmap.get_cell_item(current_cell) == -1:
highlighted_cells.append(player.current_position)
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 0, player.current_position.y),
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 2, player.current_position.y),
enhanced_gridmap.hover_item)
print("Highlighted current position: ", player.current_position)
@@ -117,7 +117,7 @@ func highlight_empty_adjacent_cells():
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
if enhanced_gridmap.get_cell_item(cell) == -1: # Check if cell is empty
highlighted_cells.append(cell_pos)
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 0, cell_pos.y),
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 2, cell_pos.y),
enhanced_gridmap.hover_item)
print("Highlighted adjacent cell: ", cell_pos)
@@ -132,7 +132,7 @@ func highlight_random_valid_cells():
var current_item = enhanced_gridmap.get_cell_item(current_cell)
if current_item != -1:
highlighted_cells.append(player.current_position)
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 0, player.current_position.y),
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 2, player.current_position.y),
enhanced_gridmap.hover_item)
# Then check all adjacent cells for items
@@ -143,7 +143,7 @@ func highlight_random_valid_cells():
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
if enhanced_gridmap.get_cell_item(cell) != -1: # Only highlight cells with items
highlighted_cells.append(cell_pos)
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 0, cell_pos.y),
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 2, cell_pos.y),
enhanced_gridmap.hover_item)
func highlight_occupied_playerboard_slots():
@@ -196,12 +196,6 @@ func clear_highlights():
# Safest is to check against hover_id or typical highlight IDs.
if l2_item != -1:
enhanced_gridmap.set_cell_item(l2_pos, -1)
# Check Layer 0 (Floor Highlight)
var l0_pos = Vector3i(cell.x, 0, cell.y)
var l0_item = enhanced_gridmap.get_cell_item(l0_pos)
if l0_item == hover_id:
enhanced_gridmap.set_cell_item(l0_pos, enhanced_gridmap.normal_items[0])
highlighted_cells.clear()
+18 -6
View File
@@ -21,6 +21,7 @@ var finish_line_x: int = 21 # Right side of the map for win condition
# Tile IDs
const TILE_WALKABLE = 0
const TILE_START = 2 # Start Line
const TILE_SAFE = 2 # Green Safe Zone
const TILE_OBSTACLE = 4 # Wall
@@ -162,7 +163,9 @@ func sync_phase(phase_name: String, duration: float):
phase_timer = duration
func _setup_arena():
var gridmap = get_node("/root/Main/EnhancedGridMap")
var gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
print("[StopNGo] Setting up 22x10 Arena with Randomized Obstacles...")
@@ -181,7 +184,10 @@ func sync_arena_setup():
func _apply_arena_setup():
# Shared logic for resizing and clearing
var gridmap = get_node("/root/Main/EnhancedGridMap")
var gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
# Fallback just in case
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
# Set Size for Stop n Go explicitly, bypassing setters that wipe the map
@@ -197,7 +203,9 @@ func _apply_arena_setup():
# Create bands based on X (Horizontal Progress)
for x in range(gridmap.columns):
var tile_id = TILE_WALKABLE
if x in safe_columns:
if x == 0:
tile_id = TILE_START
elif x in safe_columns:
tile_id = TILE_SAFE
for z in range(gridmap.rows):
@@ -251,7 +259,10 @@ func _apply_arena_setup():
# by sync_grid_item inside _spawn_mission_tiles.
func _spawn_mission_tiles():
var gridmap = get_node("/root/Main/EnhancedGridMap")
var gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
# Tile IDs for missions: Heart(7), Diamond(8), Star(9), Coin(10)
var mission_tiles = [7, 8, 9, 10]
@@ -297,8 +308,9 @@ func sync_missions(missions: Dictionary):
func check_movement_violation(player_id: int, from: Vector2i, to: Vector2i) -> bool:
"""Check if movement is illegal (during STOP phase and not in safe zone)."""
if current_phase == Phase.STOP:
var main = get_node("/root/Main")
var gridmap = main.get_node("EnhancedGridMap") if main else null
var gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if gridmap:
# Check FROM position. If you were safe, you can move?
# Rules: "If a player moves during this phase".