diff --git a/Craftimizer/SimulatorUtils.cs b/Craftimizer/SimulatorUtils.cs index 7637d45..f0476cd 100644 --- a/Craftimizer/SimulatorUtils.cs +++ b/Craftimizer/SimulatorUtils.cs @@ -15,6 +15,7 @@ using Lumina.Text.ReadOnly; using Lumina.Text.Payloads; using Lumina.Excel.Sheets; using Dalamud.Utility; +using FFXIVClientStructs.FFXIV.Client.Game.Event; namespace Craftimizer.Plugin; @@ -54,7 +55,7 @@ internal static class ActionUtils r.Icon == baseAction.Icon && r.ActionCategory.RowId == baseAction.ActionCategory.RowId && r.Name.Equals(baseAction.Name)); - + foreach (var classJob in classJobs) ActionRows[(int)actionType, (int)classJob] = (null, possibleActions.First(r => r.ClassJobCategory.ValueNullable?.IsClassJob(classJob) ?? false)); } @@ -144,7 +145,7 @@ internal static class ClassJobUtils public static unsafe ushort GetWKSSyncedLevel(this ClassJob me) { var jobLevel = (ushort)me.GetPlayerLevel(); - var handler = CSCraftEventHandler.Instance(); + var handler = EventFramework.Instance()->GetCraftEventHandler(); if (handler != null) { for (var i = 0; i < 2; ++i) diff --git a/Craftimizer/Utils/CSCraftEventHandler.cs b/Craftimizer/Utils/CSCraftEventHandler.cs deleted file mode 100644 index 93dca36..0000000 --- a/Craftimizer/Utils/CSCraftEventHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FFXIVClientStructs.FFXIV.Client.Game.Event; -using System.Runtime.InteropServices; - -namespace Craftimizer.Utils; - -[StructLayout(LayoutKind.Explicit)] -public unsafe struct CSCraftEventHandler -{ - [FieldOffset(0x48A)] public unsafe fixed ushort WKSClassLevels[2]; - [FieldOffset(0x48E)] public unsafe fixed byte WKSClassJobs[2]; - - public static CSCraftEventHandler* Instance() - { - return (CSCraftEventHandler*)EventFramework.Instance()->GetCraftEventHandler(); - } -} diff --git a/Craftimizer/Utils/CSRecipeNote.cs b/Craftimizer/Utils/CSRecipeNote.cs index 7d26272..8a1988c 100644 --- a/Craftimizer/Utils/CSRecipeNote.cs +++ b/Craftimizer/Utils/CSRecipeNote.cs @@ -1,4 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI; +using FFXIVClientStructs.FFXIV.Client.System.String; using System.Runtime.InteropServices; namespace Craftimizer.Utils; @@ -12,4 +13,29 @@ public unsafe struct CSRecipeNote { return (CSRecipeNote*)RecipeNote.Instance(); } + + [StructLayout(LayoutKind.Explicit, Size = 136)] + public struct RecipeIngredient + { + [FieldOffset(8)] + public byte NQCount; + + [FieldOffset(9)] + public byte HQCount; + + [FieldOffset(16)] + public Utf8String Name; + + [FieldOffset(120)] + public uint ItemId; + + [FieldOffset(124)] + public uint IconId; + + [FieldOffset(130)] + public byte Amount; + + [FieldOffset(131)] + public byte Flags; + } } diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index 9fa1b4a..2782de5 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -30,6 +30,7 @@ using System.Runtime.InteropServices; using ActionType = Craftimizer.Simulator.Actions.ActionType; using ClassJob = Craftimizer.Simulator.ClassJob; using CSRecipeNote = FFXIVClientStructs.FFXIV.Client.Game.UI.RecipeNote; +using RecipeIngredient2 = Craftimizer.Utils.CSRecipeNote.RecipeIngredient; namespace Craftimizer.Windows; @@ -312,31 +313,6 @@ public sealed unsafe class RecipeNote : Window, IDisposable return true; } - [StructLayout(LayoutKind.Explicit, Size = 136)] - public struct RecipeIngredient2 - { - [FieldOffset(8)] - public byte NQCount; - - [FieldOffset(9)] - public byte HQCount; - - [FieldOffset(16)] - public Utf8String Name; - - [FieldOffset(120)] - public uint ItemId; - - [FieldOffset(124)] - public uint IconId; - - [FieldOffset(130)] - public byte Amount; - - [FieldOffset(131)] - public byte Flags; - } - private IEnumerable CalculateIngredientHqCounts() { if (RecipeData == null)