diff --git a/PositionalGuide/Configuration.cs b/PositionalGuide/Configuration.cs index 31dde4b..407e57a 100644 --- a/PositionalGuide/Configuration.cs +++ b/PositionalGuide/Configuration.cs @@ -76,16 +76,16 @@ public const int /// Starts at front then goes clockwise up to index=7, then circle at index=8 and outer circle at index=9 /// public Vector4[] LineColours { get; set; } = new Vector4[] { - new Vector4(1, 0, 0, 1), // front - new Vector4(1, 0, 0, 1), // front right - new Vector4(0, 0, 1, 1), // right - new Vector4(0, 1, 0, 1), // back right - new Vector4(0, 1, 0, 1), // back - new Vector4(0, 1, 0, 1), // back left - new Vector4(0, 0, 1, 1), // left - new Vector4(1, 0, 0, 1), // front left - new Vector4(1, 1, 0, 1), // circle default - new Vector4(1, 1, 0, 1), // outer circle default + new(1, 0, 0, 1), // front + new(1, 0, 0, 1), // front right + new(0, 0, 1, 1), // right + new(0, 1, 0, 1), // back right + new(0, 1, 0, 1), // back + new(0, 1, 0, 1), // back left + new(0, 0, 1, 1), // left + new(1, 0, 0, 1), // front left + new(1, 1, 0, 1), // circle default + new(1, 1, 0, 1), // outer circle default }; public void Update() { diff --git a/PositionalGuide/ImGuitils.cs b/PositionalGuide/ImGuitils.cs index f50e376..61c2148 100644 --- a/PositionalGuide/ImGuitils.cs +++ b/PositionalGuide/ImGuitils.cs @@ -7,9 +7,7 @@ namespace PrincessRTFM.PositionalGuide; internal class ImGuitils { public int TooltipPixelWrapWidth; - public ImGuitils(int tooltipPixelWrapWidth) { - this.TooltipPixelWrapWidth = tooltipPixelWrapWidth; - } + public ImGuitils(int tooltipPixelWrapWidth) => this.TooltipPixelWrapWidth = tooltipPixelWrapWidth; public void Tooltip(string text) { if (ImGui.IsItemHovered()) { diff --git a/PositionalGuide/Plugin.cs b/PositionalGuide/Plugin.cs index 666c4f9..a7c64d2 100644 --- a/PositionalGuide/Plugin.cs +++ b/PositionalGuide/Plugin.cs @@ -8,7 +8,7 @@ using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.Gui.Dtr; -using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.IoC; @@ -27,7 +27,7 @@ public class Plugin: IDalamudPlugin { // lineIndexToRad and circleSegmentIdxToRad are fixed and only need to be calculated once at the start, // since neither the number of lines nor the number of circle segments change private readonly float[] lineIndexToAngle = Enumerable.Range(Configuration.IndexFront, Configuration.IndexFrontLeft + 1).Select(idx => (float)(idx * Math.PI / 4)).ToArray(); - private readonly float[] circleSegmentIdxToAngle = Enumerable.Range(0, circleSegmentCount).Select(idx => (float)(idx * (2.0 * Math.PI / circleSegmentCount))).ToArray(); + private readonly float[] circleSegmentIdxToAngle = Enumerable.Range(0, circleSegmentCount).Select(idx => (float)(idx * (2.0 * Math.PI / circleSegmentCount))).ToArray(); private readonly Vector4[] circleSegmentIdxToColour = new Vector4[circleSegmentCount]; private enum CircleTypes { Target, Outer }; @@ -39,7 +39,7 @@ private enum CircleTypes { Target, Outer }; [PluginService] public static IGameGui Gui { get; private set; } = null!; [PluginService] public static IChatGui Chat { get; private set; } = null!; - [PluginService] public static DalamudPluginInterface Interface { get; private set; } = null!; + [PluginService] public static IDalamudPluginInterface Interface { get; private set; } = null!; [PluginService] public static ICommandManager Commands { get; private set; } = null!; [PluginService] public static IClientState Client { get; private set; } = null!; [PluginService] public static ITargetManager Targets { get; private set; } = null!; @@ -50,7 +50,7 @@ private enum CircleTypes { Target, Outer }; private readonly WindowSystem windowSystem; private readonly ConfigWindow configWindow; - private readonly DtrBarEntry dtrEntry; + private readonly IDtrBarEntry dtrEntry; public Plugin(IDtrBar dtrBar) { this.Config = Interface.GetPluginConfig() as Configuration ?? new(); @@ -117,10 +117,10 @@ internal void Draw() { if (!this.Config.Enabled) return; - if (Targets.Target is not BattleChara target) + if (Targets.Target is not IBattleNpc target) return; - if (Client.LocalPlayer is not PlayerCharacter player) + if (Client.LocalPlayer is not IPlayerCharacter player) return; if (target.ObjectKind is ObjectKind.Player) { @@ -174,16 +174,17 @@ internal void Draw() { for (int lineIndex = Configuration.IndexFront; lineIndex <= Configuration.IndexFrontLeft; ++lineIndex) { if (!this.Config.DrawGuides[lineIndex]) continue; - anyLineActive = true; + anyLineActive = true; Vector3 rotated = RotatePoint(targetPos, guidelineBasePoint2, targetFacing + this.lineIndexToAngle[lineIndex]); bool endpointOnScreen = Gui.WorldToScreen(rotated, out Vector2 coord); - if (limitEither) { - if (!targetOnScreen && !endpointOnScreen) - continue; - } else if (limitOuter && !endpointOnScreen) { - continue; - } + if (limitEither) { + if (!targetOnScreen && !endpointOnScreen) + continue; + } + else if (limitOuter && !endpointOnScreen) { + continue; + } drawing.AddLine(centre, coord, ImGui.GetColorU32(this.Config.LineColours[lineIndex]), this.Config.LineThickness); } @@ -264,13 +265,13 @@ private void DrawCircle(ImDrawListPtr drawing, Vector3 targetPos, Vector3 basePo case CircleTypes.Outer: circleColour = this.Config.LineColours[Configuration.IndexOuterCircle]; forceCircleColour = this.Config.AlwaysUseCircleColours || this.Config.AlwaysUseCircleColoursOuter || !anyLineActive; - circleBasePoint += new Vector3(0, 0, this.Config.SoftOuterCircleRange); + circleBasePoint += new Vector3(0, 0, this.Config.SoftOuterCircleRange); break; } Vector3 startPoint = RotatePoint(targetPos, circleBasePoint, targetFacing); Vector3[] points = CirclePoints(targetPos, startPoint, this.circleSegmentIdxToAngle).ToArray(); - + (Vector2 point, bool render)[] screenPoints = new (Vector2 point, bool render)[points.Length]; for (int i = 0; i < points.Length; ++i) { bool render = Gui.WorldToScreen(points[i], out Vector2 screenPoint); @@ -310,7 +311,7 @@ private static Vector3 RotatePoint(Vector3 centre, Vector3 originalPoint, double private static double AngleBetween(Vector2 vertex, Vector2 a, Vector2 b) => Math.Atan2(b.Y - vertex.Y, b.X - vertex.X) - Math.Atan2(a.Y - vertex.Y, a.X - vertex.X); private static double AngleBetween(Vector3 vertex, Vector3 a, Vector3 b) => AngleBetween(new Vector2(vertex.X, vertex.Z), new Vector2(a.X, a.Z), new Vector2(b.X, b.Z)); - private static float AngleDifference(float a, float b) => (float)(Math.Min(Math.Abs(a - b), Math.Abs(Math.Abs(a - b) - (2 * Math.PI)))); + private static float AngleDifference(float a, float b) => (float)Math.Min(Math.Abs(a - b), Math.Abs(Math.Abs(a - b) - (2 * Math.PI))); private static IEnumerable CirclePoints(Vector2 centre, Vector2 start, float[] angles) { foreach (float angle in angles) diff --git a/PositionalGuide/dalamud.props b/PositionalGuide/dalamud.props index c882c06..4465f75 100644 --- a/PositionalGuide/dalamud.props +++ b/PositionalGuide/dalamud.props @@ -15,7 +15,7 @@ - + $(DalamudLibPath)Newtonsoft.Json.dll False @@ -44,6 +44,10 @@ $(DalamudLibPath)FFXIVClientStructs.dll False + + $(DalamudLibPath)InteropGenerator.Runtime.dll + False + diff --git a/PositionalGuide/packages.lock.json b/PositionalGuide/packages.lock.json index 59d19f2..19fcea9 100644 --- a/PositionalGuide/packages.lock.json +++ b/PositionalGuide/packages.lock.json @@ -1,13 +1,13 @@ { - "version": 1, - "dependencies": { - "net8.0-windows7.0": { - "DalamudPackager": { - "type": "Direct", - "requested": "[2.1.12, )", - "resolved": "2.1.12", - "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" - } - } - } -} + "version": 1, + "dependencies": { + "net8.0-windows7.0": { + "DalamudPackager": { + "type": "Direct", + "requested": "[2.1.13, )", + "resolved": "2.1.13", + "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" + } + } + } +} \ No newline at end of file