private static void ChaFileSaveFilePostHook(ChaFile __instance) { if (DoingImport) { return; } string cardName = __instance.charaFileName; if (cardName.IsNullOrEmpty()) { cardName = __instance.parameter?.fullname?.Trim(); } Sideloader.Logger.LogDebug($"Reloading card [{cardName}]"); var extData = ExtendedSave.GetExtendedDataById(__instance, UARExtIDOld) ?? ExtendedSave.GetExtendedDataById(__instance, UARExtID); // Some old ChaFile cards has object[] for "info" List <ResolveInfo> extInfo; if (extData.data["info"] is List <byte[]> lstByte) { extInfo = lstByte.Select(ResolveInfo.Deserialize).ToList(); } else if (extData.data["info"] is object[] objArray) { extInfo = objArray.Select(x => ResolveInfo.Deserialize((byte[])x)).ToList(); } else { Sideloader.Logger.LogError("Unknown data type:" + (extData.data["info"]).GetType()); return; } Sideloader.Logger.LogDebug($"External info count: {extInfo.Count}"); if (Sideloader.DebugLogging.Value) { foreach (ResolveInfo info in extInfo) { Sideloader.Logger.LogDebug($"External info: {info.GUID} : {info.Property} : {info.Slot}"); } } void ResetStructResolveStructure(Dictionary <CategoryProperty, StructValue <int> > propertyDict, object structure, IEnumerable <ResolveInfo> extInfo2, string propertyPrefix = "") { foreach (var kv in propertyDict) { var extResolve = extInfo.FirstOrDefault(x => x.Property == $"{propertyPrefix}{kv.Key}"); if (extResolve != null) { kv.Value.SetMethod(structure, extResolve.LocalSlot); } } } IterateCardPrefixes(ResetStructResolveStructure, __instance, extInfo); #if AI || HS2 //Resolve the bundleID to the same ID as the hair foreach (var hairPart in __instance.custom.hair.parts) { if (hairPart.id > BaseSlotID) { hairPart.bundleId = hairPart.id; } } #endif }
private static void ExtendedCoordinateImport(Dictionary <string, PluginData> importedExtendedData) { if (importedExtendedData.TryGetValue(UniversalAutoResolver.UARExtID, out var pluginData)) { if (pluginData != null && pluginData.data.ContainsKey("info")) { var tmpExtInfo = (object[])pluginData.data["info"]; var extInfo = tmpExtInfo.Select(x => ResolveInfo.Deserialize((byte[])x)).ToList(); for (int i = 0; i < extInfo.Count;) { Sideloader.Logger.Log(LogLevel.Debug, $"External info: {extInfo[i].GUID} : {extInfo[i].Property} : {extInfo[i].Slot} : {extInfo[i].CategoryNo}"); if (extInfo[i].Property.EndsWith("ClothesShoesInner")) { //KK had inner shoes, EC does not extInfo.RemoveAt(i); } else { extInfo[i].Property = extInfo[i].Property.Replace("outfit0", "outfit"); //KK originally had only one emblem if (extInfo[i].Property.EndsWith("Emblem")) { extInfo[i].Property += "0"; } //KK has multiple shoes slots, convert to one shoes slot extInfo[i].Property = extInfo[i].Property.Replace("ClothesShoesOuter", "ClothesShoes"); i++; } } importedExtendedData[UniversalAutoResolver.UARExtID] = new PluginData { data = new Dictionary <string, object> { ["info"] = extInfo.Select(x => x.Serialize()).ToList() } }; } } if (Sideloader.DebugLogging.Value && importedExtendedData.TryGetValue(UniversalAutoResolver.UARExtID, out var extData)) { if (extData == null || !extData.data.ContainsKey("info")) { Sideloader.Logger.Log(LogLevel.Debug, "Imported coordinate data: No sideloader marker found"); } else { var tmpExtInfo = (List <byte[]>)extData.data["info"]; var extInfo = tmpExtInfo.Select(ResolveInfo.Deserialize).ToList(); Sideloader.Logger.Log(LogLevel.Debug, $"Imported coordinate data: Sideloader marker found, external info count: {extInfo.Count}"); foreach (ResolveInfo info in extInfo) { Sideloader.Logger.Log(LogLevel.Debug, $"External info: {info.GUID} : {info.Property} : {info.Slot} : {info.CategoryNo}"); } } } }