From f060ea1e50e0d2de58b5ec0fb4e8ca3a6548e9c6 Mon Sep 17 00:00:00 2001 From: Xian55 Date: Tue, 19 Oct 2021 21:16:07 +0200 Subject: [PATCH] GoalThreat: Fix exception when multiple enemies around an unable to run Linq.Min --- Core/Goals/GoalThread.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Goals/GoalThread.cs b/Core/Goals/GoalThread.cs index 75542d335..15b93987b 100644 --- a/Core/Goals/GoalThread.cs +++ b/Core/Goals/GoalThread.cs @@ -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);