/// <summary> /// 잘못 만든듯 /// </summary> private void ModRefresh0() { if (isRunModreflash) { return; } isRunModreflash = true; Task.Factory.StartNew(() => { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); MyLog.LogDarkBlue("modreflash0. start ", string.Format("{0:0.000} ", stopwatch.Elapsed.ToString())); bool flag = Directory.Exists(UTY.gameProjectPath + "\\Mod\\"); if (flag) { GameUty.UpdateFileSystemPath(); GameUty.UpdateFileSystemPathOld(); } bool flag3 = GameUty.FileSystemMod != null; if (flag3) { typeof(GameUty).GetField("m_aryModOnlysMenuFiles").SetValue(null, Array.FindAll <string>(GameUty.FileSystemMod.GetList(string.Empty, AFileSystemBase.ListType.AllFile), (string i) => new Regex(".*\\.menu$").IsMatch(i))); } MyLog.LogDarkBlue("modreflash0. end ", string.Format("{0:0.000} ", stopwatch.Elapsed.ToString())); isRunModreflash = false; } ); } /*
public Dictionary <TBody.SlotID, Item> Load(string filename) { trgtMenu = ACCMenu.Load(filename); nameInterlocked = false; if (trgtMenu != null) { showDialog = true; return(trgtMenu.itemSlots); } else { // エラー確認用処理 var aFileBase = GameUty.FileOpen(filename); if (!aFileBase.IsValid()) { return(null); } //const int BUFFER_SIZE = 8192; var dir = OutputUtil.Instance.GetExportDirectory(); var outfile = Path.Combine(dir, filename); LogUtil.Error("MENUファイルを出力します。", outfile); using (var writer = new BinaryWriter(File.OpenWrite(outfile))) { writer.Write(aFileBase.ReadAll()); } } return(null); }
public static Material LoadMaterial(string materialName) { AFileBase file = GameUty.FileOpen(materialName); if (!file.IsValid() || file.GetSize() == 0) { string name = materialName.Replace(@"material\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { Debug.LogError("File not valid " + materialName); return(null); } } BinaryReader r = new BinaryReader((Stream) new MemoryStream(file.ReadAll()), System.Text.Encoding.UTF8); string str = r.ReadString(); if (str != "CM3D2_MATERIAL") { NDebug.Assert("ProcScriptBin 例外 : ヘッダーファイルが不正です。" + str); } r.ReadInt32(); r.ReadString(); Material material = AssetLoader.ReadMaterial(r, null); r.Close(); return(material); }
// Token: 0x06000250 RID: 592 RVA: 0x000147AC File Offset: 0x000129AC public Stream GetStream(string filename) { Stream result; try { AFileBase afileBase = GameUty.FileOpen(filename, null); if (!afileBase.IsValid()) { StringBuilder stringBuilder = LogUtil.Error(new object[] { "指定ファイルが見つかりません。file=", filename }); throw new ACCException(stringBuilder.ToString()); } result = new BufferedStream(new FileBaseStream(afileBase), FileUtilEx.BUFFER_SIZE); } catch (ACCException) { throw; } catch (Exception ex) { StringBuilder stringBuilder2 = LogUtil.Error(new object[] { "指定ファイルが読み込めませんでした。", filename, ex }); throw new ACCException(stringBuilder2.ToString(), ex); } return(result); }
// Token: 0x06000252 RID: 594 RVA: 0x00014918 File Offset: 0x00012B18 public byte[] LoadInternal(string filename) { byte[] result; try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (!afileBase.IsValid()) { StringBuilder stringBuilder = LogUtil.Error(new object[] { "指定ファイルが見つかりません。file=", filename }); throw new ACCException(stringBuilder.ToString()); } result = afileBase.ReadAll(); } } catch (ACCException) { throw; } catch (Exception ex) { StringBuilder stringBuilder2 = LogUtil.Error(new object[] { "指定ファイルが読み込めませんでした。", filename, ex }); throw new ACCException(stringBuilder2.ToString(), ex); } return(result); }
public static void InitGameUty() { fileSystem = new FileSystemStorage(); var assetLoader = new AssetLoader(fileSystem); var modDirectory = AFileSystemBase.base_path + "CAST/"; assetLoader.loadDirectory(modDirectory); Util.setPrivateStaticField(typeof(GameUty), "m_FileSystem", fileSystem); GameUty.UpdateFileSystemPath(); GameUty.UpdateFileSystemPathOld(); }
// 外部DLL依存 // 一旦バイト配列にロードすることなくStreamオブジェクトとして参照可能とする public Stream GetStream(string filename) { try { var aFileBase = GameUty.FileOpen(filename); if (aFileBase.IsValid()) { return(new BufferedStream(new FileBaseStream(aFileBase), BUFFER_SIZE)); } var msg = LogUtil.Error("指定ファイルが見つかりません。file=", filename); throw new ACCException(msg.ToString()); // if (aFileBase.GetSize() < BUFFER_SIZE) { } catch (ACCException) { throw; } catch (Exception e) { var msg = LogUtil.Error("指定ファイルが読み込めませんでした。", filename, e); throw new ACCException(msg.ToString(), e); } }
public byte[] LoadInternal(string filename) { try { using (var aFileBase = GameUty.FileOpen(filename)) { if (aFileBase.IsValid()) { return(aFileBase.ReadAll()); } var msg = LogUtil.Error("指定ファイルが見つかりません。file=", filename); throw new ACCException(msg.ToString()); } } catch (ACCException) { throw; } catch (Exception e) { var msg = LogUtil.Error("指定ファイルが読み込めませんでした。", filename, e); throw new ACCException(msg.ToString(), e); } }
// Token: 0x06000069 RID: 105 RVA: 0x00008494 File Offset: 0x00006694 public byte[] LoadMenuInternal(string filename) { byte[] result; try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (!afileBase.IsValid()) { throw new Exception(); } result = afileBase.ReadAll(); } } catch (Exception ex) { throw ex; } return(result); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, bool f_bMan, out string IconTex) { var fetchedField = AccessTools.DeclaredField(typeof(SceneEdit), "m_byItemFileBuffer"); var fetchedVal = fetchedField.GetValue(@this) as byte[]; IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { using (AFileBase afileBase = GameUty.FileOpen(f_strMenuFileName, null)) { NDebug.Assert(afileBase.IsValid(), "メニューファイルが存在しません。 :" + f_strMenuFileName); if (fetchedVal == null) { fetchedVal = new byte[System.Math.Max(500000, afileBase.GetSize())]; } else if (fetchedVal.Length < afileBase.GetSize()) { fetchedVal = new byte[afileBase.GetSize()]; } afileBase.Read(ref fetchedVal, afileBase.GetSize()); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } BinaryReader binaryReader = new BinaryReader(new MemoryStream(fetchedVal), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string path = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); long num2 = (long)binaryReader.ReadInt32(); int num3 = 0; string text5 = null; string text6 = string.Empty; string text7 = string.Empty; try { for (; ;) { int num4 = (int)binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Main.logger.LogError("err SaveItem \"" + text11); } if (text11 == null) { Main.logger.LogError("err SaveItem null=\"" + text11); } if (text11 != string.Empty) { } } else if (!(stringCom == "catno")) { if (stringCom == "additem") { num3++; } else if (stringCom == "unsetitem") { mi.m_boDelOnly = true; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; } } } } } } } } catch (Exception ex2) { Main.logger.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Main.logger.LogError("Error:"); } } binaryReader.Close(); return(true); }
// Token: 0x0600006A RID: 106 RVA: 0x000B857C File Offset: 0x000B757C public static Material ReadMaterial(BinaryReader r, TBodySkin bodyskin, Material existmat, string filename) { existmat = null; if (ImportCM2.m_hashPriorityMaterials == null) { ImportCM2.m_hashPriorityMaterials = new Dictionary <int, KeyValuePair <string, float> >(); string[] list = GameUty.FileSystem.GetList("prioritymaterial", ListType.AllFile); if (list != null && 0 < list.Length) { for (int i = 0; i < list.Length; i++) { if (Path.GetExtension(list[i]) == ".pmat") { string text = list[i]; using (AFileBase afileBase = GameUty.FileOpen(text, null)) { NDebug.Assert(afileBase.IsValid(), text + "を開けませんでした"); byte[] buffer = afileBase.ReadAll(); using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8)) { string a = binaryReader.ReadString(); NDebug.Assert(a == "CM3D2_PMATERIAL", "ヘッダーエラー\n" + text); int num = binaryReader.ReadInt32(); int key = binaryReader.ReadInt32(); string key2 = binaryReader.ReadString(); float value = binaryReader.ReadSingle(); NDebug.Assert(!ImportCM2.m_hashPriorityMaterials.ContainsKey(key), "すでにハッシュが登録されています"); ImportCM2.m_hashPriorityMaterials.Add(key, new KeyValuePair <string, float>(key2, value)); } } } } } } string name = r.ReadString(); string text2 = r.ReadString(); string str = r.ReadString(); string path = "DefMaterial/" + str; Material material2; if (existmat == null) { Material material = Resources.Load(path, typeof(Material)) as Material; if (material == null) { return(material); } material2 = UnityEngine.Object.Instantiate <Material>(material); } else { material2 = existmat; NDebug.Assert(material2.shader.name == text2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + text2 + " -> " + material2.shader.name); } material2.name = name; int hashCode = material2.name.GetHashCode(); if (ImportCM2.m_hashPriorityMaterials != null && ImportCM2.m_hashPriorityMaterials.ContainsKey(hashCode)) { KeyValuePair <string, float> keyValuePair = ImportCM2.m_hashPriorityMaterials[hashCode]; if (keyValuePair.Key == material2.name) { material2.SetFloat("_SetManualRenderQueue", keyValuePair.Value); material2.renderQueue = (int)keyValuePair.Value; } } Vector2 value2; Vector2 value3; Color value4; Vector4 value5; for (;;) { string a2 = r.ReadString(); if (a2 == "end") { break; } string name2 = r.ReadString(); if (a2 == "tex") { string a3 = r.ReadString(); if (a3 == "null") { material2.SetTexture(name2, null); } else if (a3 == "tex2d") { try { string text3 = r.ReadString(); string text4 = r.ReadString(); byte[] data = ImportCM.LoadTexture(GameUty.FileSystem, text3 + ".tex", false).data; value2.x = r.ReadSingle(); value2.y = r.ReadSingle(); value3.x = r.ReadSingle(); value3.y = r.ReadSingle(); if (filename == null || !filename.Contains(".mate")) { Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture2D.LoadImage(data); texture2D.name = text3; texture2D.wrapMode = TextureWrapMode.Clamp; material2.SetTexture(name2, texture2D); material2.SetTextureOffset(name2, value2); material2.SetTextureScale(name2, value3); } } catch { break; } } else if (a3 == "texRT") { string text5 = r.ReadString(); string text6 = r.ReadString(); } } else if (a2 == "col") { value4.r = r.ReadSingle(); value4.g = r.ReadSingle(); value4.b = r.ReadSingle(); value4.a = r.ReadSingle(); material2.SetColor(name2, value4); } else if (a2 == "vec") { value5.x = r.ReadSingle(); value5.y = r.ReadSingle(); value5.z = r.ReadSingle(); value5.w = r.ReadSingle(); material2.SetVector(name2, value5); } else if (a2 == "f") { float value6 = r.ReadSingle(); material2.SetFloat(name2, value6); } } if (filename != null && filename.Contains(".mate")) { try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (ImportCM2.m_matTempFile == null) { ImportCM2.m_matTempFile = new byte[Math.Max(10000, afileBase.GetSize())]; } else if (ImportCM2.m_matTempFile.Length < afileBase.GetSize()) { ImportCM2.m_matTempFile = new byte[afileBase.GetSize()]; } afileBase.Read(ref ImportCM2.m_matTempFile, afileBase.GetSize()); } } catch { } BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(ImportCM2.m_matTempFile), Encoding.UTF8); string text7 = binaryReader2.ReadString(); NDebug.Assert(text7 == "CM3D2_MATERIAL", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text7); int num2 = binaryReader2.ReadInt32(); string text8 = binaryReader2.ReadString(); r = binaryReader2; name = r.ReadString(); text2 = r.ReadString(); str = r.ReadString(); path = "DefMaterial/" + str; if (existmat == null) { Material material = Resources.Load(path, typeof(Material)) as Material; if (material == null) { return(material); } material2 = UnityEngine.Object.Instantiate <Material>(material); } else { material2 = existmat; NDebug.Assert(material2.shader.name == text2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + text2 + " -> " + material2.shader.name); } material2.name = name; hashCode = material2.name.GetHashCode(); if (ImportCM2.m_hashPriorityMaterials != null && ImportCM2.m_hashPriorityMaterials.ContainsKey(hashCode)) { KeyValuePair <string, float> keyValuePair = ImportCM2.m_hashPriorityMaterials[hashCode]; if (keyValuePair.Key == material2.name) { material2.SetFloat("_SetManualRenderQueue", keyValuePair.Value); material2.renderQueue = (int)keyValuePair.Value; } } for (;;) { string a2 = r.ReadString(); if (a2 == "end") { break; } string name2 = r.ReadString(); if (a2 == "tex") { string a3 = r.ReadString(); if (a3 == "null") { material2.SetTexture(name2, null); } else if (a3 == "tex2d") { try { string text3 = r.ReadString(); string text4 = r.ReadString(); byte[] data = ImportCM.LoadTexture(GameUty.FileSystem, text3 + ".tex", false).data; Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture2D.LoadImage(data); texture2D.name = text3; texture2D.wrapMode = TextureWrapMode.Clamp; material2.SetTexture(name2, texture2D); value2.x = r.ReadSingle(); value2.y = r.ReadSingle(); material2.SetTextureOffset(name2, value2); value3.x = r.ReadSingle(); value3.y = r.ReadSingle(); material2.SetTextureScale(name2, value3); } catch { break; } } else if (a3 == "texRT") { string text5 = r.ReadString(); string text6 = r.ReadString(); } } else if (a2 == "col") { value4.r = r.ReadSingle(); value4.g = r.ReadSingle(); value4.b = r.ReadSingle(); value4.a = r.ReadSingle(); material2.SetColor(name2, value4); } else if (a2 == "vec") { value5.x = r.ReadSingle(); value5.y = r.ReadSingle(); value5.z = r.ReadSingle(); value5.w = r.ReadSingle(); material2.SetVector(name2, value5); } else if (a2 == "f") { float value6 = r.ReadSingle(); material2.SetFloat(name2, value6); } } } return(material2); }
// Token: 0x06000069 RID: 105 RVA: 0x000B7D04 File Offset: 0x000B6D04 public static GameObject LoadSkinMesh_R(string filename, string[] filename2, string slotname, TBodySkin bodyskin, int layer) { try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (ImportCM2.m_skinTempFile == null) { ImportCM2.m_skinTempFile = new byte[Math.Max(500000, afileBase.GetSize())]; } else if (ImportCM2.m_skinTempFile.Length < afileBase.GetSize()) { ImportCM2.m_skinTempFile = new byte[afileBase.GetSize()]; } afileBase.Read(ref ImportCM2.m_skinTempFile, afileBase.GetSize()); } } catch (Exception ex) { NDebug.Assert("ファイルが開けませんでした。" + filename + "\n" + ex.Message, false); } BinaryReader binaryReader = new BinaryReader(new MemoryStream(ImportCM2.m_skinTempFile), Encoding.UTF8); TBodySkin.OriVert oriVert = bodyskin.m_OriVert; GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject.layer = layer; GameObject gameObject2 = null; Hashtable hashtable = new Hashtable(); string text = binaryReader.ReadString(); if (text != "CM3D2_MESH") { NDebug.Assert("LoadSkinMesh_R 例外 : ヘッダーファイルが不正です。" + text, false); } int num = binaryReader.ReadInt32(); string str = binaryReader.ReadString(); gameObject.name = "_SM_" + str; string b = binaryReader.ReadString(); int num2 = binaryReader.ReadInt32(); List <GameObject> list = new List <GameObject>(); for (int i = 0; i < num2; i++) { GameObject gameObject3 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject3.layer = layer; gameObject3.name = binaryReader.ReadString(); list.Add(gameObject3); if (gameObject3.name == b) { gameObject2 = gameObject3; } hashtable[gameObject3.name] = gameObject3; bool flag = binaryReader.ReadByte() != 0; if (flag) { GameObject gameObject4 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject4.name = gameObject3.name + "_SCL_"; gameObject4.transform.parent = gameObject3.transform; hashtable[gameObject3.name + "&_SCL_"] = gameObject4; } } for (int j = 0; j < num2; j++) { int num3 = binaryReader.ReadInt32(); if (num3 >= 0) { list[j].transform.parent = list[num3].transform; } else { list[j].transform.parent = gameObject.transform; } } for (int k = 0; k < num2; k++) { Transform transform = list[k].transform; float x = binaryReader.ReadSingle(); float y = binaryReader.ReadSingle(); float z = binaryReader.ReadSingle(); transform.localPosition = new Vector3(x, y, z); float x2 = binaryReader.ReadSingle(); float y2 = binaryReader.ReadSingle(); float z2 = binaryReader.ReadSingle(); float w = binaryReader.ReadSingle(); transform.localRotation = new Quaternion(x2, y2, z2, w); if (2001 <= num) { bool flag2 = binaryReader.ReadBoolean(); if (flag2) { float x3 = binaryReader.ReadSingle(); float y3 = binaryReader.ReadSingle(); float z3 = binaryReader.ReadSingle(); transform.localScale = new Vector3(x3, y3, z3); } } } int num4 = binaryReader.ReadInt32(); int num5 = binaryReader.ReadInt32(); int num6 = binaryReader.ReadInt32(); oriVert.VCount = num4; oriVert.nSubMeshCount = num5; gameObject2.AddComponent(typeof(SkinnedMeshRenderer)); gameObject.AddComponent(typeof(Animation)); SkinnedMeshRenderer skinnedMeshRenderer = gameObject2.GetComponent <Renderer>() as SkinnedMeshRenderer; skinnedMeshRenderer.updateWhenOffscreen = true; Transform[] array = new Transform[num6]; for (int l = 0; l < num6; l++) { string text2 = binaryReader.ReadString(); if (hashtable.ContainsKey(text2)) { GameObject gameObject5; if (hashtable.ContainsKey(text2 + "&_SCL_")) { gameObject5 = (GameObject)hashtable[text2 + "&_SCL_"]; } else { gameObject5 = (GameObject)hashtable[text2]; } array[l] = gameObject5.transform; } } skinnedMeshRenderer.bones = array; Mesh mesh = new Mesh(); skinnedMeshRenderer.sharedMesh = mesh; Mesh mesh2 = mesh; Matrix4x4[] array2 = new Matrix4x4[num6]; for (int m = 0; m < num6; m++) { for (int n = 0; n < 16; n++) { array2[m][n] = binaryReader.ReadSingle(); } } mesh2.bindposes = array2; Vector3[] array3 = new Vector3[num4]; Vector3[] array4 = new Vector3[num4]; Vector2[] array5 = new Vector2[num4]; BoneWeight[] array6 = new BoneWeight[num4]; for (int num7 = 0; num7 < num4; num7++) { float num8 = binaryReader.ReadSingle(); float num9 = binaryReader.ReadSingle(); float new_z = binaryReader.ReadSingle(); array3[num7].Set(num8, num9, new_z); num8 = binaryReader.ReadSingle(); num9 = binaryReader.ReadSingle(); new_z = binaryReader.ReadSingle(); array4[num7].Set(num8, num9, new_z); num8 = binaryReader.ReadSingle(); num9 = binaryReader.ReadSingle(); array5[num7].Set(num8, num9); } mesh2.vertices = array3; mesh2.normals = array4; mesh2.uv = array5; oriVert.vOriVert = array3; oriVert.vOriNorm = array4; int num10 = binaryReader.ReadInt32(); if (num10 > 0) { Vector4[] array7 = new Vector4[num10]; for (int num11 = 0; num11 < num10; num11++) { float x3 = binaryReader.ReadSingle(); float y3 = binaryReader.ReadSingle(); float z3 = binaryReader.ReadSingle(); float w2 = binaryReader.ReadSingle(); array7[num11] = new Vector4(x3, y3, z3, w2); } mesh2.tangents = array7; } for (int num12 = 0; num12 < num4; num12++) { array6[num12].boneIndex0 = (int)binaryReader.ReadUInt16(); array6[num12].boneIndex1 = (int)binaryReader.ReadUInt16(); array6[num12].boneIndex2 = (int)binaryReader.ReadUInt16(); array6[num12].boneIndex3 = (int)binaryReader.ReadUInt16(); array6[num12].weight0 = binaryReader.ReadSingle(); array6[num12].weight1 = binaryReader.ReadSingle(); array6[num12].weight2 = binaryReader.ReadSingle(); array6[num12].weight3 = binaryReader.ReadSingle(); } mesh2.boneWeights = array6; mesh2.subMeshCount = num5; oriVert.bwWeight = array6; oriVert.nSubMeshCount = num5; oriVert.nSubMeshOriTri = new int[num5][]; for (int num13 = 0; num13 < num5; num13++) { int num14 = binaryReader.ReadInt32(); int[] array8 = new int[num14]; for (int num15 = 0; num15 < num14; num15++) { array8[num15] = (int)binaryReader.ReadUInt16(); } oriVert.nSubMeshOriTri[num13] = array8; mesh2.SetTriangles(array8, num13); } int num16 = binaryReader.ReadInt32(); Material[] array9 = new Material[num16]; for (int num17 = 0; num17 < num16; num17++) { Material material = ImportCM2.ReadMaterial(binaryReader, bodyskin, null, filename2[1 + num17]); array9[num17] = material; } skinnedMeshRenderer.materials = array9; binaryReader.Close(); return(gameObject); }
public void ProcParam(Maid master, Maid slave, Maid maid0, XtMasterSlave.MsLinkConfig p_mscfg) { //v0025 masterの不在を許可 if (!master && !master.body0 && !slave && !slave.body0) if (!slave && !slave.body0) { return; } //サイズ変更 if (master && master.body0) { master.gameObject.transform.localScale = new Vector3(Scale_Master, Scale_Master, Scale_Master); if (!master.boMAN) { XtMasterSlave.UpdateHitScale(master, Scale_Master, p_mscfg); } // XtMasterSlave.UpdateHitScale(master, Scale_Master * p_mscfg.Scale_HitCheckEffect); } slave.gameObject.transform.localScale = new Vector3(Scale_Slave, Scale_Slave, Scale_Slave); if (!slave.boMAN) { XtMasterSlave.UpdateHitScale(slave, Scale_Slave, p_mscfg); } // XtMasterSlave.UpdateHitScale(slave, Scale_Slave * p_mscfg.Scale_HitCheckEffect); if (master && master.body0) { // 男設定 chinkoサイズ・位置など if (master.boMAN) { XtMasterSlave.SetManVisible(master, !Master_Hide); //master.body0.SetChinkoVisible(Cnk_Visible); XtMasterSlave.SetChinkoVisible(master.body0, Cnk_Visible); //v0030 fix if (Cnk_Visible) { XtMasterSlave.SetChinkoScale(master.body0, Cnk_Scale); XtMasterSlave.SetChinkoPos(master.body0, XtMasterSlave.faTov3(Cnk_OffsetPos)); } XtMasterSlave.SetManAlpha(master, manAlpha); } else { XtMasterSlave.SetStateMaskItemsAll(master, Master_Hide); if (slave.boMAN) { //slave.body0.SetChinkoVisible(Cnk_Visible); XtMasterSlave.SetChinkoVisible(master.body0, Cnk_Visible); //v0030 fix if (Cnk_Visible) { XtMasterSlave.SetChinkoScale(slave.body0, Cnk_Scale); XtMasterSlave.SetChinkoPos(slave.body0, XtMasterSlave.faTov3(Cnk_OffsetPos)); } XtMasterSlave.SetManAlpha(slave, manAlpha); } } } #if DEBUG Console.WriteLine(string.Format("+Stgt_boHeadToCam={0} Stgt_boEyeToCam={1}", Stgt_boHeadToCam, Stgt_boEyeToCam)); #endif if (!slave.boMAN) { #if DEBUG Console.WriteLine(string.Format("-Stgt_boHeadToCam={0} Stgt_boEyeToCam={1}", Stgt_boHeadToCam, Stgt_boEyeToCam)); #endif slave.body0.boHeadToCam = Stgt_boHeadToCam; slave.body0.boEyeToCam = Stgt_boEyeToCam; Maid tgt = null; switch (Stgt_sBoneName) { case "Bip01 Head": if (maid0 && maid0.body0 && slave != maid0) { tgt = maid0; } break; case "_IK_vagina": if (maid0 && maid0.body0 && slave != maid0) { tgt = maid0; } break; case "ManBip Head": if (master && master.body0) { tgt = master; } break; case "chinko2": if (master && master.body0) { tgt = master; } break; default: Stgt_sBoneName = string.Empty; break; } if (tgt) { Transform tgt_tr = BoneLink.BoneLink.SearchObjName(tgt.body0.m_Bones.transform, Stgt_sBoneName, true); slave.EyeToTarget(tgt, GameUty.MillisecondToSecond(0), Stgt_sBoneName); } else { slave.EyeToReset(GameUty.MillisecondToSecond(0)); } slave.body0.boHeadToCam = Stgt_boHeadToCam; slave.body0.boEyeToCam = Stgt_boEyeToCam; } }
public static GameObject LoadMesh(string modelName) { AFileBase file = GameUty.FileOpen(modelName); if (!file.IsValid() || file.GetSize() == 0) { string name = modelName.Replace(@"model\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { Debug.LogError("File not valid"); return(null); } } using (BinaryReader r = new BinaryReader(new MemoryStream(file.ReadAll()))) { int layer = 0; // TBodySkin.OriVert oriVert = bodyskin.m_OriVert; GameObject gameObject1 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject1.layer = layer; GameObject gameObject2 = (GameObject)null; Hashtable hashtable = new Hashtable(); string str1 = r.ReadString(); if (str1 != "CM3D2_MESH") { return(null); } r.ReadInt32(); string str2 = r.ReadString(); string str3 = r.ReadString(); int num = r.ReadInt32(); List <GameObject> gameObjectList = new List <GameObject>(); for (int index = 0; index < num; ++index) { GameObject gameObject3 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject3.layer = layer; gameObject3.name = r.ReadString(); gameObjectList.Add(gameObject3); if (gameObject3.name == str3) { gameObject2 = gameObject3; } hashtable[(object)gameObject3.name] = (object)gameObject3; if ((int)r.ReadByte() != 0) { GameObject gameObject4 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject4.name = gameObject3.name + "_SCL_"; gameObject4.transform.parent = gameObject3.transform; hashtable[(object)(gameObject3.name + "&_SCL_")] = (object)gameObject4; } } for (int index1 = 0; index1 < num; ++index1) { int index2 = r.ReadInt32(); gameObjectList[index1].transform.parent = index2 < 0 ? gameObject1.transform : gameObjectList[index2].transform; } for (int index = 0; index < num; ++index) { Transform transform = gameObjectList[index].transform; float x1 = r.ReadSingle(); float y1 = r.ReadSingle(); float z1 = r.ReadSingle(); transform.localPosition = new Vector3(x1, y1, z1); float x2 = r.ReadSingle(); float y2 = r.ReadSingle(); float z2 = r.ReadSingle(); float w = r.ReadSingle(); transform.localRotation = new Quaternion(x2, y2, z2, w); } int length1 = r.ReadInt32(); int length2 = r.ReadInt32(); int length3 = r.ReadInt32(); // oriVert.VCount = length1; // oriVert.nSubMeshCount = length2; gameObject2.AddComponent(typeof(SkinnedMeshRenderer)); gameObject1.AddComponent(typeof(Animation)); SkinnedMeshRenderer component = gameObject2.GetComponent <Renderer>() as SkinnedMeshRenderer; component.updateWhenOffscreen = true; // if (!bodyskin.body.boMAN) // { // if (slotname == "head") // component.castShadows = false; // if (bodyskin.Category == "chikubi") // component.castShadows = false; // if (bodyskin.Category.IndexOf("seieki_") == 0) // component.castShadows = false; // } // bodyskin.listDEL.Add((UnityEngine.Object) gameObject2); Transform[] transformArray = new Transform[length3]; for (int index = 0; index < length3; ++index) { string str4 = r.ReadString(); if (!hashtable.ContainsKey((object)str4)) { Debug.LogError((object)("nullbone= " + str4)); } else { GameObject gameObject3 = !hashtable.ContainsKey((object)(str4 + "&_SCL_")) ? (GameObject)hashtable[(object)str4] : (GameObject)hashtable[(object)(str4 + "&_SCL_")]; transformArray[index] = gameObject3.transform; } } component.bones = transformArray; Mesh mesh1 = new Mesh(); component.sharedMesh = mesh1; Mesh mesh2 = mesh1; // bodyskin.listDEL.Add((UnityEngine.Object) mesh2); Matrix4x4[] matrix4x4Array = new Matrix4x4[length3]; for (int index1 = 0; index1 < length3; ++index1) { for (int index2 = 0; index2 < 16; ++index2) { matrix4x4Array[index1][index2] = r.ReadSingle(); } } mesh2.bindposes = matrix4x4Array; Vector3[] vector3Array1 = new Vector3[length1]; Vector3[] vector3Array2 = new Vector3[length1]; Vector2[] vector2Array = new Vector2[length1]; BoneWeight[] boneWeightArray = new BoneWeight[length1]; for (int index = 0; index < length1; ++index) { float new_x1 = r.ReadSingle(); float new_y1 = r.ReadSingle(); float new_z1 = r.ReadSingle(); vector3Array1[index].Set(new_x1, new_y1, new_z1); float new_x2 = r.ReadSingle(); float new_y2 = r.ReadSingle(); float new_z2 = r.ReadSingle(); vector3Array2[index].Set(new_x2, new_y2, new_z2); float new_x3 = r.ReadSingle(); float new_y3 = r.ReadSingle(); vector2Array[index].Set(new_x3, new_y3); } mesh2.vertices = vector3Array1; mesh2.normals = vector3Array2; mesh2.uv = vector2Array; // oriVert.vOriVert = vector3Array1; // oriVert.vOriNorm = vector3Array2; int length4 = r.ReadInt32(); if (length4 > 0) { Vector4[] vector4Array = new Vector4[length4]; for (int index = 0; index < length4; ++index) { float x = r.ReadSingle(); float y = r.ReadSingle(); float z = r.ReadSingle(); float w = r.ReadSingle(); vector4Array[index] = new Vector4(x, y, z, w); } mesh2.tangents = vector4Array; } for (int index = 0; index < length1; ++index) { boneWeightArray[index].boneIndex0 = (int)r.ReadUInt16(); boneWeightArray[index].boneIndex1 = (int)r.ReadUInt16(); boneWeightArray[index].boneIndex2 = (int)r.ReadUInt16(); boneWeightArray[index].boneIndex3 = (int)r.ReadUInt16(); boneWeightArray[index].weight0 = r.ReadSingle(); boneWeightArray[index].weight1 = r.ReadSingle(); boneWeightArray[index].weight2 = r.ReadSingle(); boneWeightArray[index].weight3 = r.ReadSingle(); } mesh2.boneWeights = boneWeightArray; mesh2.subMeshCount = length2; // oriVert.bwWeight = boneWeightArray; // oriVert.nSubMeshCount = length2; // oriVert.nSubMeshOriTri = new int[length2][]; for (int submesh = 0; submesh < length2; ++submesh) { int length5 = r.ReadInt32(); int[] triangles = new int[length5]; for (int index = 0; index < length5; ++index) { triangles[index] = (int)r.ReadUInt16(); } // oriVert.nSubMeshOriTri[submesh] = triangles; mesh2.SetTriangles(triangles, submesh); } int length6 = r.ReadInt32(); Material[] materialArray = new Material[length6]; for (int index = 0; index < length6; ++index) { Material material = ReadMaterial(r, null); materialArray[index] = material; } component.materials = materialArray; r.Close(); return(gameObject1); } }
public static MenuInfo LoadMenu(string menuFileName) { AFileBase file = GameUty.FileOpen(menuFileName); if (!file.IsValid() || file.GetSize() == 0) { string name = menuFileName.Replace(@"menu\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { name = menuFileName.Replace(@"menu\man\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { throw new FileNotFoundException(name); } } } MenuInfo mi = new MenuInfo(); mi.menuFileName = menuFileName; BinaryReader binaryReader = new BinaryReader(new MemoryStream(file.ReadAll()), System.Text.Encoding.UTF8); string str1 = binaryReader.ReadString(); NDebug.Assert(str1 == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + str1); binaryReader.ReadInt32(); string path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); long num1 = (long)binaryReader.ReadInt32(); string sss = string.Empty; string str2 = string.Empty; string empty1 = string.Empty; try { while (true) { string stringCom; string[] stringList; do { do { do { MaidParts.PARTS_COLOR partsColor = MaidParts.PARTS_COLOR.NONE; do { sss = readCom(binaryReader); if (sss == null) { goto label_61; } stringCom = UTY.GetStringCom(sss); stringList = UTY.GetStringList(sss); if (readMenuProp(stringCom, stringList, ref partsColor, ref mi) == true) { goto label_40; } }while (stringList.Length != 6); string str4 = stringList[5]; try { partsColor = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), str4.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + str4); } mi.partsColor = partsColor; continue; label_40: if (stringCom == "icon" || stringCom == "icons") { mi.iconTextureName = stringList[1]; } }while (stringCom == "iconl" || stringCom == "setstr" || stringCom == "アイテムパラメータ"); if (stringCom == "saveitem") { string str3 = stringList[1]; if (str3 == string.Empty) { UnityEngine.Debug.LogError("err SaveItem \"" + str3); } if (str3 == null) { UnityEngine.Debug.LogError("err SaveItem null=\"" + str3); } } }while (stringCom == "catno"); if (stringCom == "additem") { mi.modelName = stringList[1]; } else if (stringCom == "delitem" || stringCom == "unsetitem") { mi.delOnly = true; } else if (stringCom == "priority") { mi.priority = float.Parse(stringList[1]); } }while (!(stringCom == "メニューフォルダ") || !(stringList[1].ToLower() == "man")); mi.isMan = true; } } catch { UnityEngine.Debug.LogError("Failed to parse menu file " + Path.GetFileName(path)); // UnityEngine.Debug.LogError(("Exception " + Path.GetFileName(path) + " 現在処理中だった行 = " + sss + " 以前の行 = " + str2 + " " + ex.Message + "StackTrace:\n" + ex.StackTrace)); throw; } label_61: binaryReader.Close(); return(mi); }
private static MenuObj getMenu(string menuFileName) { //UnityEngine.Debug.Log("Fetching Menu " + menuFileName); MenuObj menu = new MenuObj(); byte[] cd; using (AFileBase afileBase = GameUty.FileOpen(menuFileName, (AFileSystemBase)null)) { if (afileBase != null && afileBase.IsValid()) { //UnityEngine.Debug.Log("Reading bytes"); cd = afileBase.ReadAll(); using (BinaryReader binaryReader = new BinaryReader((Stream) new MemoryStream(cd), Encoding.UTF8)) { //Useless header info??? //UnityEngine.Debug.Log("Reading header"); menu.header.CM3D2_MENU = binaryReader.ReadString(); menu.header.temp1 = binaryReader.ReadInt32(); menu.header.temp2 = binaryReader.ReadString(); menu.header.temp3 = binaryReader.ReadString(); menu.header.temp4 = binaryReader.ReadString(); menu.header.temp5 = binaryReader.ReadString(); menu.header.temp6 = binaryReader.ReadInt32(); bool end = false; //UnityEngine.Debug.Log("Reading commands"); //Blocks do { MenuCommandObj command = new MenuCommandObj(); string str4; do { byte byt = binaryReader.ReadByte(); command.byt = byt; int num2 = (int)byt; str4 = string.Empty; if (num2 != 0) { for (int index = 0; index < num2; ++index) { string str = binaryReader.ReadString(); command.nativeStrings.Add(str); str4 = str4 + "\"" + str + "\" "; } } else { end = true; } }while (str4 == string.Empty && !end); if (!end) { string stringCom = UTY.GetStringCom(str4); string[] stringList = UTY.GetStringList(str4); command.stringCom = stringCom; command.stringList = stringList; menu.commands.Add(command); if (stringCom.Equals("category")) { //Get the category menu.category = stringList[1]; } } }while (!end); } } else { if (afileBase == null) { UnityEngine.Debug.Log("Split Hair Sliders: null AFileBase"); } else { if (!afileBase.IsValid()) { UnityEngine.Debug.Log("Split Hair Sliders: invalid AFileBase"); } } } } return(menu); }