Add another hook for animations in character collections.

This commit is contained in:
Ottermandias 2022-06-18 14:23:28 +02:00
parent 58e46accae
commit df1a75b58a
3 changed files with 33 additions and 1 deletions

View file

@ -72,4 +72,25 @@ public unsafe partial class PathResolver
_animationLoadCollection = last;
return ret;
}
public delegate void LoadSomePap( IntPtr a1, int a2, IntPtr a3, int a4 );
[Signature( "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC ?? 41 8B D9 89 51" )]
public Hook< LoadSomePap >? LoadSomePapHook;
private void LoadSomePapDetour( IntPtr a1, int a2, IntPtr a3, int a4 )
{
var timelinePtr = a1 + 0x50;
var last = _animationLoadCollection;
if( timelinePtr != IntPtr.Zero )
{
var actorIdx = ( int )( *( *( ulong** )timelinePtr + 1 ) >> 3 );
if( actorIdx >= 0 && actorIdx < Dalamud.Objects.Length )
{
_animationLoadCollection = IdentifyCollection( ( GameObject* )( Dalamud.Objects[ actorIdx ]?.Address ?? IntPtr.Zero ) );
}
}
LoadSomePapHook!.Original( a1, a2, a3, a4 );
_animationLoadCollection = last;
}
}

View file

@ -93,6 +93,7 @@ public unsafe partial class PathResolver
LoadTimelineResourcesHook?.Enable();
CharacterBaseLoadAnimationHook?.Enable();
LoadSomeAvfxHook?.Enable();
LoadSomePapHook?.Enable();
}
private void DisableDataHooks()
@ -105,6 +106,7 @@ public unsafe partial class PathResolver
LoadTimelineResourcesHook?.Disable();
CharacterBaseLoadAnimationHook?.Disable();
LoadSomeAvfxHook?.Disable();
LoadSomePapHook?.Disable();
}
private void DisposeDataHooks()
@ -116,6 +118,7 @@ public unsafe partial class PathResolver
LoadTimelineResourcesHook?.Dispose();
CharacterBaseLoadAnimationHook?.Dispose();
LoadSomeAvfxHook?.Dispose();
LoadSomePapHook?.Dispose();
}
// This map links DrawObjects directly to Actors (by ObjectTable index) and their collections.
@ -272,8 +275,12 @@ public unsafe partial class PathResolver
}
// Housing Retainers
if( Penumbra.Config.UseDefaultCollectionForRetainers && gameObject->ObjectKind == (byte) ObjectKind.EventNpc && gameObject->DataID == 1011832 )
if( Penumbra.Config.UseDefaultCollectionForRetainers
&& gameObject->ObjectKind == ( byte )ObjectKind.EventNpc
&& gameObject->DataID == 1011832 )
{
return Penumbra.CollectionManager.Default;
}
string? actorName = null;
if( Penumbra.Config.PreferNamedCollectionsOverOwners )

View file

@ -76,6 +76,9 @@ public partial class PathResolver : IDisposable
private bool HandleAnimationFile( ResourceType type, Utf8GamePath _, [NotNullWhen(true)] out ModCollection? collection )
{
if( type == ResourceType.Pap && _.Path.EndsWith( '0', '1', '0', '.', 'p', 'a', 'p' ) )
PluginLog.Information( $"PAPPITY PAP {_}" );
if( _animationLoadCollection != null )
{
switch( type )
@ -84,6 +87,7 @@ public partial class PathResolver : IDisposable
case ResourceType.Pap:
case ResourceType.Avfx:
case ResourceType.Atex:
case ResourceType.Scd:
collection = _animationLoadCollection;
return true;
}