private static void ExtendedSceneLoad(string path) { PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(UniversalAutoResolver.UARExtID); UniversalAutoResolver.ResolveStudioObjects(ExtendedData, UniversalAutoResolver.ResolveType.Load); UniversalAutoResolver.ResolveStudioMap(ExtendedData, UniversalAutoResolver.ResolveType.Load); }
// Token: 0x06000006 RID: 6 RVA: 0x000020F8 File Offset: 0x000002F8 private static void ExtendedSceneLoadInUpdate() { try { Logger.Log(LogLevel.Info, "Start loading VMDPlay info from scene data."); object obj; if (ExtendedSave.GetSceneExtendedDataById("KKVMDPlayExtSave").data.TryGetValue("xml", out obj)) { if (obj != null && obj is byte[]) { Logger.Log(LogLevel.Info, string.Format("Found VMDPlay info XML data: {0}", ((byte[])obj).Length)); MemoryStream inStream = new MemoryStream((byte[])obj); Console.WriteLine("ExtSave: Loading from PNG."); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(inStream); Console.WriteLine(xmlDocument.ToString()); KKVMDPlayExtSavePlugin.OnLoad(xmlDocument.DocumentElement); } else { Logger.Log(LogLevel.Message, "Data not found."); } } else { Logger.Log(LogLevel.Message, "Data not found."); } } catch (Exception ex) { Logger.Log(LogLevel.Error, string.Format("Failed to load data. {0}", ex.StackTrace)); } }
/// <summary> /// Scene has to be fully loaded for all characters and objects to exist in the game /// </summary> private void SceneLoaded(Scene s, LoadSceneMode lsm) { if (s.name == "StudioNotification" && LoadClicked) { LoadClicked = false; try { IKObjectInfoList.Clear(); PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(PluginName); if (ExtendedData != null && ExtendedData.data.ContainsKey("AnimationInfo")) { List <AnimationControllerInfo> AnimationControllerInfoList; AnimationControllerInfoList = ((object[])ExtendedData.data["AnimationInfo"]).Select(x => AnimationControllerInfo.Unserialize((byte[])x)).ToList(); foreach (var AnimInfo in AnimationControllerInfoList) { IKObjectInfo LoadedAnimInfo = new IKObjectInfo(); var Character = Singleton <Studio.Studio> .Instance.dicObjectCtrl.Where(x => x.Key == AnimInfo.CharDicKey).Select(x => x.Value as OCIChar).First(); LoadedAnimInfo.CharacterKey = AnimInfo.CharDicKey; LoadedAnimInfo.CharacterObject = GameObject.Find(Character.charInfo.name); LoadedAnimInfo.IKPart = AnimInfo.IKPart; LoadedAnimInfo.IKTarget = Character.listIKTarget.Where(x => x.boneObject.name == AnimInfo.IKPart).First(); var LinkedItem = Singleton <Studio.Studio> .Instance.dicObjectCtrl.Where(x => x.Key == AnimInfo.ItemDicKey).Select(x => x.Value).First(); switch (LinkedItem) { case OCIItem Item: LoadedAnimInfo.ObjectKey = Item.objectInfo.dicKey; LoadedAnimInfo.SelectedObject = Item.childRoot.gameObject; break; case OCIFolder Folder: LoadedAnimInfo.ObjectKey = Folder.objectInfo.dicKey; LoadedAnimInfo.SelectedObject = Folder.childRoot.gameObject; break; case OCIRoute Route: LoadedAnimInfo.ObjectKey = Route.objectInfo.dicKey; LoadedAnimInfo.SelectedObject = Route.childRoot.gameObject; break; } IKObjectInfoList.Add(LoadedAnimInfo); } } Logger.Log(LogLevel.Debug, "Loaded KK_AnimationController animations"); } catch (Exception ex) { Logger.Log(LogLevel.Error | LogLevel.Message, "Could not load KK_AnimationController animations."); Logger.Log(LogLevel.Error, ex.ToString()); } } }
/// <summary> /// Get extended data of the last loaded scene by using the ID you specified when registering this controller. /// </summary> public PluginData GetExtendedData() { if (ExtendedDataId == null) { throw new ArgumentException(nameof(ExtendedDataId)); } return(ExtendedSave.GetSceneExtendedDataById(ExtendedDataId)); }
internal static void ExtendedSceneLoad(string path) { PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(UARExtID); ResolveStudioObjects(ExtendedData, ResolveType.Load); ResolveStudioMap(ExtendedData, ResolveType.Load); ResolveStudioFilter(ExtendedData, ResolveType.Load); ResolveStudioRamp(ExtendedData, ResolveType.Load); ResolveStudioBGM(ExtendedData, ResolveType.Load); }
protected override void OnSceneSave() { //Clear out the old style data PluginData OldData = ExtendedSave.GetSceneExtendedDataById(PluginNameInternal); if (OldData != null) { OldData = null; } ExtendedSave.SetSceneExtendedDataById(PluginNameInternal, new PluginData { data = null }); }
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); }
public static void RegisterSaveEvent() { ExtendedSave.SceneBeingSaved += path => { ExtendedSave.SetSceneExtendedDataById(StudioCharaLightLinkedToCamera.GUID, new PluginData() { data = new System.Collections.Generic.Dictionary <string, object> { { "locked", Locked ? "true" : "false" }, { "attachedLightAngle", new System.Collections.Generic.Dictionary <string, float> { { "x", ComputeAngle.AttachedLightEuler.x }, { "y", ComputeAngle.AttachedLightEuler.y } } }, { "attachedCameraAngle", new System.Collections.Generic.Dictionary <string, float> { { "x", ComputeAngle.AttachedCameraEuler.x }, { "y", ComputeAngle.AttachedCameraEuler.y } } } }, version = 3 }); Logger.LogDebug("Scene Saved"); }; ExtendedSave.SceneBeingLoaded += path => { PluginData pd = ExtendedSave.GetSceneExtendedDataById(StudioCharaLightLinkedToCamera.GUID); if (null != pd && pd.version == 3 && pd.data.TryGetValue("locked", out object l) && l is string boolstring && pd.data.TryGetValue("attachedLightAngle", out object lig) && pd.data.TryGetValue("attachedCameraAngle", out object cam)) { System.Collections.Generic.Dictionary <string, float> ligAngle = lig.ToDictionary <string, float>(); System.Collections.Generic.Dictionary <string, float> camAngle = cam.ToDictionary <string, float>(); ToggleLocked(boolstring == "true"); ComputeAngle.AttachedLightEuler = new Vector2(ligAngle["x"], ligAngle["y"]); ComputeAngle.AttachedCameraEuler = new Vector2(camAngle["x"], camAngle["y"]); Logger.LogDebug("Scene Load PluginData"); }
/// <summary> /// Called by the scene controller, loads animations from the loaded or imported scene /// </summary> internal void LoadAnimations(int characterDicKey, ReadOnlyDictionary <int, ObjectCtrlInfo> loadedItems) { try { PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(PluginNameInternal); //Version 1 save data if (ExtendedData?.data != null && ExtendedData.data.ContainsKey("AnimationInfo")) { List <AnimationControllerInfo> AnimationControllerInfoList = ((object[])ExtendedData.data["AnimationInfo"]).Select(x => AnimationControllerInfo.Unserialize((byte[])x)).ToList(); foreach (var AnimInfo in AnimationControllerInfoList) { //See if this is the right character if (AnimInfo.CharDicKey != characterDicKey) { continue; } ObjectCtrlInfo linkedItem = loadedItems[AnimInfo.ItemDicKey]; if (AnimInfo.Version.IsNullOrEmpty()) { AddLinkV1(AnimInfo.IKPart, linkedItem); } else { AddLink(AnimInfo.IKPart, linkedItem); } } } //Version 2 save data else { var data = GetExtendedData(); if (data?.data != null) { if (data.data.TryGetValue("LinksV1", out var loadedLinksV1) && loadedLinksV1 != null) { foreach (var link in (Dictionary <object, object>)loadedLinksV1) { AddLinkV1((string)link.Key, loadedItems[(int)link.Value]); } } if (data.data.TryGetValue("Links", out var loadedLinks) && loadedLinks != null) { foreach (var link in (Dictionary <object, object>)loadedLinks) { AddLink((string)link.Key, loadedItems[(int)link.Value]); } } if (data.data.TryGetValue("Eyes", out var loadedEyeLink) && loadedEyeLink != null) { AddEyeLink(loadedItems[(int)loadedEyeLink]); } if (data.data.TryGetValue("Neck", out var loadedNeckLink) && loadedNeckLink != null) { AddNeckLink(loadedItems[(int)loadedNeckLink]); } } } Logger.Log(LogLevel.Debug, $"Loaded KK_AnimationController animations for character {ChaControl.chaFile.parameter.fullname.Trim()}"); } catch (Exception ex) { Logger.Log(LogLevel.Error | LogLevel.Message, "Could not load KK_AnimationController animations."); Logger.Log(LogLevel.Error, ex.ToString()); } }