diff --git a/SneakOnBy/DeepDungeonDex.cs b/SneakOnBy/DeepDungeonDex.cs index 67caee1..d79d732 100644 --- a/SneakOnBy/DeepDungeonDex.cs +++ b/SneakOnBy/DeepDungeonDex.cs @@ -1,7 +1,5 @@ using Dalamud.Logging; using Dalamud.Plugin; -using ECommons.DalamudServices; -using ECommons.ExcelServices; using ECommons.Reflection; using FFXIVClientStructs.FFXIV.Component.GUI; using System; diff --git a/SneakOnBy/ECommons b/SneakOnBy/ECommons new file mode 160000 index 0000000..04127e1 --- /dev/null +++ b/SneakOnBy/ECommons @@ -0,0 +1 @@ +Subproject commit 04127e1fe2f49221a3cc1e621ed24f4199ecaee0 diff --git a/SneakOnBy/Plugin.cs b/SneakOnBy/Plugin.cs index ae609b3..9c3164e 100644 --- a/SneakOnBy/Plugin.cs +++ b/SneakOnBy/Plugin.cs @@ -4,6 +4,8 @@ using Dalamud.Interface.Windowing; using SneakOnBy.Windows; using ECommons; +using Dalamud.Plugin.Services; +using ECommons.Reflection; namespace SneakOnBy { @@ -12,8 +14,10 @@ public sealed class Plugin : IDalamudPlugin public string Name => "Sneak On By"; private const string CommandName = "/sneaky"; + public static IDalamudPlugin Instance; + private DalamudPluginInterface PluginInterface { get; init; } - private CommandManager CommandManager { get; init; } + private ICommandManager CommandManager { get; init; } public Configuration Configuration { get; init; } public WindowSystem WindowSystem = new("SneakOnBy"); @@ -22,12 +26,15 @@ public sealed class Plugin : IDalamudPlugin public Plugin( [RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, - [RequiredVersion("1.0")] CommandManager commandManager) + [RequiredVersion("1.0")] ICommandManager commandManager) { + + Instance = this; this.PluginInterface = pluginInterface; this.CommandManager = commandManager; - ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector, Module.ObjectFunctions); + Services.Initialize(pluginInterface); + //ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector, Module.ObjectFunctions); this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); this.Configuration.Initialize(this.PluginInterface); @@ -47,20 +54,25 @@ public sealed class Plugin : IDalamudPlugin this.PluginInterface.UiBuilder.Draw += DrawUI; this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; - + + DalamudReflector.Init(); + + } public void Dispose() { this.WindowSystem.RemoveAllWindows(); - ECommonsMain.Dispose(); + //ECommonsMain.Dispose(); ConfigWindow.Dispose(); Canvas.Dispose(); this.CommandManager.RemoveHandler(CommandName); + + DalamudReflector.Dispose(); } private void OnCommand(string command, string args) diff --git a/SneakOnBy/Services.cs b/SneakOnBy/Services.cs new file mode 100644 index 0000000..eb5fff6 --- /dev/null +++ b/SneakOnBy/Services.cs @@ -0,0 +1,22 @@ +using Dalamud.IoC; +using Dalamud.Plugin.Services; +using Dalamud.Plugin; + +public class Services +{ + public static void Initialize(DalamudPluginInterface pluginInterface) + => pluginInterface.Create(); + + // @formatter:off + [PluginService][RequiredVersion("1.0")] public static IClientState ClientState { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static IGameInteropProvider GameInteropProvider { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static IPluginLog PluginLog { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static DalamudPluginInterface PluginInterface { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static IFramework Framework { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static ICondition Condition { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static IObjectTable Objects { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static IGameGui GameGui { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public static IKeyState KeyState { get; private set; } = null!; + // @formatter:on + +} diff --git a/SneakOnBy/SneakOnBy.csproj b/SneakOnBy/SneakOnBy.csproj index b3d7437..3749a4e 100644 --- a/SneakOnBy/SneakOnBy.csproj +++ b/SneakOnBy/SneakOnBy.csproj @@ -30,8 +30,7 @@ - - + diff --git a/SneakOnBy/Windows/Canvas.cs b/SneakOnBy/Windows/Canvas.cs index 10d11ad..f112cdb 100644 --- a/SneakOnBy/Windows/Canvas.cs +++ b/SneakOnBy/Windows/Canvas.cs @@ -3,15 +3,10 @@ using Dalamud.Interface.Windowing; using ImGuiNET; using Dalamud.Game.ClientState.Objects.Types; -using ECommons.GameFunctions; -using ECommons.DalamudServices; -using Dalamud.Interface; using ECommons.MathHelpers; using Dalamud.Game.ClientState.Objects.Enums; -using Dalamud.Interface.Colors; -using Dalamud.Utility.Numerics; using Dalamud.Game.ClientState.Conditions; -using Lumina.Excel.GeneratedSheets; +using Dalamud.Interface.Utility; namespace SneakOnBy.Windows; @@ -45,16 +40,16 @@ public override void PreDraw() public override bool DrawConditions() { - return Svc.ClientState.LocalPlayer != null && Svc.Condition[ConditionFlag.InDeepDungeon]; + return Services.ClientState.LocalPlayer != null && Services.Condition[ConditionFlag.InDeepDungeon]; } public void Dispose() { } public override void Draw() { - foreach (GameObject obj in Svc.Objects) + foreach (GameObject obj in Services.Objects) { - if (obj is BattleNpc bnpc && bnpc.IsHostile() && !bnpc.StatusFlags.HasFlag(StatusFlags.InCombat) && bnpc.IsCharacterVisible()) { + if (obj is BattleNpc bnpc && bnpc.StatusFlags.HasFlag(StatusFlags.Hostile) && !bnpc.StatusFlags.HasFlag(StatusFlags.InCombat)) { Aggro aggro = DeepDungeonDex.GetMobAggroType(bnpc.NameId); switch (aggro) { @@ -117,7 +112,7 @@ internal static (int min, int max) Get18PieForAngle(float a) internal static float GetAngle(GameObject bnpc) { - return (MathHelper.GetRelativeAngle(Svc.ClientState.LocalPlayer.Position, bnpc.Position) + bnpc.Rotation.RadToDeg()) % 360; + return (MathHelper.GetRelativeAngle(Services.ClientState.LocalPlayer.Position, bnpc.Position) + bnpc.Rotation.RadToDeg()) % 360; } internal static void ActorConeXZ(GameObject actor, float radius, float startRads, float endRads, Vector4 color, bool lines = true) diff --git a/SneakOnBy/Windows/ConvexShape.cs b/SneakOnBy/Windows/ConvexShape.cs index dabcd68..91ba060 100644 --- a/SneakOnBy/Windows/ConvexShape.cs +++ b/SneakOnBy/Windows/ConvexShape.cs @@ -1,4 +1,3 @@ -using ECommons.DalamudServices; using System.Numerics; using ImGuiNET; using System; @@ -26,7 +25,7 @@ internal void Point(Vector3 worldPos) // TODO: implement proper clipping. everything goes crazy when // drawing lines outside the clip window and behind the camera // point - var visible = Svc.GameGui.WorldToScreen(worldPos, out Vector2 pos); + var visible = Services.GameGui.WorldToScreen(worldPos, out Vector2 pos); DrawList.PathLineTo(pos); if (visible) { cullObject = false; } } diff --git a/SneakOnBy/packages.lock.json b/SneakOnBy/packages.lock.json index fd63291..6cf1c73 100644 --- a/SneakOnBy/packages.lock.json +++ b/SneakOnBy/packages.lock.json @@ -4,15 +4,9 @@ "net7.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[2.1.11, )", - "resolved": "2.1.11", - "contentHash": "9qlAWoRRTiL/geAvuwR/g6Bcbrd/bJJgVnB/RurBiyKs6srsP0bvpoo8IK+Eg8EA6jWeM6/YJWs66w4FIAzqPw==" - }, - "ECommons": { - "type": "Direct", - "requested": "[2.0.0.4, )", - "resolved": "2.0.0.4", - "contentHash": "joGkq0Y+K9da2TD/8/felotoTuqaUPjyKFjr2aeod77e28YMEmFrwVH+r91cU9X8hs50LEEp4QTzUnIrMJgcNw==" + "requested": "[2.1.12, )", + "resolved": "2.1.12", + "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" } } }