Add hook for dismount sounds..?

This commit is contained in:
Ottermandias 2023-05-05 16:17:53 +02:00
parent 6f6b72e7aa
commit 8e5ed60c79

View file

@ -47,6 +47,7 @@ public unsafe class AnimationHookService : IDisposable
_scheduleClipUpdateHook.Enable();
_unkMountAnimationHook.Enable();
_unkParasolAnimationHook.Enable();
_dismountHook.Enable();
}
public bool HandleFiles(ResourceType type, Utf8GamePath _, out ResolveData resolveData)
@ -103,6 +104,7 @@ public unsafe class AnimationHookService : IDisposable
_scheduleClipUpdateHook.Dispose();
_unkMountAnimationHook.Dispose();
_unkParasolAnimationHook.Dispose();
_dismountHook.Dispose();
}
/// <summary> Characters load some of their voice lines or whatever with this function. </summary>
@ -333,4 +335,30 @@ public unsafe class AnimationHookService : IDisposable
_unkParasolAnimationHook!.Original(drawObject, unk1);
_animationLoadData.Value = last;
}
[Signature("E8 ?? ?? ?? ?? F6 43 ?? ?? 74 ?? 48 8B CB", DetourName = nameof(DismountDetour))]
private readonly Hook<DismountDelegate> _dismountHook = null;
private delegate void DismountDelegate(nint a1, nint a2);
private void DismountDetour(nint a1, nint a2)
{
if (a1 == nint.Zero)
{
_dismountHook!.Original(a1, a2);
return;
}
var gameObject = *(GameObject**)(a1 + 8);
if (gameObject == null)
{
_dismountHook!.Original(a1, a2);
return;
}
var last = _animationLoadData.Value;
_animationLoadData.Value = _collectionResolver.IdentifyCollection(gameObject, true);
_dismountHook!.Original(a1, a2);
_animationLoadData.Value = last;
}
}