From d2993b17a4e959a13f35d2a5c90c6dbaf2e8d9d9 Mon Sep 17 00:00:00 2001 From: Conor Edmonds Date: Tue, 9 Jun 2026 19:43:36 -0400 Subject: [PATCH] debugging --- EnemyController.cs | 17 +++++++++-------- Map.cs | 25 +++++++++---------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/EnemyController.cs b/EnemyController.cs index 35b05f1..6a8f185 100644 --- a/EnemyController.cs +++ b/EnemyController.cs @@ -115,19 +115,20 @@ public partial class EnemyController : TurnController public void MoveEnemies() { + Map map = _playArea._map; for (int i = 0; i < _enemies.Count; i++) { Enemy enemy = _enemies[i]; - enemy._speedRemaining = enemy._address.Y <= _playArea._map._minY ? 0 : enemy._speed; + enemy._speedRemaining = enemy._address.Y <= 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))); + Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, map._minY))); if (enemy._address == Vector2I.Zero) { GD.Print(1,goal); } - enemy._path = _playArea._map.GetPath(enemy._address, goal); + enemy._path = map.GetPath(enemy._address, goal); if (enemy._path.Count <= 0) { enemy._speedRemaining = 0; @@ -151,17 +152,17 @@ public partial class EnemyController : TurnController { continue; } - if (enemy._address.Y <= _playArea._map._minY) + if (enemy._address.Y <= map._minY) { enemy._speedRemaining = 0; continue; } - Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, _playArea._map._minY))); + Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, map._minY))); if (enemy._address == Vector2I.Zero) { GD.Print(2,goal); } - List path = _playArea._map.GetPath(enemy._address, goal); + List path = map.GetPath(enemy._address, goal); if (path.Count == 0) { continue; @@ -171,7 +172,7 @@ public partial class EnemyController : TurnController { GD.Print(3, enemy._address); } - _playArea._map.SetCellEnemy(cell, enemy); + map.SetCellEnemy(cell, enemy); enemy._path.Add(cell); enemy._speedRemaining--; } @@ -199,7 +200,7 @@ public partial class EnemyController : TurnController { tween.Parallel(); } - tween.TweenProperty(mEnemy, "global_position", _playArea._map.GetCellPositionFromAddress(mEnemy._path[i]), .25f); + tween.TweenProperty(mEnemy, "global_position", map.GetCellPositionFromAddress(mEnemy._path[i]), .25f); } } diff --git a/Map.cs b/Map.cs index f31ed11..6cb1c5d 100644 --- a/Map.cs +++ b/Map.cs @@ -93,11 +93,19 @@ public partial class Map : TileMapLayer { _addressOccupants[ENEMY._address] = null; SetCellSolid(ENEMY._address); + if (ENEMY._address == Vector2I.Zero) + { + GD.Print(4,_astar.IsPointSolid(ENEMY._address)); + } ENEMY._address = ADDRESS; _addressOccupants[ADDRESS] = ENEMY; SetCellSolid(ADDRESS); + if (ADDRESS == Vector2I.Zero) + { + GD.Print(5,_astar.IsPointSolid(ADDRESS)); + } } public void SetCellSolid(Vector2I ADDRESS) @@ -120,24 +128,9 @@ public partial class Map : TileMapLayer public List 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 pathTaken = [.. _astar.GetIdPath(FROM, TO, true)]; _astar.SetPointSolid(FROM, true); - if (FROM == Vector2I.Zero) - { - // GD.Print(6,_astar.IsPointSolid(FROM)); - } - if (TO == Vector2I.Zero) - { - // GD.Print(7,_astar.IsPointSolid(FROM)); - } if (!INCLUDE_FROM) {