Check Yourself assignment for special actors.

This commit is contained in:
Ottermandias 2022-12-03 17:07:01 +01:00
parent 114ed5954e
commit bfddcdd7e2
4 changed files with 20 additions and 19 deletions

View file

@ -333,7 +333,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
public (string, bool) GetCharacterCollection( string characterName, ushort worldId ) public (string, bool) GetCharacterCollection( string characterName, ushort worldId )
{ {
CheckInitialized(); 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 ) ? ( collection.Name, true )
: ( Penumbra.CollectionManager.Default.Name, false ); : ( Penumbra.CollectionManager.Default.Name, false );
} }
@ -807,7 +807,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
{ {
CheckInitialized(); CheckInitialized();
var identifier = NameToIdentifier( characterName, worldId ); 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 ? c
: Penumbra.CollectionManager.Individual( identifier ); : Penumbra.CollectionManager.Individual( identifier );
var set = collection.MetaCache?.Manipulations.ToArray() ?? Array.Empty< MetaManipulation >(); var set = collection.MetaCache?.Manipulations.ToArray() ?? Array.Empty< MetaManipulation >();

View file

@ -42,7 +42,7 @@ public partial class ModCollection
public readonly IndividualCollections Individuals = new(Penumbra.Actors); public readonly IndividualCollections Individuals = new(Penumbra.Actors);
public ModCollection Individual( ActorIdentifier identifier ) public ModCollection Individual( ActorIdentifier identifier )
=> Individuals.TryGetCollection( identifier, out var c ) ? c : Default; => Individuals.TryGetCollection( identifier, out var c, out _ ) ? c : Default;
// Special Collections // Special Collections
private readonly ModCollection?[] _specialCollections = new ModCollection?[Enum.GetValues< CollectionType >().Length - 4]; private readonly ModCollection?[] _specialCollections = new ModCollection?[Enum.GetValues< CollectionType >().Length - 4];
@ -64,7 +64,7 @@ public partial class ModCollection
CollectionType.Default => Default, CollectionType.Default => Default,
CollectionType.Interface => Interface, CollectionType.Interface => Interface,
CollectionType.Current => Current, 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, _ => null,
}; };
} }

View file

@ -23,8 +23,9 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ
public (string DisplayName, ModCollection Collection) this[ int index ] public (string DisplayName, ModCollection Collection) this[ int index ]
=> ( _assignments[ index ].DisplayName, _assignments[ index ].Collection ); => ( _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 ) switch( identifier.Type )
{ {
case IdentifierType.Player: return CheckWorlds( identifier, out collection ); 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.FittingRoom when Penumbra.Config.UseCharacterCollectionInTryOn:
case SpecialActor.DyePreview when Penumbra.Config.UseCharacterCollectionInTryOn: case SpecialActor.DyePreview when Penumbra.Config.UseCharacterCollectionInTryOn:
case SpecialActor.Portrait when Penumbra.Config.UseCharacterCollectionsInCards: case SpecialActor.Portrait when Penumbra.Config.UseCharacterCollectionsInCards:
return CheckWorlds( _actorManager.GetCurrentPlayer(), out collection ); return CheckWorlds( specialIdentifier = _actorManager.GetCurrentPlayer(), out collection );
case SpecialActor.ExamineScreen: case SpecialActor.ExamineScreen:
{ {
return CheckWorlds( _actorManager.GetInspectPlayer(), out collection! ) return CheckWorlds( specialIdentifier = _actorManager.GetInspectPlayer(), out collection! )
|| CheckWorlds( _actorManager.GetCardPlayer(), out collection! ) || CheckWorlds( specialIdentifier = _actorManager.GetCardPlayer(), out collection! )
|| CheckWorlds( _actorManager.GetGlamourPlayer(), out collection! ); || CheckWorlds( specialIdentifier = _actorManager.GetGlamourPlayer(), out collection! );
} }
} }
@ -89,11 +90,11 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ
return false; return false;
} }
public bool TryGetCollection( GameObject? gameObject, out ModCollection? collection ) public bool TryGetCollection( GameObject? gameObject, out ModCollection? collection, out ActorIdentifier specialIdentifier )
=> TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection ); => TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection, out specialIdentifier );
public unsafe bool TryGetCollection( FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* gameObject, out ModCollection? 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 ); => TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection, out specialIdentifier );
private bool CheckWorlds( ActorIdentifier identifier, out ModCollection? collection ) private bool CheckWorlds( ActorIdentifier identifier, out ModCollection? collection )
{ {

View file

@ -44,8 +44,8 @@ public unsafe partial class PathResolver
else else
{ {
var identifier = Penumbra.Actors.FromObject( gameObject, false ); var identifier = Penumbra.Actors.FromObject( gameObject, false );
var collection = CollectionByIdentifier( identifier ) var collection = CollectionByIdentifier( identifier, out var specialIdentifier )
?? CheckYourself( identifier, gameObject ) ?? CheckYourself( identifier.Type == IdentifierType.Special ? specialIdentifier : identifier, gameObject )
?? CollectionByAttributes( gameObject ) ?? CollectionByAttributes( gameObject )
?? CheckOwnedCollection( identifier, gameObject ) ?? CheckOwnedCollection( identifier, gameObject )
?? Penumbra.CollectionManager.Default; ?? Penumbra.CollectionManager.Default;
@ -71,16 +71,16 @@ public unsafe partial class PathResolver
} }
var player = Penumbra.Actors.GetCurrentPlayer(); var player = Penumbra.Actors.GetCurrentPlayer();
return CollectionByIdentifier( player ) return CollectionByIdentifier( player, out _ )
?? CheckYourself( player, gameObject ) ?? CheckYourself( player, gameObject )
?? CollectionByAttributes( gameObject ) ?? CollectionByAttributes( gameObject )
?? Penumbra.CollectionManager.Default; ?? Penumbra.CollectionManager.Default;
} }
// Check both temporary and permanent character collections. Temporary first. // Check both temporary and permanent character collections. Temporary first.
private static ModCollection? CollectionByIdentifier( ActorIdentifier identifier ) private static ModCollection? CollectionByIdentifier( ActorIdentifier identifier, out ActorIdentifier specialIdentifier )
=> Penumbra.TempMods.Collections.TryGetCollection( identifier, out var collection ) => Penumbra.TempMods.Collections.TryGetCollection( identifier, out var collection, out specialIdentifier )
|| Penumbra.CollectionManager.Individuals.TryGetCollection( identifier, out collection ) || Penumbra.CollectionManager.Individuals.TryGetCollection( identifier, out collection, out specialIdentifier )
? collection ? collection
: null; : null;