Skip to content

Commit

Permalink
GoalThreat: Fix exception when multiple enemies around an unable to r…
Browse files Browse the repository at this point in the history
…un Linq.Min
  • Loading branch information
Xian55 committed Oct 19, 2021
1 parent 5f76ba0 commit f060ea1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Core/Goals/GoalThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public void OnActionEvent(object sender, ActionEventArgs e)
if (routeInfo != null && routeInfo.PoiList.Any())
{
var closest = routeInfo.PoiList.Where(p => p.Name == "Corpse").
Min(i => (WowPoint.DistanceTo(goapAgent.PlayerReader.PlayerLocation, i.Location), i));
Select(i => new { i, d = WowPoint.DistanceTo(goapAgent.PlayerReader.PlayerLocation, i.Location) }).
Aggregate((a, b) => a.d <= b.d ? a : b);

if (closest.i != null)
{
routeInfo.PoiList.Remove(closest.i);
Expand Down

0 comments on commit f060ea1

Please sign in to comment.