diff --git a/Penumbra/Api/PenumbraApi.cs b/Penumbra/Api/PenumbraApi.cs index 49ad61cd..d9e92eda 100644 --- a/Penumbra/Api/PenumbraApi.cs +++ b/Penumbra/Api/PenumbraApi.cs @@ -333,7 +333,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi public (string, bool) GetCharacterCollection( string characterName, ushort worldId ) { CheckInitialized(); - return Penumbra.CollectionManager.Individuals.TryGetCollection( NameToIdentifier( characterName, worldId ), out var collection ) + return Penumbra.CollectionManager.Individuals.TryGetCollection( NameToIdentifier( characterName, worldId ), out var collection, out _ ) ? ( collection.Name, true ) : ( Penumbra.CollectionManager.Default.Name, false ); } @@ -807,7 +807,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi { CheckInitialized(); var identifier = NameToIdentifier( characterName, worldId ); - var collection = Penumbra.TempMods.Collections.TryGetCollection( identifier, out var c ) + var collection = Penumbra.TempMods.Collections.TryGetCollection( identifier, out var c, out _ ) ? c : Penumbra.CollectionManager.Individual( identifier ); var set = collection.MetaCache?.Manipulations.ToArray() ?? Array.Empty< MetaManipulation >(); diff --git a/Penumbra/Collections/CollectionManager.Active.cs b/Penumbra/Collections/CollectionManager.Active.cs index 355c9297..7f23eae0 100644 --- a/Penumbra/Collections/CollectionManager.Active.cs +++ b/Penumbra/Collections/CollectionManager.Active.cs @@ -42,7 +42,7 @@ public partial class ModCollection public readonly IndividualCollections Individuals = new(Penumbra.Actors); public ModCollection Individual( ActorIdentifier identifier ) - => Individuals.TryGetCollection( identifier, out var c ) ? c : Default; + => Individuals.TryGetCollection( identifier, out var c, out _ ) ? c : Default; // Special Collections private readonly ModCollection?[] _specialCollections = new ModCollection?[Enum.GetValues< CollectionType >().Length - 4]; @@ -64,7 +64,7 @@ public partial class ModCollection CollectionType.Default => Default, CollectionType.Interface => Interface, CollectionType.Current => Current, - CollectionType.Individual => identifier.IsValid ? Individuals.TryGetCollection( identifier, out var c ) ? c : null : null, + CollectionType.Individual => identifier.IsValid ? Individuals.TryGetCollection( identifier, out var c, out _ ) ? c : null : null, _ => null, }; } diff --git a/Penumbra/Collections/IndividualCollections.Access.cs b/Penumbra/Collections/IndividualCollections.Access.cs index 01858010..142b9131 100644 --- a/Penumbra/Collections/IndividualCollections.Access.cs +++ b/Penumbra/Collections/IndividualCollections.Access.cs @@ -23,8 +23,9 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ public (string DisplayName, ModCollection Collection) this[ int index ] => ( _assignments[ index ].DisplayName, _assignments[ index ].Collection ); - public bool TryGetCollection( ActorIdentifier identifier, [NotNullWhen( true )] out ModCollection? collection ) + public bool TryGetCollection( ActorIdentifier identifier, [NotNullWhen( true )] out ModCollection? collection, out ActorIdentifier specialIdentifier ) { + specialIdentifier = ActorIdentifier.Invalid; switch( identifier.Type ) { case IdentifierType.Player: return CheckWorlds( identifier, out collection ); @@ -73,12 +74,12 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ case SpecialActor.FittingRoom when Penumbra.Config.UseCharacterCollectionInTryOn: case SpecialActor.DyePreview when Penumbra.Config.UseCharacterCollectionInTryOn: case SpecialActor.Portrait when Penumbra.Config.UseCharacterCollectionsInCards: - return CheckWorlds( _actorManager.GetCurrentPlayer(), out collection ); + return CheckWorlds( specialIdentifier = _actorManager.GetCurrentPlayer(), out collection ); case SpecialActor.ExamineScreen: { - return CheckWorlds( _actorManager.GetInspectPlayer(), out collection! ) - || CheckWorlds( _actorManager.GetCardPlayer(), out collection! ) - || CheckWorlds( _actorManager.GetGlamourPlayer(), out collection! ); + return CheckWorlds( specialIdentifier = _actorManager.GetInspectPlayer(), out collection! ) + || CheckWorlds( specialIdentifier = _actorManager.GetCardPlayer(), out collection! ) + || CheckWorlds( specialIdentifier = _actorManager.GetGlamourPlayer(), out collection! ); } } @@ -89,11 +90,11 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ return false; } - public bool TryGetCollection( GameObject? gameObject, out ModCollection? collection ) - => TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection ); + public bool TryGetCollection( GameObject? gameObject, out ModCollection? collection, out ActorIdentifier specialIdentifier ) + => TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection, out specialIdentifier ); - public unsafe bool TryGetCollection( FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* gameObject, out ModCollection? collection ) - => TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection ); + 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 ); private bool CheckWorlds( ActorIdentifier identifier, out ModCollection? collection ) { diff --git a/Penumbra/Interop/Resolver/PathResolver.Identification.cs b/Penumbra/Interop/Resolver/PathResolver.Identification.cs index 868e08a8..f1d704f1 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Identification.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Identification.cs @@ -44,8 +44,8 @@ public unsafe partial class PathResolver else { var identifier = Penumbra.Actors.FromObject( gameObject, false ); - var collection = CollectionByIdentifier( identifier ) - ?? CheckYourself( identifier, gameObject ) + var collection = CollectionByIdentifier( identifier, out var specialIdentifier ) + ?? CheckYourself( identifier.Type == IdentifierType.Special ? specialIdentifier : identifier, gameObject ) ?? CollectionByAttributes( gameObject ) ?? CheckOwnedCollection( identifier, gameObject ) ?? Penumbra.CollectionManager.Default; @@ -71,16 +71,16 @@ public unsafe partial class PathResolver } var player = Penumbra.Actors.GetCurrentPlayer(); - return CollectionByIdentifier( player ) + return CollectionByIdentifier( player, out _ ) ?? CheckYourself( player, gameObject ) ?? CollectionByAttributes( gameObject ) ?? Penumbra.CollectionManager.Default; } // Check both temporary and permanent character collections. Temporary first. - private static ModCollection? CollectionByIdentifier( ActorIdentifier identifier ) - => Penumbra.TempMods.Collections.TryGetCollection( identifier, out var collection ) - || Penumbra.CollectionManager.Individuals.TryGetCollection( identifier, out collection ) + private static ModCollection? CollectionByIdentifier( ActorIdentifier identifier, out ActorIdentifier specialIdentifier ) + => Penumbra.TempMods.Collections.TryGetCollection( identifier, out var collection, out specialIdentifier ) + || Penumbra.CollectionManager.Individuals.TryGetCollection( identifier, out collection, out specialIdentifier ) ? collection : null;