Natural resource generator

This commit is contained in:
2025-08-27 23:20:29 +08:00
parent 3fd655a3e5
commit 359e1532d2
8 changed files with 168 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using Godot;
namespace AceFieldNewHorizon.Scripts.System;
@@ -21,21 +22,13 @@ public partial class GridManager : Node
{
// Initialize all layers
foreach (GridLayer layer in Enum.GetValues(typeof(GridLayer)))
{
_layers[layer] = new Dictionary<Vector2I, (Node2D, Vector2I, float)>();
}
}
public bool IsAreaFree(Vector2I topLeft, Vector2I size, float rotation, GridLayer layer = GridLayer.Building)
{
var occupiedCells = GridUtils.GetOccupiedCells(topLeft, size, rotation);
foreach (var cell in occupiedCells)
{
if (_layers[layer].ContainsKey(cell))
return false;
}
return true;
return occupiedCells.All(cell => !_layers[layer].ContainsKey(cell));
}
public void OccupyArea(Vector2I topLeft, Node2D building, Vector2I size, float rotation,