minor changes, next step is to add 2-3 friendly pegs, 2 neutral pegs, 2 hostile pegs, 2 buildings and all associated actions for these additions

This commit is contained in:
2026-07-01 02:36:31 -04:00
parent 2c289333f0
commit bbe9eefcfa
7 changed files with 106 additions and 31 deletions
+10 -6
View File
@@ -9,9 +9,16 @@ public partial class Map : TileMapLayer
public int _minX, _maxX, _minY, _maxY, _mainSource = 0;
public string _isSolidString = "is_solid";
public Vector2 _cellSize, _sizeInPixels, _sizeInCells;
public List<Vector2I> _cells = new(), _leftmostColumn = new(), _rightmostColumn = new(), _topRow = new(), _bottomRow = new();
public List<Vector2I> _leftmostColumn = new(), _rightmostColumn = new(), _topRow = new(), _bottomRow = new();
public AStarGrid2D _astar = new();
public Dictionary<Vector2I, Peg> _addressOccupants = new();
public List<Vector2I> _cells
{
get
{
return [.. GetUsedCells()];
}
}
public int _firstOpenRow
{
get
@@ -72,7 +79,6 @@ public partial class Map : TileMapLayer
{
base._Ready();
_cellSize = TileSet.TileSize;
_cells = [.. GetUsedCells()];
_cells.ForEach(c => _addressOccupants[c] = null);
_minX = _cells.Min(c => c.X);
_maxX = _cells.Max(c => c.X);
@@ -149,10 +155,8 @@ public partial class Map : TileMapLayer
}
PEG._address = ADDRESS;
}
_addressOccupants[ADDRESS] = PEG;
SetCellSolid(ADDRESS);
PEG._path.Add(ADDRESS);
}
public void SetCellSolid(Vector2I ADDRESS)
@@ -175,11 +179,11 @@ public partial class Map : TileMapLayer
EvaluateSolidCells();
}
public List<Vector2I> GetPath(Vector2I FROM, Vector2I TO, bool INCLUDE_FROM = false)
public List<Vector2I> GetPath(Vector2I FROM, Vector2I TO, bool INCLUDE_FROM = false, bool PARTIAL = false)
{
_astar.SetPointSolid(FROM, false);
List<Vector2I> pathTaken = [.. _astar.GetIdPath(FROM, TO)];
List<Vector2I> pathTaken = [.. _astar.GetIdPath(FROM, TO, PARTIAL)];
_astar.SetPointSolid(FROM, true);
if (!INCLUDE_FROM)