From 375546b4acc7905b517c2c67d6cb975fe7c0ca9f Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 14 Oct 2023 16:26:06 +0200 Subject: [PATCH] Don't show window if between areas --- Workshoppa/WorkshopPlugin.GameFunctions.cs | 16 +++++++++++----- Workshoppa/WorkshopPlugin.cs | 2 ++ Workshoppa/Workshoppa.csproj | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Workshoppa/WorkshopPlugin.GameFunctions.cs b/Workshoppa/WorkshopPlugin.GameFunctions.cs index 6cb7166..50469f9 100644 --- a/Workshoppa/WorkshopPlugin.GameFunctions.cs +++ b/Workshoppa/WorkshopPlugin.GameFunctions.cs @@ -32,14 +32,20 @@ partial class WorkshopPlugin private float GetDistanceToEventObject(IReadOnlyList npcIds, out GameObject? o) { - foreach (var obj in _objectTable) + Vector3? localPlayerPosition = _clientState.LocalPlayer?.Position; + if (localPlayerPosition != null) { - if (obj.ObjectKind == ObjectKind.EventObj) + foreach (var obj in _objectTable) { - if (npcIds.Contains(GetNpcId(obj))) + if (obj.ObjectKind == ObjectKind.EventObj) { - o = obj; - return Vector3.Distance(_clientState.LocalPlayer?.Position ?? Vector3.Zero, obj.Position + new Vector3(0, -2, 0)); + if (npcIds.Contains(GetNpcId(obj))) + { + o = obj; + float distance = Vector3.Distance(localPlayerPosition.Value, obj.Position + new Vector3(0, -2, 0)); + if (distance > 0.01) + return distance; + } } } } diff --git a/Workshoppa/WorkshopPlugin.cs b/Workshoppa/WorkshopPlugin.cs index 2782b86..dbd7997 100644 --- a/Workshoppa/WorkshopPlugin.cs +++ b/Workshoppa/WorkshopPlugin.cs @@ -101,6 +101,8 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin if (!_clientState.IsLoggedIn || !WorkshopTerritories.Contains(_clientState.TerritoryType) || _condition[ConditionFlag.BoundByDuty] || + _condition[ConditionFlag.BetweenAreas] || + _condition[ConditionFlag.BetweenAreas51] || GetDistanceToEventObject(FabricationStationIds, out var fabricationStation) >= 3f) { _mainWindow.NearFabricationStation = false; diff --git a/Workshoppa/Workshoppa.csproj b/Workshoppa/Workshoppa.csproj index 20824c7..3cb49fd 100644 --- a/Workshoppa/Workshoppa.csproj +++ b/Workshoppa/Workshoppa.csproj @@ -1,7 +1,7 @@ net7.0-windows - 2.4 + 2.5 11.0 enable true