private static void ExtendedSceneLoad(string path) { PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(UniversalAutoResolver.UARExtID); UniversalAutoResolver.ResolveStudioObjects(ExtendedData, UniversalAutoResolver.ResolveType.Load); UniversalAutoResolver.ResolveStudioMap(ExtendedData, UniversalAutoResolver.ResolveType.Load); }
private static void ExtendedSceneImport(string path) { PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(UniversalAutoResolver.UARExtID); Dictionary <int, ObjectInfo> ObjectList = FindObjectInfo(SearchType.All); if (ExtendedData != null && ExtendedData.data.ContainsKey("itemInfo")) { object[] tmpExtInfo = (object[])ExtendedData.data["itemInfo"]; List <StudioResolveInfo> extInfo = tmpExtInfo.Select(x => StudioResolveInfo.Unserialize((byte[])x)).ToList(); Dictionary <int, int> ItemImportOrder = FindObjectInfoOrder(SearchType.Import, typeof(OIItemInfo)); Dictionary <int, int> LightImportOrder = FindObjectInfoOrder(SearchType.Import, typeof(OILightInfo)); //Match objects from the StudioResolveInfo to objects in the scene based on the item order that was generated and saved to the scene data foreach (StudioResolveInfo extResolve in extInfo) { int NewDicKey = ItemImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault(); if (ObjectList[NewDicKey] is OIItemInfo Item) { UniversalAutoResolver.ResolveStudioObject(extResolve, Item); ObjectList.Remove(NewDicKey); } else { NewDicKey = LightImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault(); if (ObjectList[extResolve.DicKey] is OILightInfo Light) { UniversalAutoResolver.ResolveStudioObject(extResolve, Light); ObjectList.Remove(NewDicKey); } } } } //Resolve every item without extended data in case of hard mods foreach (ObjectInfo OI in ObjectList.Where(x => x.Value is OIItemInfo || x.Value is OILightInfo).Select(x => x.Value)) { if (OI is OIItemInfo Item) { UniversalAutoResolver.ResolveStudioObject(Item); } else if (OI is OILightInfo Light) { UniversalAutoResolver.ResolveStudioObject(Light); } } //Maps are not imported //UniversalAutoResolver.ResolveStudioMap(extData); }
private static void ExtendedCardLoad(ChaFile file) { UniversalAutoResolver.ResolveStructure(StructReference.ChaFileFaceProperties, file.custom.face, file); UniversalAutoResolver.ResolveStructure(StructReference.ChaFileBodyProperties, file.custom.body, file); UniversalAutoResolver.ResolveStructure(StructReference.ChaFileHairProperties, file.custom.hair, file); for (int i = 0; i < file.coordinate.Length; i++) { var coordinate = file.coordinate[i]; string prefix = $"outfit{i}."; UniversalAutoResolver.ResolveStructure(StructReference.ChaFileClothesProperties, coordinate.clothes, file, prefix); UniversalAutoResolver.ResolveStructure(StructReference.ChaFileMakeupProperties, coordinate.makeup, file, prefix); for (int acc = 0; acc < coordinate.accessory.parts.Length; acc++) { string accPrefix = $"{prefix}accessory{acc}."; UniversalAutoResolver.ResolveStructure(StructReference.ChaFileAccessoryPartsInfoProperties, coordinate.accessory.parts[acc], file, accPrefix); } } }
private static void ExtendedCardSave(ChaFile file) { List <ResolveInfo> resolutionInfo = new List <ResolveInfo>(); void IterateStruct(Dictionary <CategoryProperty, StructValue <int> > dict, object obj, IEnumerable <ResolveInfo> extInfo, string propertyPrefix = "") { foreach (var kv in dict) { int slot = kv.Value.GetMethod(obj); //No need to attempt a resolution info lookup for empty accessory slots and pattern slots if (slot == 0) { continue; } //Check if it's a vanilla item if (slot < 100000000) { if (ResourceRedirector.ListLoader.InternalDataList[kv.Key.Category].ContainsKey(slot)) { continue; } } //For accessories, make sure we're checking the appropriate category if (kv.Key.Category.ToString().Contains("ao_")) { ChaFileAccessory.PartsInfo AccessoryInfo = (ChaFileAccessory.PartsInfo)obj; if ((int)kv.Key.Category != AccessoryInfo.type) { //If the current category does not match the accessory's category do not attempt a resolution info lookup continue; } } var info = UniversalAutoResolver.TryGetResolutionInfo(kv.Key.ToString(), slot); if (info == null) { continue; } var newInfo = info.DeepCopy(); newInfo.Property = $"{propertyPrefix}{newInfo.Property}"; kv.Value.SetMethod(obj, newInfo.Slot); resolutionInfo.Add(newInfo); } } IterateCardPrefixes(IterateStruct, file, null); ExtendedSave.SetExtendedDataById(file, UniversalAutoResolver.UARExtID, new PluginData { data = new Dictionary <string, object> { ["info"] = resolutionInfo.Select(x => x.Serialize()).ToList() } }); }
private static void ExtendedCardLoad(ChaFile file) { UniversalAutoResolver.ResolveStructure(StructReference.ChaFileFaceProperties, lastLoadedInstance.face, file); UniversalAutoResolver.ResolveStructure(StructReference.ChaFileBodyProperties, lastLoadedInstance.body, file); UniversalAutoResolver.ResolveStructure(StructReference.ChaFileHairProperties, lastLoadedInstance.hair, file); }