mostly fixed movement but there's still a problem with enemies in the top left cell (0,0) being set to not solid

This commit is contained in:
2026-06-09 18:11:06 -04:00
parent e209861cb3
commit 4722cf882b
7 changed files with 114 additions and 40 deletions
+19 -30
View File
@@ -73,25 +73,6 @@ public partial class Map : TileMapLayer
return GetOccupant(CELL_TO_CHECK) != null;
}
public void HighlightCells()
{
_cells.ForEach(c =>
{
if (HasOccupant(c))
{
SetCell(c, 0, new Vector2I(4,1));
}
else if (_astar.IsPointSolid(c))
{
}
else
{
SetCell(c, 0, new Vector2I(0, (c.X + c.Y) % 2 == 0 ? 0 : 1));
}
});
}
public bool IsCellSolid(Vector2I CELL_TO_CHECK)
{
bool hasOccupant = HasOccupant(CELL_TO_CHECK);
@@ -105,7 +86,7 @@ public partial class Map : TileMapLayer
{
List<Vector2I> rowCells = [.. _cells.Where(c => c.Y == ROW_TO_CHECK)];
return rowCells.All(c => HasOccupant(c));
return rowCells.All(c => _astar.IsPointSolid(c));
}
public void SetCellEnemy(Vector2I ADDRESS, Enemy ENEMY)
@@ -135,20 +116,28 @@ public partial class Map : TileMapLayer
EvaluateSolidCells();
}
public List<Vector2I> GetPath(Vector2I FROM, Vector2I TO, bool INCLUDE_FROM = false, bool SHOW_PATH = false)
public List<Vector2I> GetPath(Vector2I FROM, Vector2I TO, bool INCLUDE_FROM = false)
{
_astar.SetPointSolid(FROM, false);
if (FROM == Vector2I.Zero)
{
GD.Print(4,_astar.IsPointSolid(FROM));
}
if (TO == Vector2I.Zero)
{
GD.Print(5,_astar.IsPointSolid(FROM));
}
List<Vector2I> pathTaken = [.. _astar.GetIdPath(FROM, TO, true)];
_astar.SetPointSolid(FROM, true);
// if (SHOW_PATH)
// {
// for (int i = 0; i < pathTaken.Count; i++)
// {
// Vector2I cell = pathTaken[i];
// SetCell(cell, _mainSource, _pathTakenAtlasCoordinates);
// }
// }
if (FROM == Vector2I.Zero)
{
GD.Print(6,_astar.IsPointSolid(FROM));
}
if (TO == Vector2I.Zero)
{
GD.Print(7,_astar.IsPointSolid(FROM));
}
if (!INCLUDE_FROM)
{
pathTaken.Remove(FROM);