Skip to content

Commit

Permalink
update to API 9
Browse files Browse the repository at this point in the history
  • Loading branch information
McSwindler committed Nov 2, 2023
1 parent dd128be commit e2728cd
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 30 deletions.
2 changes: 0 additions & 2 deletions SneakOnBy/DeepDungeonDex.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions SneakOnBy/ECommons
Submodule ECommons added at 04127e
22 changes: 17 additions & 5 deletions SneakOnBy/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Dalamud.Interface.Windowing;
using SneakOnBy.Windows;
using ECommons;
using Dalamud.Plugin.Services;
using ECommons.Reflection;

namespace SneakOnBy
{
Expand All @@ -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");

Expand All @@ -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);
Expand All @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions SneakOnBy/Services.cs
Original file line number Diff line number Diff line change
@@ -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<Services>();

// @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

}
3 changes: 1 addition & 2 deletions SneakOnBy/SneakOnBy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.11" />
<PackageReference Include="ECommons" Version="2.0.0.4" />
<PackageReference Include="DalamudPackager" Version="2.1.12" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 5 additions & 10 deletions SneakOnBy/Windows/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions SneakOnBy/Windows/ConvexShape.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using ECommons.DalamudServices;
using System.Numerics;
using ImGuiNET;
using System;
Expand Down Expand Up @@ -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; }
}
Expand Down
12 changes: 3 additions & 9 deletions SneakOnBy/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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=="
}
}
}
Expand Down

0 comments on commit e2728cd

Please sign in to comment.