continuing to switch to MapCell orientation
This commit is contained in:
@@ -59,7 +59,8 @@ public partial class Peg : MapCellOccupant
|
||||
// }
|
||||
|
||||
// }
|
||||
return _pegController._playArea._map.GetPath(_address, Goal(), false, PARTIAL);
|
||||
MapCell goal = Goal();
|
||||
return _pegController._playArea._map.GetPath(_address, goal._address, false, PARTIAL);
|
||||
}
|
||||
|
||||
public virtual Dictionary<Vector2I, MapCell> GetEnemies()
|
||||
@@ -87,13 +88,13 @@ public partial class Peg : MapCellOccupant
|
||||
return _pegController._playArea._map.GetCellPositionFromAddress(_address);
|
||||
}
|
||||
|
||||
public virtual Vector2I Goal()
|
||||
public virtual MapCell Goal()
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
List<Vector2I> visible = GetVisibleCells();
|
||||
List<Vector2I> unoccupied = [.. visible.Where(c => !map._astar.IsPointSolid(c))];
|
||||
List<Vector2I> closest = [.. unoccupied.OrderByDescending(c => c.Y * _disposition).ThenByDescending(c => Math.Abs(c.X - _address.X))];
|
||||
return closest[0];
|
||||
Dictionary<Vector2I, MapCell> visible = GetVisibleCells();
|
||||
Dictionary<Vector2I, MapCell> unoccupied = visible.Where(c => !map._astar.IsPointSolid(c.Key)).ToDictionary();
|
||||
Dictionary<Vector2I, MapCell> closest = unoccupied.OrderByDescending(c => c.Value._address.Y * (int)_disposition).ThenByDescending(c => Math.Abs(c.Value._address.X - _address.X)).ToDictionary();
|
||||
return closest.ElementAt(0).Value;
|
||||
}
|
||||
|
||||
public virtual void StartTurn()
|
||||
|
||||
Reference in New Issue
Block a user