mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-31 21:03:48 +01:00
Remove TryGetValue(MetaManipulation) from MetaDictionary.
This commit is contained in:
parent
5ca9e63a2a
commit
0445ed0ef9
11 changed files with 182 additions and 183 deletions
|
|
@ -2,6 +2,7 @@ using Penumbra.GameData.Enums;
|
|||
using Penumbra.GameData.Structs;
|
||||
using Penumbra.Interop.Services;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.String.Functions;
|
||||
|
||||
namespace Penumbra.Meta.Files;
|
||||
|
|
@ -126,4 +127,7 @@ public sealed unsafe class ExpandedEqdpFile : MetaBaseFile
|
|||
|
||||
public static EqdpEntry GetDefault(MetaFileManager manager, GenderRace raceCode, bool accessory, PrimaryId primaryId)
|
||||
=> GetDefault(manager, CharacterUtility.ReverseIndices[(int)CharacterUtilityData.EqdpIdx(raceCode, accessory)], primaryId);
|
||||
|
||||
public static EqdpEntry GetDefault(MetaFileManager manager, EqdpIdentifier identifier)
|
||||
=> GetDefault(manager, CharacterUtility.ReverseIndices[(int)identifier.FileIndex()], identifier.SetId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Penumbra.GameData.Structs;
|
||||
using Penumbra.Interop.Services;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.String.Functions;
|
||||
|
||||
namespace Penumbra.Meta.Files;
|
||||
|
|
@ -164,6 +165,9 @@ public sealed class ExpandedGmpFile : ExpandedEqpGmpBase, IEnumerable<GmpEntry>
|
|||
public static GmpEntry GetDefault(MetaFileManager manager, PrimaryId primaryIdx)
|
||||
=> new() { Value = GetDefaultInternal(manager, InternalIndex, primaryIdx, GmpEntry.Default.Value) };
|
||||
|
||||
public static GmpEntry GetDefault(MetaFileManager manager, GmpIdentifier identifier)
|
||||
=> new() { Value = GetDefaultInternal(manager, InternalIndex, identifier.SetId, GmpEntry.Default.Value) };
|
||||
|
||||
public void Reset(IEnumerable<PrimaryId> entries)
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
|
|
|
|||
|
|
@ -184,4 +184,7 @@ public sealed unsafe class EstFile : MetaBaseFile
|
|||
|
||||
public static EstEntry GetDefault(MetaFileManager manager, EstType estType, GenderRace genderRace, PrimaryId primaryId)
|
||||
=> GetDefault(manager, (MetaIndex)estType, genderRace, primaryId);
|
||||
|
||||
public static EstEntry GetDefault(MetaFileManager manager, EstIdentifier identifier)
|
||||
=> GetDefault(manager, identifier.FileIndex(), identifier.GenderRace, identifier.SetId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ public unsafe class ImcFile : MetaBaseFile
|
|||
return ptr == null ? new ImcEntry() : *ptr;
|
||||
}
|
||||
|
||||
public ImcEntry GetEntry(EquipSlot slot, Variant variantIdx)
|
||||
=> GetEntry(PartIndex(slot), variantIdx);
|
||||
|
||||
public ImcEntry GetEntry(int partIdx, Variant variantIdx, out bool exists)
|
||||
{
|
||||
var ptr = VariantPtr(Data, partIdx, variantIdx);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public readonly record struct EqdpIdentifier(PrimaryId SetId, EquipSlot Slot, Ge
|
|||
}
|
||||
}
|
||||
|
||||
public readonly record struct EqdpEntryInternal(bool Model, bool Material)
|
||||
public readonly record struct EqdpEntryInternal(bool Material, bool Model)
|
||||
{
|
||||
private EqdpEntryInternal((bool, bool) val)
|
||||
: this(val.Item1, val.Item2)
|
||||
|
|
@ -81,7 +81,6 @@ public readonly record struct EqdpEntryInternal(bool Model, bool Material)
|
|||
: this(entry.ToBits(slot))
|
||||
{ }
|
||||
|
||||
|
||||
public EqdpEntry ToEntry(EquipSlot slot)
|
||||
=> Eqdp.FromSlotAndBits(slot, Model, Material);
|
||||
=> Eqdp.FromSlotAndBits(slot, Material, Model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,19 @@ public sealed class MetaDictionary : IEnumerable<MetaManipulation>
|
|||
IEnumerator IEnumerable.GetEnumerator()
|
||||
=> GetEnumerator();
|
||||
|
||||
public bool Add(IMetaIdentifier identifier, object entry)
|
||||
=> identifier switch
|
||||
{
|
||||
EqdpIdentifier eqdpIdentifier => entry is EqdpEntryInternal e && Add(eqdpIdentifier, e),
|
||||
EqpIdentifier eqpIdentifier => entry is EqpEntryInternal e && Add(eqpIdentifier, e),
|
||||
EstIdentifier estIdentifier => entry is EstEntry e && Add(estIdentifier, e),
|
||||
GlobalEqpManipulation globalEqpManipulation => Add(globalEqpManipulation),
|
||||
GmpIdentifier gmpIdentifier => entry is GmpEntry e && Add(gmpIdentifier, e),
|
||||
ImcIdentifier imcIdentifier => entry is ImcEntry e && Add(imcIdentifier, e),
|
||||
RspIdentifier rspIdentifier => entry is RspEntry e && Add(rspIdentifier, e),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
public bool Add(MetaManipulation manip)
|
||||
{
|
||||
var ret = manip.ManipulationType switch
|
||||
|
|
@ -146,71 +159,23 @@ public sealed class MetaDictionary : IEnumerable<MetaManipulation>
|
|||
TryAdd(identifier);
|
||||
}
|
||||
|
||||
public bool TryGetValue(MetaManipulation identifier, out MetaManipulation oldValue)
|
||||
{
|
||||
switch (identifier.ManipulationType)
|
||||
{
|
||||
case MetaManipulation.Type.Imc:
|
||||
if (_imc.TryGetValue(identifier.Imc.Identifier, out var oldImc))
|
||||
{
|
||||
oldValue = new MetaManipulation(new ImcManipulation(identifier.Imc.Identifier, oldImc));
|
||||
return true;
|
||||
}
|
||||
public bool TryGetValue(EstIdentifier identifier, out EstEntry value)
|
||||
=> _est.TryGetValue(identifier, out value);
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Eqdp:
|
||||
if (_eqp.TryGetValue(identifier.Eqp.Identifier, out var oldEqdp))
|
||||
{
|
||||
oldValue = new MetaManipulation(new EqpManipulation(identifier.Eqp.Identifier, oldEqdp.ToEntry(identifier.Eqp.Slot)));
|
||||
return true;
|
||||
}
|
||||
public bool TryGetValue(EqpIdentifier identifier, out EqpEntryInternal value)
|
||||
=> _eqp.TryGetValue(identifier, out value);
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Eqp:
|
||||
if (_eqdp.TryGetValue(identifier.Eqdp.Identifier, out var oldEqp))
|
||||
{
|
||||
oldValue = new MetaManipulation(new EqdpManipulation(identifier.Eqdp.Identifier, oldEqp.ToEntry(identifier.Eqdp.Slot)));
|
||||
return true;
|
||||
}
|
||||
public bool TryGetValue(EqdpIdentifier identifier, out EqdpEntryInternal value)
|
||||
=> _eqdp.TryGetValue(identifier, out value);
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Est:
|
||||
if (_est.TryGetValue(identifier.Est.Identifier, out var oldEst))
|
||||
{
|
||||
oldValue = new MetaManipulation(new EstManipulation(identifier.Est.Identifier, oldEst));
|
||||
return true;
|
||||
}
|
||||
public bool TryGetValue(GmpIdentifier identifier, out GmpEntry value)
|
||||
=> _gmp.TryGetValue(identifier, out value);
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Gmp:
|
||||
if (_gmp.TryGetValue(identifier.Gmp.Identifier, out var oldGmp))
|
||||
{
|
||||
oldValue = new MetaManipulation(new GmpManipulation(identifier.Gmp.Identifier, oldGmp));
|
||||
return true;
|
||||
}
|
||||
public bool TryGetValue(RspIdentifier identifier, out RspEntry value)
|
||||
=> _rsp.TryGetValue(identifier, out value);
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Rsp:
|
||||
if (_rsp.TryGetValue(identifier.Rsp.Identifier, out var oldRsp))
|
||||
{
|
||||
oldValue = new MetaManipulation(new RspManipulation(identifier.Rsp.Identifier, oldRsp));
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.GlobalEqp:
|
||||
if (_globalEqp.TryGetValue(identifier.GlobalEqp, out var oldGlobalEqp))
|
||||
{
|
||||
oldValue = new MetaManipulation(oldGlobalEqp);
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
oldValue = default;
|
||||
return false;
|
||||
}
|
||||
public bool TryGetValue(ImcIdentifier identifier, out ImcEntry value)
|
||||
=> _imc.TryGetValue(identifier, out value);
|
||||
|
||||
public void SetTo(MetaDictionary other)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue