diff --git a/Deliveroo/Deliveroo.csproj b/Deliveroo/Deliveroo.csproj index c9dccd3..230dcad 100644 --- a/Deliveroo/Deliveroo.csproj +++ b/Deliveroo/Deliveroo.csproj @@ -1,7 +1,7 @@ net7.0-windows - 2.8 + 2.9 11.0 enable true diff --git a/Deliveroo/DeliverooPlugin.GameFunctions.cs b/Deliveroo/DeliverooPlugin.GameFunctions.cs index 1894eb4..fdd16b5 100644 --- a/Deliveroo/DeliverooPlugin.GameFunctions.cs +++ b/Deliveroo/DeliverooPlugin.GameFunctions.cs @@ -51,25 +51,17 @@ partial class DeliverooPlugin private float GetDistanceToNpc(int npcId, out GameObject? o) { - try + foreach (var obj in _objectTable) { - foreach (var obj in _objectTable) + if (obj.ObjectKind == ObjectKind.EventNpc && obj is Character c) { - // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - if (obj != null && obj.ObjectKind == ObjectKind.EventNpc && obj is Character c) + if (GetNpcId(obj) == npcId) { - if (GetNpcId(obj) == npcId) - { - o = obj; - return Vector3.Distance(_clientState.LocalPlayer!.Position, c.Position); - } + o = obj; + return Vector3.Distance(_clientState.LocalPlayer?.Position ?? Vector3.Zero, c.Position); } } } - catch (Exception) - { - // ignore - } o = null; return float.MaxValue;