feat: Introduce EnhancedGridMap addon for advanced grid management and procedural generation, and StaticTektonManager for tekton spawning and placement.
This commit is contained in:
@@ -382,6 +382,21 @@ func _execute_block_floor(target_pos: Vector2i):
|
||||
var pos = n.position
|
||||
var block_pos = Vector3i(pos.x, 0, pos.y)
|
||||
|
||||
# Check current item first
|
||||
var current_item = enhanced_gridmap.get_cell_item(block_pos)
|
||||
|
||||
# Skip if already a wall or immutable
|
||||
# We assume Item 4 is the wall/stand.
|
||||
# Also check enhanced_gridmap.immutable_items if available
|
||||
var is_immutable = false
|
||||
if "immutable_items" in enhanced_gridmap:
|
||||
if current_item in enhanced_gridmap.immutable_items:
|
||||
is_immutable = true
|
||||
|
||||
if current_item == 4 or is_immutable:
|
||||
# Don't overwrite existing walls/stands, and don't schedule them for "restoration" (deletion)
|
||||
continue
|
||||
|
||||
if player.is_multiplayer_authority():
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
if main:
|
||||
@@ -390,7 +405,7 @@ func _execute_block_floor(target_pos: Vector2i):
|
||||
# Record for restoration
|
||||
blocked_tiles.append({
|
||||
"position": block_pos,
|
||||
"original_item": 0,
|
||||
"original_item": current_item, # Restore the ACTUAL item that was there (e.g. ground 0 or maybe a dropped item?)
|
||||
"timer": BLOCK_DURATION
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
extends Node
|
||||
|
||||
# StaticTektonManager
|
||||
# Handles spawning and placement of Static Tektons in restricted zones.
|
||||
|
||||
const STAND_SCENE_PATH = "res://scenes/static_tekton_stand.tscn"
|
||||
const TEKTON_SCENE_PATH = "res://scenes/tekton.tscn"
|
||||
const STATIC_CONTROLLER_SCRIPT = "res://scripts/static_tekton_controller.gd"
|
||||
|
||||
# Zone Definitions based on CameraContextManager logic
|
||||
# 9 Zones in a 3x3 grid (approximate for 14x14 map)
|
||||
# Top-Left, Top-Mid, Top-Right
|
||||
# Mid-Left, Mid-Mid, Mid-Right
|
||||
# Bot-Left, Bot-Mid, Bot-Right
|
||||
|
||||
func calculate_spawn_points(count: int, gridmap: Node) -> Array:
|
||||
"""
|
||||
Calculates random spawn positions for static tektons.
|
||||
Returns an Array of Vector2i positions.
|
||||
"""
|
||||
if count <= 0 or not gridmap: return []
|
||||
|
||||
print("[StaticTektonManager] Calculating %d static tekton positions..." % count)
|
||||
|
||||
# 1. Define Zones
|
||||
var width = gridmap.columns
|
||||
var depth = gridmap.rows
|
||||
|
||||
# Simple 3x3 grid partition
|
||||
var zone_w = width / 3
|
||||
var zone_d = depth / 3
|
||||
|
||||
var all_zones = []
|
||||
for z in range(3):
|
||||
for x in range(3):
|
||||
# Create Rect2i for each zone (x, y, w, h)
|
||||
var zone_rect = Rect2i(x * zone_w, z * zone_d, zone_w, zone_d)
|
||||
all_zones.append(zone_rect)
|
||||
|
||||
# 2. Select Zones (Random Distinct)
|
||||
all_zones.shuffle()
|
||||
var selected_zones = all_zones.slice(0, count)
|
||||
|
||||
var spawn_points = []
|
||||
|
||||
# 3. Pick Point in each Selected Zone
|
||||
for i in range(selected_zones.size()):
|
||||
var zone = selected_zones[i]
|
||||
var pos = _pick_spot_in_zone(zone, gridmap)
|
||||
if pos != Vector2i(-1, -1):
|
||||
spawn_points.append(pos)
|
||||
|
||||
return spawn_points
|
||||
|
||||
func _pick_spot_in_zone(zone: Rect2i, gridmap: Node) -> Vector2i:
|
||||
# Find a valid 3x3 spot in the zone
|
||||
# The returned position is the CENTER of the 3x3 area
|
||||
var attempts = 0
|
||||
|
||||
while attempts < 30:
|
||||
attempts += 1
|
||||
# Ensure center is at least 1 tile away from edges of the map to fit 3x3
|
||||
# zone.position might be 0,0.
|
||||
var min_x = max(1, zone.position.x + 1)
|
||||
var max_x = min(gridmap.columns - 2, zone.position.x + zone.size.x - 2)
|
||||
var min_y = max(1, zone.position.y + 1)
|
||||
var max_y = min(gridmap.rows - 2, zone.position.y + zone.size.y - 2)
|
||||
|
||||
if min_x > max_x or min_y > max_y:
|
||||
break # Zone too small
|
||||
|
||||
var x = randi_range(min_x, max_x)
|
||||
var y = randi_range(min_y, max_y)
|
||||
var center = Vector2i(x, y)
|
||||
|
||||
# Check 3x3 area validity
|
||||
var valid_area = true
|
||||
for dx in range(-1, 2):
|
||||
for dy in range(-1, 2):
|
||||
var check_pos = Vector3i(center.x + dx, 0, center.y + dy)
|
||||
if gridmap.get_cell_item(check_pos) == -1:
|
||||
valid_area = false # Void/Hole
|
||||
break
|
||||
# Optionally check for other obstacles?
|
||||
|
||||
if valid_area:
|
||||
return center
|
||||
|
||||
print("[StaticTektonManager] Failed to find 3x3 spot in zone %s" % zone)
|
||||
return Vector2i(-1, -1)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dqgkrld6qe54a
|
||||
Reference in New Issue
Block a user