✨ Natural resource generator
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user