private List <string> ProcessScene(string pth) { var names = new List <string>(); using (var fileStream = new FileStream(pth, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var reader = new BinaryReader(fileStream)) { PngFile.SkipPng(reader); var version = new Version(reader.ReadString()); var num = reader.ReadInt32(); var infos = ListPool <ObjectInfo> .Get(); for (var i = 0; i < num; i++) { var dummy = reader.ReadInt32(); var num2 = reader.ReadInt32(); ObjectInfo oICharInfo; switch (num2) { case 0: { oICharInfo = new OICharInfo(null, Studio.Studio.GetNewIndex()); break; } case 1: { oICharInfo = new OIItemInfo(-1, -1, -1, Studio.Studio.GetNewIndex()); break; } case 2: { oICharInfo = new OILightInfo(-1, Studio.Studio.GetNewIndex()); break; } case 3: { oICharInfo = new OIFolderInfo(Studio.Studio.GetNewIndex()); break; } case 4: { oICharInfo = new OIRouteInfo(Studio.Studio.GetNewIndex()); break; } case 5: { oICharInfo = new OICameraInfo(Studio.Studio.GetNewIndex()); break; } default: continue; } ResetHspe(); oICharInfo.Load(reader, version, true); infos.Add(oICharInfo); CollectNames(oICharInfo, ref names); } while (infos.Count > 0) { var info = infos[0]; infos.RemoveAt(0); info.DeleteKey(); } ListPool <ObjectInfo> .Release(infos); } } return(names); }
// Edited version of SceneInfo.Import void ImportSceneChara(string path) { using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var binaryReader = new BinaryReader(fileStream)) { PngFile.SkipPng(binaryReader); var version = new Version(binaryReader.ReadString()); var sceneInfo = Studio.Studio.Instance.sceneInfo; var traverse = Traverse.Create(sceneInfo); traverse.Property("dicImport").SetValue(new Dictionary <int, ObjectInfo>()); traverse.Property("dicChangeKey").SetValue(new Dictionary <int, int>()); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { int value = binaryReader.ReadInt32(); int type = binaryReader.ReadInt32(); if (type == 0) { var objectInfo = new OICharInfo(null, Studio.Studio.GetNewIndex()); objectInfo.Load(binaryReader, version, true, true); sceneInfo.dicObject.Add(objectInfo.dicKey, objectInfo); sceneInfo.dicImport.Add(objectInfo.dicKey, objectInfo); sceneInfo.dicChangeKey.Add(objectInfo.dicKey, value); } else if (type == 1) { var objectInfo = new OIItemInfo(-1, -1, -1, Studio.Studio.GetNewIndex()); objectInfo.Load(binaryReader, version, true, true); foreach (var item in FindCharacters(objectInfo.child)) { sceneInfo.dicObject.Add(item.dicKey, item); sceneInfo.dicImport.Add(item.dicKey, item); sceneInfo.dicChangeKey.Add(item.dicKey, value); } } else if (type == 3) { var objectInfo = new OIFolderInfo(Studio.Studio.GetNewIndex()); objectInfo.Load(binaryReader, version, true, true); foreach (var item in FindCharacters(objectInfo.child)) { sceneInfo.dicObject.Add(item.dicKey, item); sceneInfo.dicImport.Add(item.dicKey, item); sceneInfo.dicChangeKey.Add(item.dicKey, value); } } else { ObjectInfo objectInfo = null; switch (type) { case 2: objectInfo = new OILightInfo(-1, Studio.Studio.GetNewIndex()); break; case 4: objectInfo = new OIRouteInfo(Studio.Studio.GetNewIndex()); break; case 5: objectInfo = new OICameraInfo(Studio.Studio.GetNewIndex()); break; } objectInfo.Load(binaryReader, version, true, true); } } } } AddObjectAssist.LoadChild(Studio.Studio.Instance.sceneInfo.dicImport, null, null); Studio.Studio.Instance.treeNodeCtrl.RefreshHierachy(); }