diff --git a/Penumbra/Meta/Files/EqpGmpFile.cs b/Penumbra/Meta/Files/EqpGmpFile.cs index c85799a6..0a7fe90f 100644 --- a/Penumbra/Meta/Files/EqpGmpFile.cs +++ b/Penumbra/Meta/Files/EqpGmpFile.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; @@ -109,7 +110,7 @@ public unsafe class ExpandedEqpGmpBase : MetaBaseFile } } -public sealed class ExpandedEqpFile : ExpandedEqpGmpBase +public sealed class ExpandedEqpFile : ExpandedEqpGmpBase, IEnumerable { public ExpandedEqpFile() : base( false ) @@ -121,6 +122,7 @@ public sealed class ExpandedEqpFile : ExpandedEqpGmpBase set => SetInternal( idx, ( ulong )value ); } + public static EqpEntry GetDefault( int setIdx ) => ( EqpEntry )GetDefaultInternal( CharacterUtility.EqpIdx, setIdx, ( ulong )Eqp.DefaultEntry ); @@ -141,9 +143,18 @@ public sealed class ExpandedEqpFile : ExpandedEqpGmpBase this[ entry ] = GetDefault( entry ); } } + + public IEnumerator< EqpEntry > GetEnumerator() + { + for( var idx = 1; idx < Count; ++idx ) + yield return this[ idx ]; + } + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } -public sealed class ExpandedGmpFile : ExpandedEqpGmpBase +public sealed class ExpandedGmpFile : ExpandedEqpGmpBase, IEnumerable { public ExpandedGmpFile() : base( true ) @@ -165,4 +176,13 @@ public sealed class ExpandedGmpFile : ExpandedEqpGmpBase this[ entry ] = GetDefault( entry ); } } + + public IEnumerator GetEnumerator() + { + for( var idx = 1; idx < Count; ++idx ) + yield return this[idx]; + } + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } \ No newline at end of file diff --git a/Penumbra/Meta/Manager/MetaManager.cs b/Penumbra/Meta/Manager/MetaManager.cs index 6bec0c19..7f83e98f 100644 --- a/Penumbra/Meta/Manager/MetaManager.cs +++ b/Penumbra/Meta/Manager/MetaManager.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Dalamud.Logging; using Penumbra.Collections; using Penumbra.Meta.Files; using Penumbra.Meta.Manipulations; @@ -76,6 +77,11 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM public bool ApplyMod( MetaManipulation manip, IMod mod ) { + if( _manipulations.ContainsKey( manip ) ) + { + _manipulations.Remove( manip ); + } + _manipulations[ manip ] = mod; // Imc manipulations do not require character utility. if( manip.ManipulationType == MetaManipulation.Type.Imc ) @@ -134,9 +140,10 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM return; } + var loaded = 0; foreach( var manip in Manipulations.Where( m => m.ManipulationType != MetaManipulation.Type.Imc ) ) { - var _ = manip.ManipulationType switch + loaded += manip.ManipulationType switch { MetaManipulation.Type.Eqp => ApplyMod( manip.Eqp ), MetaManipulation.Type.Gmp => ApplyMod( manip.Gmp ), @@ -145,7 +152,9 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM MetaManipulation.Type.Rsp => ApplyMod( manip.Rsp ), MetaManipulation.Type.Unknown => false, _ => false, - }; + } + ? 1 + : 0; } if( Penumbra.CollectionManager.Default == _collection ) @@ -155,6 +164,7 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM } Penumbra.CharacterUtility.LoadingFinished -= ApplyStoredManipulations; + PluginLog.Debug( "{Collection}: Loaded {Num} delayed meta manipulations.", _collection.Name, loaded ); } [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )]