mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-30 20:33:43 +01:00
Move all animation and game event hooks to own classes.
This commit is contained in:
parent
81cdcad72e
commit
da019e729d
62 changed files with 1402 additions and 1143 deletions
49
Penumbra/Interop/Hooks/CharacterBaseDestructor.cs
Normal file
49
Penumbra/Interop/Hooks/CharacterBaseDestructor.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using Dalamud.Hooking;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Classes;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.UI.AdvancedWindow;
|
||||
|
||||
namespace Penumbra.Interop.Hooks;
|
||||
|
||||
public sealed unsafe class CharacterBaseDestructor : EventWrapperPtr<CharacterBase, CharacterBaseDestructor.Priority>, IHookService
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
/// <seealso cref="PathResolving.DrawObjectState"/>
|
||||
DrawObjectState = 0,
|
||||
|
||||
/// <seealso cref="ModEditWindow.MtrlTab"/>
|
||||
MtrlTab = -1000,
|
||||
}
|
||||
|
||||
public CharacterBaseDestructor(HookManager hooks)
|
||||
: base("Destroy CharacterBase")
|
||||
=> _task = hooks.CreateHook<Delegate>(Name, Address, Detour, true);
|
||||
|
||||
private readonly Task<Hook<Delegate>> _task;
|
||||
|
||||
public nint Address
|
||||
=> (nint)CharacterBase.MemberFunctionPointers.Destroy;
|
||||
|
||||
public void Enable()
|
||||
=> _task.Result.Enable();
|
||||
|
||||
public void Disable()
|
||||
=> _task.Result.Disable();
|
||||
|
||||
public Task Awaiter
|
||||
=> _task;
|
||||
|
||||
public bool Finished
|
||||
=> _task.IsCompletedSuccessfully;
|
||||
|
||||
private delegate nint Delegate(CharacterBase* characterBase);
|
||||
|
||||
private nint Detour(CharacterBase* characterBase)
|
||||
{
|
||||
Penumbra.Log.Verbose($"[{Name}] Triggered with 0x{(nint)characterBase:X}.");
|
||||
Invoke(characterBase);
|
||||
return _task.Result.Original(characterBase);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue