From 606b9d52baad30a454cdaff5ff0e723c66463200 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sun, 11 Aug 2024 21:22:19 +0200 Subject: [PATCH] Fix distance logic for gathering nodes --- GatheringPathRenderer/RendererPlugin.cs | 4 +-- GatheringPathRenderer/Windows/EditorWindow.cs | 33 +++++++++++++------ .../533_The Turquoise Trench_MIN.json | 9 +++-- Questionable.Model/GatheringMath.cs | 5 +-- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/GatheringPathRenderer/RendererPlugin.cs b/GatheringPathRenderer/RendererPlugin.cs index 636100ad3..a5cfe4b36 100644 --- a/GatheringPathRenderer/RendererPlugin.cs +++ b/GatheringPathRenderer/RendererPlugin.cs @@ -219,8 +219,8 @@ public sealed class RendererPlugin : IDalamudPlugin refY = x.Position.Z, refZ = x.Position.Y, Filled = true, - radius = x.CalculateMinimumDistance(), - Donut = x.CalculateMaximumDistance() - x.CalculateMinimumDistance(), + radius = locationOverride?.MinimumDistance ?? x.CalculateMinimumDistance(), + Donut = (locationOverride?.MaximumDistance ?? x.CalculateMaximumDistance()) - (locationOverride?.MinimumDistance ?? x.CalculateMinimumDistance()), color = _colors[location.Root.Groups.IndexOf(group) % _colors.Count], Enabled = true, coneAngleMin = minimumAngle, diff --git a/GatheringPathRenderer/Windows/EditorWindow.cs b/GatheringPathRenderer/Windows/EditorWindow.cs index 6d1f2958b..7541001f3 100644 --- a/GatheringPathRenderer/Windows/EditorWindow.cs +++ b/GatheringPathRenderer/Windows/EditorWindow.cs @@ -89,7 +89,8 @@ internal sealed class EditorWindow : Window return; } - _target ??= _objectTable.Where(x => x.ObjectKind == ObjectKind.GatheringPoint && x.DataId == location.Node.DataId) + _target ??= _objectTable + .Where(x => x.ObjectKind == ObjectKind.GatheringPoint && x.DataId == location.Node.DataId) .Select(x => new { Object = x, @@ -129,18 +130,20 @@ internal sealed class EditorWindow : Window } int minAngle = locationOverride.MinimumAngle ?? location.MinimumAngle.GetValueOrDefault(); - if (ImGui.DragInt("Min Angle", ref minAngle, 5, -360, 360)) + int maxAngle = locationOverride.MaximumAngle ?? location.MaximumAngle.GetValueOrDefault(); + if (ImGui.DragIntRange2("Angle", ref minAngle, ref maxAngle, 5, -360, 360)) { locationOverride.MinimumAngle = minAngle; - locationOverride.MaximumAngle ??= location.MaximumAngle.GetValueOrDefault(); + locationOverride.MaximumAngle = maxAngle; _plugin.Redraw(); } - int maxAngle = locationOverride.MaximumAngle ?? location.MaximumAngle.GetValueOrDefault(); - if (ImGui.DragInt("Max Angle", ref maxAngle, 5, -360, 360)) + float minDistance = locationOverride.MinimumDistance ?? location.CalculateMinimumDistance(); + float maxDistance = locationOverride.MaximumDistance ?? location.CalculateMaximumDistance(); + if (ImGui.DragFloatRange2("Distance", ref minDistance, ref maxDistance, 0.1f, 1f, 3f)) { - locationOverride.MinimumAngle ??= location.MinimumAngle.GetValueOrDefault(); - locationOverride.MaximumAngle = maxAngle; + locationOverride.MinimumDistance = minDistance; + locationOverride.MaximumDistance = maxDistance; _plugin.Redraw(); } @@ -150,8 +153,18 @@ internal sealed class EditorWindow : Window ImGui.PushStyleColor(ImGuiCol.Button, ImGuiColors.DalamudRed); if (ImGui.Button("Save")) { - location.MinimumAngle = locationOverride.MinimumAngle; - location.MaximumAngle = locationOverride.MaximumAngle; + if (locationOverride is { MinimumAngle: not null, MaximumAngle: not null }) + { + location.MinimumAngle = locationOverride.MinimumAngle ?? location.MinimumAngle; + location.MaximumAngle = locationOverride.MaximumAngle ?? location.MaximumAngle; + } + + if (locationOverride is { MinimumDistance: not null, MaximumDistance: not null }) + { + location.MinimumDistance = locationOverride.MinimumDistance; + location.MaximumDistance = locationOverride.MaximumDistance; + } + _plugin.Save(context.File, context.Root); } @@ -243,6 +256,6 @@ internal sealed class LocationOverride public bool NeedsSave() { - return MinimumAngle != null && MaximumAngle != null; + return (MinimumAngle != null && MaximumAngle != null) || (MinimumDistance != null && MaximumDistance != null); } } diff --git a/GatheringPaths/4.x - Stormblood/The Ruby Sea/533_The Turquoise Trench_MIN.json b/GatheringPaths/4.x - Stormblood/The Ruby Sea/533_The Turquoise Trench_MIN.json index 7134c24b5..f886de4f8 100644 --- a/GatheringPaths/4.x - Stormblood/The Ruby Sea/533_The Turquoise Trench_MIN.json +++ b/GatheringPaths/4.x - Stormblood/The Ruby Sea/533_The Turquoise Trench_MIN.json @@ -7,6 +7,7 @@ "[Kugane] Aetheryte Plaza", "[Kugane] The Ruby Price" ], + "FlyBetweenNodes": true, "Groups": [ { "Nodes": [ @@ -33,8 +34,10 @@ "Y": 0.503479, "Z": 634.821 }, - "MinimumAngle": 60, - "MaximumAngle": 150 + "MinimumAngle": 45, + "MaximumAngle": 90, + "MinimumDistance": 1.6, + "MaximumDistance": 3 }, { "Position": { @@ -132,4 +135,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/Questionable.Model/GatheringMath.cs b/Questionable.Model/GatheringMath.cs index 86fca7854..e7674a494 100644 --- a/Questionable.Model/GatheringMath.cs +++ b/Questionable.Model/GatheringMath.cs @@ -19,8 +19,9 @@ public static class GatheringMath degrees = Rng.Next(0, 360); float range = Rng.Next( - (int)(location.CalculateMinimumDistance() * 100), - (int)((location.CalculateMaximumDistance() - location.CalculateMinimumDistance()) * 100)) / 100f; + (int)(location.CalculateMinimumDistance() * 100), + (int)(location.CalculateMaximumDistance() * 100)) + / 100f; return (CalculateLandingLocation(location.Position, degrees, range), degrees, range); }