mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 14:23:43 +01:00
Move all meta hooks to own classes.
This commit is contained in:
parent
da019e729d
commit
68c782f0b9
11 changed files with 314 additions and 180 deletions
35
Penumbra/Interop/Hooks/Meta/SetupVisor.cs
Normal file
35
Penumbra/Interop/Hooks/Meta/SetupVisor.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
||||
namespace Penumbra.Interop.Hooks.Meta;
|
||||
|
||||
/// <summary>
|
||||
/// GMP. This gets called every time when changing visor state, and it accesses the gmp file itself,
|
||||
/// but it only applies a changed gmp file after a redraw for some reason.
|
||||
/// </summary>
|
||||
public sealed unsafe class SetupVisor : FastHook<SetupVisor.Delegate>
|
||||
{
|
||||
private readonly CollectionResolver _collectionResolver;
|
||||
private readonly MetaState _metaState;
|
||||
|
||||
public SetupVisor(HookManager hooks, CollectionResolver collectionResolver, MetaState metaState)
|
||||
{
|
||||
_collectionResolver = collectionResolver;
|
||||
_metaState = metaState;
|
||||
Task = hooks.CreateHook<Delegate>("Setup Visor", Sigs.SetupVisor, Detour, true);
|
||||
}
|
||||
|
||||
public delegate byte Delegate(DrawObject* drawObject, ushort modelId, byte visorState);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private byte Detour(DrawObject* drawObject, ushort modelId, byte visorState)
|
||||
{
|
||||
var collection = _collectionResolver.IdentifyCollection(drawObject, true);
|
||||
using var gmp = _metaState.ResolveGmpData(collection.ModCollection);
|
||||
var ret = Task.Result.Original.Invoke(drawObject, modelId, visorState);
|
||||
Penumbra.Log.Excessive($"[Setup Visor] Invoked on {(nint)drawObject:X} with {modelId}, {visorState} -> {ret}.");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue