Improve GamePaths and parsing, add support for identifying skeletons and phybs.

This commit is contained in:
Ottermandias 2025-02-27 13:08:41 +01:00
parent 8860d1e39a
commit c6de7ddebd
17 changed files with 65 additions and 83 deletions

View file

@ -17,8 +17,8 @@ public static class CustomizationSwap
if (idFrom.Id > byte.MaxValue)
throw new Exception($"The Customization ID {idFrom} is too large for {slot}.");
var mdlPathFrom = GamePaths.Character.Mdl.Path(race, slot, idFrom, slot.ToCustomizationType());
var mdlPathTo = GamePaths.Character.Mdl.Path(race, slot, idTo, slot.ToCustomizationType());
var mdlPathFrom = GamePaths.Mdl.Customization(race, slot, idFrom, slot.ToCustomizationType());
var mdlPathTo = GamePaths.Mdl.Customization(race, slot, idTo, slot.ToCustomizationType());
var mdl = FileSwap.CreateSwap(manager, ResourceType.Mdl, redirections, mdlPathFrom, mdlPathTo);
var range = slot == BodySlot.Tail
@ -47,8 +47,8 @@ public static class CustomizationSwap
ref string fileName, ref bool dataWasChanged)
{
variant = slot is BodySlot.Face or BodySlot.Ear ? Variant.None.Id : variant;
var mtrlFromPath = GamePaths.Character.Mtrl.Path(race, slot, idFrom, fileName, out var gameRaceFrom, out var gameSetIdFrom, variant);
var mtrlToPath = GamePaths.Character.Mtrl.Path(race, slot, idTo, fileName, out var gameRaceTo, out var gameSetIdTo, variant);
var mtrlFromPath = GamePaths.Mtrl.Customization(race, slot, idFrom, fileName, out var gameRaceFrom, out var gameSetIdFrom, variant);
var mtrlToPath = GamePaths.Mtrl.Customization(race, slot, idTo, fileName, out var gameRaceTo, out var gameSetIdTo, variant);
var newFileName = fileName;
newFileName = ItemSwap.ReplaceRace(newFileName, gameRaceTo, race, gameRaceTo != race);
@ -60,7 +60,7 @@ public static class CustomizationSwap
var actualMtrlFromPath = mtrlFromPath;
if (newFileName != fileName)
{
actualMtrlFromPath = GamePaths.Character.Mtrl.Path(race, slot, idFrom, newFileName, out _, out _, variant);
actualMtrlFromPath = GamePaths.Mtrl.Customization(race, slot, idFrom, newFileName, out _, out _, variant);
fileName = newFileName;
dataWasChanged = true;
}

View file

@ -107,7 +107,7 @@ public static class EquipmentSwap
foreach (var child in eqp.ChildSwaps.SelectMany(c => c.WithChildren()).OfType<MetaSwap<EqpIdentifier, EqpEntryInternal>>())
{
affectedItems.UnionWith(identifier
.Identify(GamePaths.Equipment.Mdl.Path(idFrom, GenderRace.MidlanderMale, child.SwapFromIdentifier.Slot))
.Identify(GamePaths.Mdl.Equipment(idFrom, GenderRace.MidlanderMale, child.SwapFromIdentifier.Slot))
.Select(kvp => kvp.Value).OfType<IdentifiedItem>().Select(i => i.Item));
}
}
@ -223,11 +223,9 @@ public static class EquipmentSwap
public static FileSwap CreateMdl(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, EquipSlot slotFrom, EquipSlot slotTo,
GenderRace gr, PrimaryId idFrom, PrimaryId idTo, byte mtrlTo)
{
var mdlPathFrom = slotFrom.IsAccessory()
? GamePaths.Accessory.Mdl.Path(idFrom, gr, slotFrom)
: GamePaths.Equipment.Mdl.Path(idFrom, gr, slotFrom);
var mdlPathTo = slotTo.IsAccessory() ? GamePaths.Accessory.Mdl.Path(idTo, gr, slotTo) : GamePaths.Equipment.Mdl.Path(idTo, gr, slotTo);
var mdl = FileSwap.CreateSwap(manager, ResourceType.Mdl, redirections, mdlPathFrom, mdlPathTo);
var mdlPathFrom = GamePaths.Mdl.Gear(idFrom, gr, slotFrom);
var mdlPathTo = GamePaths.Mdl.Gear(idTo, gr, slotTo);
var mdl = FileSwap.CreateSwap(manager, ResourceType.Mdl, redirections, mdlPathFrom, mdlPathTo);
foreach (ref var fileName in mdl.AsMdl()!.Materials.AsSpan())
{
@ -264,9 +262,7 @@ public static class EquipmentSwap
}
else
{
items = identifier.Identify(slotFrom.IsEquipment()
? GamePaths.Equipment.Mdl.Path(idFrom, GenderRace.MidlanderMale, slotFrom)
: GamePaths.Accessory.Mdl.Path(idFrom, GenderRace.MidlanderMale, slotFrom))
items = identifier.Identify(GamePaths.Mdl.Gear(idFrom, GenderRace.MidlanderMale, slotFrom))
.Select(kvp => kvp.Value).OfType<IdentifiedItem>().Select(i => i.Item)
.ToHashSet();
variants = Enumerable.Range(0, imc.Count + 1).Select(i => (Variant)i).ToArray();
@ -324,7 +320,7 @@ public static class EquipmentSwap
if (decalId == 0)
return null;
var decalPath = GamePaths.Equipment.Decal.Path(decalId);
var decalPath = GamePaths.Tex.EquipDecal(decalId);
return FileSwap.CreateSwap(manager, ResourceType.Tex, redirections, decalPath, decalPath);
}
@ -337,9 +333,9 @@ public static class EquipmentSwap
if (vfxId == 0)
return null;
var vfxPathFrom = GamePaths.Equipment.Avfx.Path(idFrom, vfxId);
var vfxPathFrom = GamePaths.Avfx.Path(slotFrom, idFrom, vfxId);
vfxPathFrom = ItemSwap.ReplaceType(vfxPathFrom, slotFrom, slotTo, idFrom);
var vfxPathTo = GamePaths.Equipment.Avfx.Path(idTo, vfxId);
var vfxPathTo = GamePaths.Avfx.Path(slotTo, idTo, vfxId);
var avfx = FileSwap.CreateSwap(manager, ResourceType.Avfx, redirections, vfxPathFrom, vfxPathTo);
foreach (ref var filePath in avfx.AsAvfx()!.Textures.AsSpan())
@ -402,14 +398,10 @@ public static class EquipmentSwap
if (!fileName.Contains($"{prefix}{idTo.Id:D4}"))
return null;
var folderTo = slotTo.IsAccessory()
? GamePaths.Accessory.Mtrl.FolderPath(idTo, variantTo)
: GamePaths.Equipment.Mtrl.FolderPath(idTo, variantTo);
var folderTo = GamePaths.Mtrl.GearFolder(slotTo, idTo, variantTo);
var pathTo = $"{folderTo}{fileName}";
var folderFrom = slotFrom.IsAccessory()
? GamePaths.Accessory.Mtrl.FolderPath(idFrom, variantTo)
: GamePaths.Equipment.Mtrl.FolderPath(idFrom, variantTo);
var folderFrom = GamePaths.Mtrl.GearFolder(slotFrom, idFrom, variantTo);
var newFileName = ItemSwap.ReplaceId(fileName, prefix, idTo, idFrom);
newFileName = ItemSwap.ReplaceSlot(newFileName, slotTo, slotFrom, slotTo != slotFrom);
var pathFrom = $"{folderFrom}{newFileName}";
@ -457,7 +449,7 @@ public static class EquipmentSwap
public static FileSwap CreateShader(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, ref string shaderName,
ref bool dataWasChanged)
{
var path = $"shader/sm5/shpk/{shaderName}";
var path = GamePaths.Shader(shaderName);
return FileSwap.CreateSwap(manager, ResourceType.Shpk, redirections, path, path);
}

View file

@ -132,14 +132,14 @@ public static class ItemSwap
public static FileSwap CreatePhyb(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, EstType type,
GenderRace race, EstEntry estEntry)
{
var phybPath = GamePaths.Skeleton.Phyb.Path(race, type.ToName(), estEntry.AsId);
var phybPath = GamePaths.Phyb.Customization(race, type.ToName(), estEntry.AsId);
return FileSwap.CreateSwap(manager, ResourceType.Phyb, redirections, phybPath, phybPath);
}
public static FileSwap CreateSklb(MetaFileManager manager, Func<Utf8GamePath, FullPath> redirections, EstType type,
GenderRace race, EstEntry estEntry)
{
var sklbPath = GamePaths.Skeleton.Sklb.Path(race, type.ToName(), estEntry.AsId);
var sklbPath = GamePaths.Sklb.Customization(race, type.ToName(), estEntry.AsId);
return FileSwap.CreateSwap(manager, ResourceType.Sklb, redirections, sklbPath, sklbPath);
}