Handle ownership in gpose / cutscenes better.

This commit is contained in:
Ottermandias 2022-12-04 01:35:11 +01:00
parent 882a59c1bf
commit 2b6275fe67
3 changed files with 29 additions and 29 deletions

View file

@ -26,6 +26,12 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ
public bool TryGetCollection( ActorIdentifier identifier, [NotNullWhen( true )] out ModCollection? collection, out ActorIdentifier specialIdentifier )
{
specialIdentifier = ActorIdentifier.Invalid;
if( Count == 0 )
{
collection = null;
return false;
}
switch( identifier.Type )
{
case IdentifierType.Player: return CheckWorlds( identifier, out collection );
@ -94,7 +100,7 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ
=> TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection, out specialIdentifier );
public unsafe bool TryGetCollection( FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* gameObject, out ModCollection? collection, out ActorIdentifier specialIdentifier )
=> TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection, out specialIdentifier );
=> TryGetCollection( _actorManager.FromObject( gameObject, out _, false ), out collection, out specialIdentifier );
private bool CheckWorlds( ActorIdentifier identifier, out ModCollection? collection )
{

View file

@ -43,11 +43,11 @@ public unsafe partial class PathResolver
}
else
{
var identifier = Penumbra.Actors.FromObject( gameObject, false );
var identifier = Penumbra.Actors.FromObject( gameObject, out var owner, false );
var collection = CollectionByIdentifier( identifier, out var specialIdentifier )
?? CheckYourself( identifier.Type == IdentifierType.Special ? specialIdentifier : identifier, gameObject )
?? CollectionByAttributes( gameObject )
?? CheckOwnedCollection( identifier, gameObject )
?? CheckOwnedCollection( identifier, owner )
?? Penumbra.CollectionManager.Default;
return IdentifiedCache.Set( collection, identifier, gameObject );
}
@ -124,23 +124,9 @@ public unsafe partial class PathResolver
}
// Get the collection applying to the owner if it is available.
private static ModCollection? CheckOwnedCollection( ActorIdentifier identifier, GameObject* obj )
private static ModCollection? CheckOwnedCollection( ActorIdentifier identifier, GameObject* owner )
{
if( identifier.Type != IdentifierType.Owned || !Penumbra.Config.UseOwnerNameForCharacterCollection )
{
return null;
}
var owner = identifier.Kind switch
{
ObjectKind.BattleNpc when obj->OwnerID != 0xE0000000 => ( GameObject* )( Dalamud.Objects.SearchById( obj->OwnerID )?.Address ?? IntPtr.Zero ),
ObjectKind.MountType when obj->ObjectIndex % 2 == 1 => ( GameObject* )Dalamud.Objects.GetObjectAddress( obj->ObjectIndex - 1 ),
ObjectKind.Companion when obj->ObjectIndex % 2 == 1 => ( GameObject* )Dalamud.Objects.GetObjectAddress( obj->ObjectIndex - 1 ),
( ObjectKind )15 when obj->ObjectIndex % 2 == 1 => ( GameObject* )Dalamud.Objects.GetObjectAddress( obj->ObjectIndex - 1 ), // TODO: CS Update
_ => null,
};
if( owner == null )
if( identifier.Type != IdentifierType.Owned || !Penumbra.Config.UseOwnerNameForCharacterCollection || owner == null )
{
return null;
}