mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-19 22:37:46 +01:00
Add support for imc-toggle attributes to accessories, and fix up attributes when item swapping models.
This commit is contained in:
parent
c0aa2e36ea
commit
a953febfba
2 changed files with 112 additions and 1 deletions
|
|
@ -234,9 +234,56 @@ public static class EquipmentSwap
|
|||
mdl.ChildSwaps.Add(mtrl);
|
||||
}
|
||||
|
||||
FixAttributes(mdl, slotFrom, slotTo);
|
||||
|
||||
return mdl;
|
||||
}
|
||||
|
||||
private static void FixAttributes(FileSwap swap, EquipSlot slotFrom, EquipSlot slotTo)
|
||||
{
|
||||
if (slotFrom == slotTo)
|
||||
return;
|
||||
|
||||
var needle = slotTo switch
|
||||
{
|
||||
EquipSlot.Head => "atr_mv_",
|
||||
EquipSlot.Ears => "atr_ev_",
|
||||
EquipSlot.Neck => "atr_nv_",
|
||||
EquipSlot.Wrists => "atr_wv_",
|
||||
EquipSlot.RFinger or EquipSlot.LFinger => "atr_rv_",
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
var replacement = slotFrom switch
|
||||
{
|
||||
EquipSlot.Head => 'm',
|
||||
EquipSlot.Ears => 'e',
|
||||
EquipSlot.Neck => 'n',
|
||||
EquipSlot.Wrists => 'w',
|
||||
EquipSlot.RFinger or EquipSlot.LFinger => 'r',
|
||||
_ => 'm',
|
||||
};
|
||||
|
||||
var attributes = swap.AsMdl()!.Attributes;
|
||||
for (var i = 0; i < attributes.Length; ++i)
|
||||
{
|
||||
if (FixAttribute(ref attributes[i], needle, replacement))
|
||||
swap.DataWasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe bool FixAttribute(ref string attribute, string from, char to)
|
||||
{
|
||||
if (!attribute.StartsWith(from) || attribute.Length != from.Length + 1 || attribute[^1] is < 'a' or > 'j')
|
||||
return false;
|
||||
|
||||
Span<char> stack = stackalloc char[attribute.Length];
|
||||
attribute.CopyTo(stack);
|
||||
stack[4] = to;
|
||||
attribute = new string(stack);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void LookupItem(EquipItem i, out EquipSlot slot, out PrimaryId modelId, out Variant variant)
|
||||
{
|
||||
slot = i.Type.ToSlot();
|
||||
|
|
@ -399,7 +446,7 @@ public static class EquipmentSwap
|
|||
return null;
|
||||
|
||||
var folderTo = GamePaths.Mtrl.GearFolder(slotTo, idTo, variantTo);
|
||||
var pathTo = $"{folderTo}{fileName}";
|
||||
var pathTo = $"{folderTo}{fileName}";
|
||||
|
||||
var folderFrom = GamePaths.Mtrl.GearFolder(slotFrom, idFrom, variantTo);
|
||||
var newFileName = ItemSwap.ReplaceId(fileName, prefix, idTo, idFrom);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue