diff --git a/EnemyController.cs b/EnemyController.cs index 8516018..4571dec 100644 --- a/EnemyController.cs +++ b/EnemyController.cs @@ -47,6 +47,11 @@ public partial class EnemyController : TurnController } + // public List GetEnemyPath(Enemy ENEMY, Vector2I PATH) + // { + + // } + public Vector2I GetBestGoal(Enemy ENEMY, Vector2I GOAL) { Vector2I goal = GOAL; @@ -96,6 +101,7 @@ public partial class EnemyController : TurnController { Enemy enemy = _enemies[i]; enemy._speedRemaining = enemy._address.Y <= _playArea._map._minY ? 0 : enemy._speed; + if (enemy._speedRemaining > 0) { Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, _playArea._map._minY))); @@ -127,10 +133,6 @@ public partial class EnemyController : TurnController List path = _playArea._map.GetPath(enemy._address, goal); Vector2I cell = path[0]; - if (enemy._track) - { - GD.Print(cell, _playArea._map._astar.IsPointSolid(cell)); - } _playArea._map.SetCellEnemy(cell, enemy); enemy._path.Add(cell); enemy._speedRemaining--; @@ -189,7 +191,7 @@ public partial class EnemyController : TurnController public void SetEnemy(Enemy ENEMY, Vector2I CELL) { - if (CELL == new Vector2I(8, 13)) + if (CELL == new Vector2I(5, 7)) { ENEMY._track = true; } diff --git a/Map.cs b/Map.cs index f243070..a0daed6 100644 --- a/Map.cs +++ b/Map.cs @@ -94,16 +94,10 @@ public partial class Map : TileMapLayer public bool IsCellSolid(Vector2I CELL_TO_CHECK) { - bool hasOccupant = GetOccupant(CELL_TO_CHECK) != null; - if (hasOccupant) - { - // GD.Print(CELL_TO_CHECK, " has occupant"); - } + bool hasOccupant = HasOccupant(CELL_TO_CHECK); + bool isSolid = (bool)GetCellTileData(CELL_TO_CHECK).GetCustomData(_isSolidString); - if (isSolid) - { - // GD.Print(CELL_TO_CHECK, " is solid"); - } + return hasOccupant || isSolid; } @@ -111,7 +105,7 @@ public partial class Map : TileMapLayer { List rowCells = [.. _cells.Where(c => c.Y == ROW_TO_CHECK)]; - return rowCells.All(c => GetOccupant(c) != null); + return rowCells.All(c => HasOccupant(c)); } public void SetCellEnemy(Vector2I ADDRESS, Enemy ENEMY) @@ -119,7 +113,6 @@ public partial class Map : TileMapLayer _addressOccupants[ENEMY._address] = null; SetCellSolid(ENEMY._address); - ENEMY._address = ADDRESS; _addressOccupants[ADDRESS] = ENEMY; @@ -146,6 +139,8 @@ public partial class Map : TileMapLayer { _astar.SetPointSolid(FROM, false); List pathTaken = [.. _astar.GetIdPath(FROM, TO, true)]; + + _astar.SetPointSolid(FROM, true); // if (SHOW_PATH) // { // for (int i = 0; i < pathTaken.Count; i++)