private static void CreateMaidClassNameMap()
        {
            if (0 < maidClassIDtoNameDic.Count)
            {
                return;
            }
            int maxVal = 0;

            using (AFileBase aFileBase = GameUty.FileSystem.FileOpen("maid_class_infotext.nei"))
            {
                using (CsvParser csvParser = new CsvParser())
                {
                    bool condition = csvParser.Open(aFileBase);
                    NDebug.Assert(condition, "file open error[maid_class_infotext.nei]");
                    for (int i = 1; i < csvParser.max_cell_y; i++)
                    {
                        if (!csvParser.IsCellToExistData(0, i))
                        {
                            continue;
                        }
                        string cellAsString = csvParser.GetCellAsString(0, i);
                        maidClassIDtoNameDic.Add(maxVal, cellAsString);
                        maxVal++;
                    }
                }
            }
        }
        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);
 }
Example #5
0
        public Dictionary <TBody.SlotID, Item> Load(string filename)
        {
            trgtMenu        = ACCMenu.Load(filename);
            nameInterlocked = false;
            if (trgtMenu != null)
            {
                showDialog = true;
                return(trgtMenu.itemSlots);
            }
            else
            {
                // エラー確認用処理
                AFileBase aFileBase = global::GameUty.FileOpen(filename);
                if (aFileBase.IsValid())
                {
                    //const int BUFFER_SIZE = 8192;

                    string dir     = OutputUtil.Instance.GetExportDirectory();
                    string 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 void m_dicSliderPartsTypeBtnName_ext()
        {
            if (m_dicSliderPartsTypeBtnName_ext_flag)
            {
                return;
            }
            m_dicSliderPartsTypeBtnName_ext_flag = true;

            string text = "edit_category_define_creator.nei";

            Dictionary <SceneEditInfo.EMenuCategory, int> dictionary = new Dictionary <SceneEditInfo.EMenuCategory, int>();

            using (AFileBase afileBase = GameUty.FileSystemMod.FileOpen(text))
            {
                using (CsvParser csvParser = new CsvParser())
                {
                    bool condition = csvParser.Open(afileBase);
                    NDebug.Assert(condition, text + "\nopen failed.");
                    for (int i = 1; i < csvParser.max_cell_y; i++)
                    {
                        if (csvParser.IsCellToExistData(0, i))
                        {
                            int num = 0;
                            MPN key = MPN.null_mpn;
                            try
                            {
                                key = (MPN)Enum.Parse(typeof(MPN), csvParser.GetCellAsString(num++, i));
                            }
                            catch
                            {
                            }
                            SceneEditInfo.CCateNameType ccateNameType = new SceneEditInfo.CCateNameType();
                            ccateNameType.m_eMenuCate = SceneEditInfo.EMenuCategory.頭;
                            try
                            {
                                ccateNameType.m_eMenuCate = (SceneEditInfo.EMenuCategory)Enum.Parse(typeof(SceneEditInfo.EMenuCategory), csvParser.GetCellAsString(num++, i));
                            }
                            catch
                            {
                            }
                            ccateNameType.m_eType = SceneEditInfo.CCateNameType.EType.Item;
                            try
                            {
                                ccateNameType.m_eType = (SceneEditInfo.CCateNameType.EType)Enum.Parse(typeof(SceneEditInfo.CCateNameType.EType), csvParser.GetCellAsString(num++, i));
                            }
                            catch
                            {
                            }
                            ccateNameType.m_ePartsType          = csvParser.GetCellAsString(num++, i);
                            ccateNameType.m_strBtnPartsTypeName = csvParser.GetCellAsString(num++, i);
                            ccateNameType.m_nIdx = 50 + i;
                            SceneEditInfo.dicPartsTypePair_[key] = ccateNameType;
                        }
                    }
                }
            }
        }
Example #7
0
        // add data from *phot_bg_list*.nei files to PhotoBGData.bg_data_

        public static void PhotoBGext()
        {
            string[] bg_nelist = null;
            bg_nelist = GameUty.FileSystemMod.GetList("PhotoBG_NEI", AFileSystemBase.ListType.AllFile);


            if (bg_nelist == null || 0 == bg_nelist.Length)
            {
                return;
            }
            foreach (string str in bg_nelist)
            {
                string nei_filename = Path.GetFileName(str);

                if (Path.GetExtension(nei_filename) == ".nei" && nei_filename != "phot_bg_list.nei")
                {
                    using (AFileBase aFileBase2 = GameUty.FileSystemMod.FileOpen(nei_filename))
                    {
                        using (CsvParser csvParser = new CsvParser())
                        {
                            if (csvParser.Open(aFileBase2))
                            {
                                for (int k = 1; k < csvParser.max_cell_y; k++)
                                {
                                    int         num2        = 1;
                                    PhotoBGData photoBGData = new PhotoBGData(); // this requires prepatched assembly to compile
                                    photoBGData.id                 = "";
                                    photoBGData.category           = csvParser.GetCellAsString(num2++, k);
                                    photoBGData.name               = csvParser.GetCellAsString(num2++, k);
                                    photoBGData.create_prefab_name = csvParser.GetCellAsString(num2++, k);
                                    //assign id from prefab/bundles string
                                    //this is done because save/load of objects in photomode is based on id
                                    if (!string.IsNullOrEmpty(photoBGData.create_prefab_name))
                                    {
                                        photoBGData.id = photoBGData.create_prefab_name.GetHashCode().ToString();
                                        // this feels wrong, but i suspect the KISS might convert id to int at some point
                                        // so i'd rather be on safe side
                                    }

                                    string check = csvParser.GetCellAsString(num2++, k);
                                    if (String.IsNullOrEmpty(check) || GameUty.BgFiles.ContainsKey(photoBGData.create_prefab_name.ToLower() + ".asset_bg"))
                                    {
                                        PhotoBGData.bg_data_.Add(photoBGData);
                                    }
                                }
                            }
                            else
                            {
                                Debug.Log($"Skipping invalid file: Mod/{str}");
                            }
                        }
                    }
                }
            }
        }
 // Token: 0x06000255 RID: 597 RVA: 0x00014A44 File Offset: 0x00012C44
 public void Copy(AFileBase infile, string outfilepath)
 {
     using (BinaryWriter binaryWriter = new BinaryWriter(File.OpenWrite(outfilepath)))
     {
         byte[] buffer = new byte[8196];
         int    count;
         while ((count = infile.Read(ref buffer, 8196)) > 0)
         {
             binaryWriter.Write(buffer, 0, count);
         }
     }
 }
Example #9
0
        // 外部DLL依存
        public void Copy(AFileBase infile, string outfilepath)
        {
            const int buffSize = 8196;

            using (var writer = new BinaryWriter(File.OpenWrite(outfilepath)))  {
                var buff   = new byte[buffSize];
                int length = 0;
                while ((length = infile.Read(ref buff, buffSize)) > 0)
                {
                    writer.Write(buff, 0, length);
                }
            }
        }
Example #10
0
        // add data from *phot_motion_list*.nei files to PhotoMotionData.motion_data_
        public static void PhotMotExt()
        {
            string[] PhotoMotNei = null;

            PhotoMotNei = GameUty.FileSystemMod.GetList("PhotMot_NEI", AFileSystemBase.ListType.AllFile);


            //   if (PhotoMotNei == null || PhotoMotNei.Length == 0)
            //   { return; }

            foreach (string str in PhotoMotNei)
            {
                string nei_filename = Path.GetFileName(str);

                if (Path.GetExtension(nei_filename) == ".nei" && nei_filename != "phot_motion_list.nei")
                {
                    using (AFileBase aFileBase = GameUty.FileSystem.FileOpen(nei_filename))
                    {
                        using (CsvParser csvParser = new CsvParser())
                        {
                            if (csvParser.Open(aFileBase))
                            {
                                for (int i = 1; i < csvParser.max_cell_y; i++)
                                {
                                    int             num             = 0;
                                    PhotoMotionData photoMotionData = new PhotoMotionData(); // this requires prepatched assembly to compile
                                    photoMotionData.id                = (long)csvParser.GetCellAsInteger(num++, i);
                                    photoMotionData.category          = csvParser.GetCellAsString(num++, i);
                                    photoMotionData.name              = csvParser.GetCellAsString(num++, i);
                                    photoMotionData.direct_file       = csvParser.GetCellAsString(num++, i);
                                    photoMotionData.is_loop           = (csvParser.GetCellAsString(num++, i) == "○");
                                    photoMotionData.call_script_fil   = csvParser.GetCellAsString(num++, i);
                                    photoMotionData.call_script_label = csvParser.GetCellAsString(num++, i);
                                    photoMotionData.is_mod            = false;
                                    string cellAsString = csvParser.GetCellAsString(num++, i);
                                    bool   flag         = csvParser.GetCellAsString(num++, i) == "○";
                                    photoMotionData.use_animekey_mune_l = (photoMotionData.use_animekey_mune_r = flag);
                                    photoMotionData.is_man_pose         = (csvParser.GetCellAsString(num++, i) == "○");
                                    PhotoMotionData.motion_data_.Add(photoMotionData);
                                }
                            }
                            else
                            {
                                Debug.Log($"Skipping invalid file: Mod/{str}");
                            }
                        }
                    }
                }
            }
        }
        private static void CreateEnabledYotogiClassMap()
        {
            Type       yotogiClassType = typeof(Maid).Assembly.GetType("param.YotogiClassType");
            MethodInfo getYotogiClassIdFromNameMethod = typeof(MaidParam).GetMethod(
                "GetYotogiClassIdFromName",
                BindingFlags.Public | BindingFlags.Static);
            bool isOldVersion = yotogiClassType != null;

            Action <string> readYotogiClasses = delegate(string fileName)
            {
                fileName += ".nei";
                if (!GameUty.FileSystem.IsExistentFile(fileName))
                {
                    return;
                }
                using (AFileBase aFileBase = GameUty.FileSystem.FileOpen(fileName))
                {
                    using (CsvParser csvParser = new CsvParser())
                    {
                        bool condition = csvParser.Open(aFileBase);
                        NDebug.Assert(condition, fileName + " open failed.");
                        for (int k = 1; k < csvParser.max_cell_y; k++)
                        {
                            if (!csvParser.IsCellToExistData(0, k))
                            {
                                continue;
                            }
                            string className = csvParser.GetCellAsString(0, k);
                            int    key       = isOldVersion
                                      ? (int)Enum.Parse(yotogiClassType, className, true)
                                      : (int)getYotogiClassIdFromNameMethod.Invoke(null, new object[] { className });
                            if (!yotogiClassToNameDic.ContainsKey(key))
                            {
                                yotogiClassToNameDic.Add(key, className);
                            }
                            EnabledYotogiClasses.Add(key);
                        }
                    }
                }
            };

            readYotogiClasses("yotogi_class_enabled_list");
            foreach (string path in GameUty.PathList)
            {
                readYotogiClasses($"yotogi_class_enabled_list_{path}");
            }
            EnabledYotogiClasses.Sort();
        }
Example #12
0
 public byte[] LoadInternal(string filename)
 {
     try {
         using (AFileBase aFileBase = global::GameUty.FileOpen(filename)) {
             if (!aFileBase.IsValid())
             {
                 var msg = LogUtil.Error("指定ファイルが見つかりません。file=", filename);
                 throw new ACCException(msg.ToString());
             }
             return(aFileBase.ReadAll());
         }
     } catch (ACCException) {
         throw;
     } catch (Exception e) {
         var msg = LogUtil.Error("指定ファイルが読み込めませんでした。", filename, e);
         throw new ACCException(msg.ToString(), e);
     }
 }
        public static void m_dicPartsTypeWearMode_ext()
        {
            if (m_dicPartsTypeWearMode_ext_flag)
            {
                return;
            }
            m_dicPartsTypeWearMode_ext_flag = true;
            string text = "edit_mask_define_creator.nei";

            SceneEditInfo.dicPartsTypeWearMode_ = new Dictionary <MPN, TBody.MaskMode>();
            using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
            {
                using (CsvParser csvParser = new CsvParser())
                {
                    bool condition = csvParser.Open(afileBase);

                    for (int i = 1; i < csvParser.max_cell_y; i++)
                    {
                        if (csvParser.IsCellToExistData(0, i))
                        {
                            int num = 0;
                            MPN key = MPN.null_mpn;
                            try
                            {
                                key = (MPN)Enum.Parse(typeof(MPN), csvParser.GetCellAsString(num++, i));
                            }
                            catch
                            {}
                            TBody.MaskMode value = TBody.MaskMode.None;
                            try
                            {
                                value = (TBody.MaskMode)Enum.Parse(typeof(TBody.MaskMode), csvParser.GetCellAsString(num++, i));
                            }
                            catch
                            {
                            }

                            SceneEditInfo.dicPartsTypeWearMode_[key] = value;
                        }
                    }
                }
            }
        }
Example #14
0
        public Stream GetStream(string filename, out bool onBuffer)
        {
            try {
                AFileBase aFileBase = global::GameUty.FileOpen(filename);
                if (!aFileBase.IsValid())
                {
                    var msg = LogUtil.Error("指定ファイルが見つかりません。file=", filename);
                    throw new ACCException(msg.ToString());
                }

                onBuffer = aFileBase.GetSize() < BUFFER_SIZE;
                return(new BufferedStream(new FileBaseStream(aFileBase), BUFFER_SIZE));
            } catch (ACCException) {
                throw;
            } catch (Exception e) {
                var msg = LogUtil.Error("指定ファイルが読み込めませんでした。", filename, e);
                throw new ACCException(msg.ToString(), e);
            }
        }
Example #15
0
 // 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 void m_dicPartsTypeCamera_ext()
        {
            if (m_dicPartsTypeCamera_ext_flag)
            {
                return;
            }
            m_dicPartsTypeCamera_ext_flag = true;
            string text = "edit_attention_point_define_creator.nei";

            using (AFileBase afileBase = GameUty.FileSystemMod.FileOpen(text))
            {
                using (CsvParser csvParser = new CsvParser())
                {
                    bool condition = csvParser.Open(afileBase);
                    NDebug.Assert(condition, text + "\nopen failed.");
                    for (int i = 1; i < csvParser.max_cell_y; i++)
                    {
                        if (csvParser.IsCellToExistData(0, i))
                        {
                            SceneEditInfo.CamToBone value = default(SceneEditInfo.CamToBone);
                            int num = 0;
                            MPN key = MPN.null_mpn;
                            try
                            {
                                key = (MPN)Enum.Parse(typeof(MPN), csvParser.GetCellAsString(num++, i));
                            }
                            catch
                            {}
                            value.bone     = csvParser.GetCellAsString(num++, i);
                            value.angle    = wf.Parse.Vector2(csvParser.GetCellAsString(num++, i));
                            value.distance = csvParser.GetCellAsReal(num++, i);
                            SceneEditInfo.m_dicPartsTypeCamera_[key] = value;
                        }
                    }
                }
            }
        }
    // 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);
    }
Example #18
0
 public FileBaseStream(AFileBase file)
 {
     filebase = file;
 }
Example #19
0
        // add data to desk_item_detail.nei and desk_item_category.nei
        public static void DeskData_Ext()
        {
#if DEBUG
            Console.WriteLine("Console.Writeline says hi");
            Debug.Log("Debug.Log says hi");
#endif

            string[] DeskItemList = null;
            DeskItemList = GameUty.FileSystemMod.GetList("DeskItem_NEI", AFileSystemBase.ListType.AllFile);
            if (DeskItemList == null || DeskItemList.Length == 0)
            {
                return;
            }

            foreach (string str in  DeskItemList)
            {
                string neifile   = Path.GetFileName(str);
                string extension = Path.GetExtension(neifile);

                // check if file is indeed a .nei file and it snot mennt to overwrite base files
                // also check if the file is category type or detail type to determine the processing
                // only files that contain category in their name are assumed to be category files all others nei files are assumbed to be detail files

                if (neifile.Contains("category") && extension == ".nei" && neifile != "desk_item_category.nei")
                {
                    using (AFileBase afileBase = GameUty.FileSystem.FileOpen(neifile))
                    {
                        using (CsvParser csvParser = new CsvParser())
                        {
                            bool condition = csvParser.Open(afileBase);
                            for (int k = 1; k < csvParser.max_cell_y; k++)
                            {
                                if (!csvParser.IsCellToExistData(0, k))
                                {
                                    break;
                                }
                                int    cellAsInteger = csvParser.GetCellAsInteger(0, k);
                                string cellAsString  = csvParser.GetCellAsString(1, k);
                                if (!DeskManager.item_category_data_dic_.ContainsKey(cellAsInteger))
                                {
                                    DeskManager.item_category_data_dic_.Add(cellAsInteger, cellAsString);
                                }
                            }
                        }
                    }
                }
                else if (neifile != "desk_item_detail.nei" && extension == ".nei")
                {
                    using (AFileBase afileBase = GameUty.FileSystem.FileOpen(neifile))
                    {
                        using (CsvParser csvParser = new CsvParser())
                        {
                            if (csvParser.Open(afileBase))
                            {
                                for (int j = 1; j < csvParser.max_cell_y; j++)
                                {
                                    if (csvParser.IsCellToExistData(0, j))
                                    {
                                        int cellAsInteger2            = csvParser.GetCellAsInteger(0, j);
                                        DeskManager.ItemData itemData = new DeskManager.ItemData(csvParser, j);


                                        // check if it's a prefab data and add it if it is
                                        // is impossible to check if prefab exists in resources files
                                        // so if referenced prefab doesn't exist i ngame files, the entry isn't going to work properly in game
                                        if (!string.IsNullOrEmpty(itemData.prefab_name))
                                        {
                                            itemData.id = itemData.prefab_name.GetHashCode();// override the id from file with hash of prefab string to minimize id conflicts
                                            DeskManager.item_detail_data_dic_.Add(itemData.id, itemData);
                                        }

                                        // check if entry refers to asset bundle, and if it is, check if it exists before addding the data
                                        else if (!string.IsNullOrEmpty(itemData.asset_name) && GameUty.BgFiles.ContainsKey(itemData.asset_name + ".asset_bg"))
                                        {
                                            itemData.id = itemData.asset_name.GetHashCode();
                                            DeskManager.item_detail_data_dic_.Add(itemData.id, itemData);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Debug.Log($"Skipping invalid file: Mod/{str}");
                            }
                        }
                    }
                }
            }
        }
        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);
        }
    // 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: 0x06000237 RID: 567 RVA: 0x00014590 File Offset: 0x00012790
 public FileBaseStream(AFileBase file)
 {
     this.filebase = file;
 }
Example #24
0
        public static void PmatHandler()
        {
            FieldInfo m_hashPriorityMaterials = typeof(ImportCM).GetField("m_hashPriorityMaterials",
                                                                          BindingFlags.Static | BindingFlags.NonPublic);
            var pmadt_dic_value = m_hashPriorityMaterials.GetValue(null);
            Dictionary <int, KeyValuePair <string, float> > pmatlist = new Dictionary <int, KeyValuePair <string, float> > ();
            Dictionary <int, string> DupFilter = new Dictionary <int, string>();

            if (pmadt_dic_value == null)
            {
                string[] gamepmat = GameUty.FileSystem.GetList("prioritymaterial", AFileSystemBase.ListType.AllFile);
                string[] modpmat  = GameUty.m_ModFileSystem.GetFileListAtExtension(".pmat");

                if (modpmat != null && 0 < modpmat.Length)
                {
                    for (int i = 0; i < modpmat.Length; i++)
                    {
                        if (Path.GetExtension(modpmat[i]) == ".pmat")
                        {
                            string filename = Path.GetFileName(modpmat[i]);
                            using (AFileBase aFileBase = GameUty.FileSystemMod.FileOpen(filename))
                            {
                                if (aFileBase.IsValid())
                                {
                                    byte[] buffer = aFileBase.ReadAll();
                                    using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8))
                                    {
                                        string a = binaryReader.ReadString();
                                        if (a == "CM3D2_PMATERIAL")
                                        {
                                            int    num   = binaryReader.ReadInt32();
                                            int    key   = binaryReader.ReadInt32();
                                            string key2  = binaryReader.ReadString();
                                            float  value = binaryReader.ReadSingle();
                                            if (!pmatlist.ContainsKey(key))
                                            {
                                                DupFilter.Add(key, filename);
                                                pmatlist.Add(key, new KeyValuePair <string, float>(key2, value));
                                            }
                                            else
                                            {
                                                Debug.LogWarning($"Skipping {filename}  because its target material has already been changed by {DupFilter[key]}  ");
                                            }
                                        }
                                        else
                                        {
                                            Debug.Log("ヘッダーエラー\n" + filename + "File header of Mod .pmat file is invalid! skipping it!");
                                        }
                                    }
                                }
                                else
                                {
                                    Debug.Log(filename + "を開けませんでした ( Mod .pmat file is invalid! skipping it)");
                                }
                            }
                        }
                    }
                }


                if (gamepmat != null && 0 < gamepmat.Length)
                {
                    for (int i = 0; i < gamepmat.Length; i++)
                    {
                        if (Path.GetExtension(gamepmat[i]) == ".pmat")
                        {
                            string text = gamepmat[i];
                            using (AFileBase aFileBase = GameUty.FileSystem.FileOpen(text))
                            {
                                if (aFileBase.IsValid())
                                {
                                    byte[] buffer = aFileBase.ReadAll();
                                    using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8))
                                    {
                                        string a = binaryReader.ReadString();
                                        if (a == "CM3D2_PMATERIAL")
                                        {
                                            int    num   = binaryReader.ReadInt32();
                                            int    key   = binaryReader.ReadInt32();
                                            string key2  = binaryReader.ReadString();
                                            float  value = binaryReader.ReadSingle();
                                            if (!pmatlist.ContainsKey(key))
                                            {
                                                pmatlist.Add(key, new KeyValuePair <string, float>(key2, value));
                                            }
                                        }
                                        else
                                        {
                                            { Debug.Log("ヘッダーエラー\n" + text + "File header of official .pmat file or Mod override is invalid! skipping it!"); }
                                        }
                                    }
                                }
                                else
                                {
                                    { Debug.Log(text + "を開けませんでした ( Official .pmat file or Mod override is invalid! skipping it)"); }
                                }
                            }
                        }
                    }
                }

                m_hashPriorityMaterials.SetValue(null, pmatlist);
            }
        }
Example #25
0
        // add data from *phot_bg_object_list*.nei files to PhotoBGObjectData.bg_data_
        public static void PhotoBGobjext()
        {
            string[] BgObj_list = null;

            BgObj_list = GameUty.FileSystemMod.GetList("PhotoBG_OBJ_NEI", AFileSystemBase.ListType.AllFile);


            if (BgObj_list == null || 0 == BgObj_list.Length)
            {
                return;
            }


            foreach (string str in BgObj_list)
            {
                string nei_filename = Path.GetFileName(str);


                if (Path.GetExtension(nei_filename) == ".nei" && nei_filename != "phot_bg_object_list.nei")
                {
                    using (AFileBase aFileBase = GameUty.FileSystemMod.FileOpen(nei_filename))
                    {
                        using (CsvParser csvParser = new CsvParser())
                        {
                            if (csvParser.Open(aFileBase))
                            {
                                for (int i = 1; i < csvParser.max_cell_y; i++)
                                {
                                    int num = 1;
                                    PhotoBGObjectData photoBGObjectData = new PhotoBGObjectData(); // this requires prepatched assembly to compile
                                    photoBGObjectData.id                       = 0;                // not sure if't necessary for id to actually have a value
                                    photoBGObjectData.category                 = csvParser.GetCellAsString(num++, i);
                                    photoBGObjectData.name                     = csvParser.GetCellAsString(num++, i);
                                    photoBGObjectData.create_prefab_name       = csvParser.GetCellAsString(num++, i);
                                    photoBGObjectData.create_asset_bundle_name = csvParser.GetCellAsString(num++, i);
                                    //assign id from rpefab/bundles string
                                    //this is done because save/load of objects in photomode is based on id
                                    if (!string.IsNullOrEmpty(photoBGObjectData.create_prefab_name))
                                    {
                                        photoBGObjectData.id = photoBGObjectData.create_prefab_name.GetHashCode();
                                    }
                                    else if (!string.IsNullOrEmpty(photoBGObjectData.create_asset_bundle_name))
                                    {
                                        photoBGObjectData.id = photoBGObjectData.create_asset_bundle_name.GetHashCode();
                                    }
                                    string check = csvParser.GetCellAsString(num++, i);
                                    if (String.IsNullOrEmpty(check) || GameUty.BgFiles.ContainsKey(photoBGObjectData.create_asset_bundle_name.ToLower() + ".asset_bg"))
                                    {
                                        PhotoBGObjectData.bg_data_.Add(photoBGObjectData);
                                    }
                                }
                            }
                            else
                            {
                                Debug.Log($"Skipping invalid file: Mod/{str}");
                            }
                        }
                    }
                }
            }
        }
        // 外部DLL依存
        public void Copy(AFileBase infile, string outfilepath) {
            const int buffSize = 8196;
            using ( var writer = new BinaryWriter(File.OpenWrite(outfilepath)) )  {

                var buff = new byte[buffSize];
                int length = 0;
                while ((length = infile.Read(ref buff, buffSize)) > 0) {
                    writer.Write(buff, 0, length);
                }
            }
        }
 public FileBaseStream(AFileBase file) {
     this.filebase = file;
 }
        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);
        }
        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);
        }
        static void YotogiStage_CreateData()
        {
            //Get the Dictionary
            Dictionary <int, YotogiStage.Data> basicsData = (Dictionary <int, YotogiStage.Data>) typeof(YotogiStage).GetField("basicDatas", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

            //Create folders if they dont exist
            string mainPath = UTY.gameProjectPath + "\\Mod\\[YotogiAnywhere]\\[NewStages]";

            if (!Directory.Exists(mainPath))
            {
                Directory.CreateDirectory(mainPath);
            }

            if (YotogiAnywhere.newStageIds == null)
            {
                YotogiAnywhere.newStageIds = new List <int>();
            }

            //Get the data in folders
            string[] newStagesDirs = Directory.GetDirectories(mainPath);
            for (int i = 0; i < newStagesDirs.Length; i++)
            {
                DirectoryInfo di        = new DirectoryInfo(newStagesDirs[i]);
                string        stageName = di.Name;

                //Wow this is bad I should have done something better than a bunch of if statements
                if (Directory.Exists(mainPath + "\\" + stageName + "\\[Day]"))
                {
                    if (Directory.Exists(mainPath + "\\" + stageName + "\\[Night]"))
                    {
                        int maxId = -1;
                        YotogiStage.Data stageData = null;

                        //Try to find stage in existing data
                        foreach (KeyValuePair <int, YotogiStage.Data> kvp in basicsData)
                        {
                            if (kvp.Value.uniqueName.Equals(stageName))
                            {
                                stageData = kvp.Value;
                                break;
                            }

                            //Also get the max Id
                            maxId = System.Math.Max(maxId, kvp.Value.id);
                        }

                        //Create new if it does not exist
                        if (stageData == null)
                        {
                            //Increment from max Id
                            maxId += 10;

                            //Add to list of new ones
                            if (!YotogiAnywhere.newStageIds.Contains(maxId))
                            {
                                YotogiAnywhere.newStageIds.Add(maxId);
                                CsvCommonIdManager commonIdManager = (CsvCommonIdManager)typeof(YotogiStage).GetField("commonIdManager", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
                                commonIdManager.idMap.Add(maxId, new KeyValuePair <string, string>(stageName, ""));
                                commonIdManager.nameMap.Add(stageName, maxId);
                                typeof(YotogiStage).GetField("commonIdManager", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, commonIdManager);
                            }

                            //CsvParser is a pain, and the YotogiStage.Data constructor is a pain, so reuse yotogi_stage_list
                            //It wont find the id so it will be ok
                            string    f_strFileName = "yotogi_stage_list.nei";
                            AFileBase afileBase     = GameUty.FileSystem.FileOpen(f_strFileName);
                            CsvParser csvParser     = new CsvParser();
                            csvParser.Open(afileBase);
                            stageData = new YotogiStage.Data(-1, csvParser);

                            //Set id, only field we really need right now
                            typeof(YotogiStage.Data).GetField("id", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, maxId);

                            //Cleanup
                            csvParser.Dispose();
                        }

                        //Get BG and Thumbnail from folders
                        string prefab_bg       = null;
                        string prefab_bg_night = null;

                        //Day
                        if (Directory.GetFiles(mainPath + "\\" + stageName + "\\[Day]").Where(f => f.EndsWith(".asset_bg")).ToList().Count != 0)
                        {
                            prefab_bg = Path.GetFileNameWithoutExtension(new FileInfo(Directory.GetFiles(mainPath + "\\" + stageName + "\\[Day]").Where(f => f.EndsWith(".asset_bg")).ToList()[0]).Name);
                        }
                        else if (Directory.GetFiles(mainPath + "\\" + stageName + "\\[Day]").Where(f => f.EndsWith(".room")).ToList().Count != 0)
                        {
                            prefab_bg = Path.GetFileNameWithoutExtension(new FileInfo(Directory.GetFiles(mainPath + "\\" + stageName + "\\[Day]").Where(f => f.EndsWith(".room")).ToList()[0]).Name);
                        }
                        else
                        {
                            UnityEngine.Debug.Log("No.asset_bg or .room [Day] file found for " + stageName);
                        }
                        //Night
                        if (Directory.GetFiles(mainPath + "\\" + stageName + "\\[Night]").Where(f => f.EndsWith(".asset_bg")).ToList().Count != 0)
                        {
                            prefab_bg_night = Path.GetFileNameWithoutExtension(new FileInfo(Directory.GetFiles(mainPath + "\\" + stageName + "\\[Night]").Where(f => f.EndsWith(".asset_bg")).ToList()[0]).Name);
                        }
                        else if (Directory.GetFiles(mainPath + "\\" + stageName + "\\[Night]").Where(f => f.EndsWith(".room")).ToList().Count != 0)
                        {
                            prefab_bg_night = Path.GetFileNameWithoutExtension(new FileInfo(Directory.GetFiles(mainPath + "\\" + stageName + "\\[Night]").Where(f => f.EndsWith(".room")).ToList()[0]).Name);
                        }
                        else
                        {
                            UnityEngine.Debug.Log("No.asset_bg or .room [Night] file found for " + stageName);
                        }

                        string thumbnail       = null;
                        string thumbnail_night = null;

                        //Day
                        if (Directory.GetFiles(mainPath + "\\" + stageName + "\\[Day]").Where(f => f.EndsWith(".tex")).ToList().Count != 0)
                        {
                            thumbnail = new FileInfo(Directory.GetFiles(mainPath + "\\" + stageName + "\\[Day]").Where(f => f.EndsWith(".tex")).ToList()[0]).Name;
                        }
                        else
                        {
                            UnityEngine.Debug.Log("No .tex [Day] thumbnail file found for " + stageName);
                        }
                        //Night
                        if (Directory.GetFiles(mainPath + "\\" + stageName + "\\[Night]").Where(f => f.EndsWith(".tex")).ToList().Count != 0)
                        {
                            thumbnail_night = new FileInfo(Directory.GetFiles(mainPath + "\\" + stageName + "\\[Night]").Where(f => f.EndsWith(".tex")).ToList()[0]).Name;
                        }
                        else
                        {
                            UnityEngine.Debug.Log("No .tex [Night] thumbnail file found for " + stageName);
                        }

                        if (prefab_bg == null || prefab_bg_night == null || thumbnail == null || thumbnail_night == null)
                        {
                            UnityEngine.Debug.Log("YotogiAnywhere failed to create Location found for " + stageName);
                            break;
                        }


                        //Create a settings json if it doesnt exist
                        if (!File.Exists(mainPath + "\\" + stageName + "/settings.json"))
                        {
                            YotogiStage_Data_Json newSetting = new YotogiStage_Data_Json();
                            File.WriteAllText(mainPath + "\\" + stageName + "/settings.json", Newtonsoft.Json.JsonConvert.SerializeObject(newSetting));
                        }

                        //Settings from Directory
                        typeof(YotogiStage.Data).GetField("uniqueName", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, stageName);
                        typeof(YotogiStage.Data).GetField("drawName", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, stageName);

                        typeof(YotogiStage.Data).GetField("prefabName", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, new string[] { prefab_bg, prefab_bg_night });
                        typeof(YotogiStage.Data).GetField("thumbnailName", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, new string[] { thumbnail, thumbnail_night });

                        //Some Generic settings we do not worry about
                        typeof(YotogiStage.Data).GetField("sortId", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, stageData.id);

                        typeof(YotogiStage.Data).GetField("drawClubGrade", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, 1);
                        typeof(YotogiStage.Data).GetField("requestClubGrade", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, 1);

                        typeof(YotogiStage.Data).GetField("requestFacilityIds", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, new int[] { });

                        //Settings file
                        YotogiStage_Data_Json settings = Newtonsoft.Json.JsonConvert.DeserializeObject <YotogiStage_Data_Json>(File.ReadAllText(mainPath + "\\" + stageName + "/settings.json"));
                        typeof(YotogiStage.Data).GetField("bgmFileName", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, settings.bgm);
                        typeof(YotogiStage.Data).GetField("stageSelectCameraData", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, new YotogiStage.Data.Camera(new UnityEngine.Vector3(settings.camera_pos_x, settings.camera_pos_y, settings.camera_pos_z),
                                                                                                                                                                                new UnityEngine.Vector2(settings.camera_rot_x, settings.camera_rot_y),
                                                                                                                                                                                settings.camera_radius));
                        typeof(YotogiStage.Data).GetField("skillSelectcharacterData", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, new YotogiStage.Data.Character(new UnityEngine.Vector3(settings.kasuko_x, settings.kasuko_y, settings.kasuko_z),
                                                                                                                                                                                      new UnityEngine.Vector3(settings.kasuko_rot_x, settings.kasuko_rot_y, settings.kasuko_rot_z),
                                                                                                                                                                                      new UnityEngine.Vector2(settings.skill_x, settings.skill_y)));
                        typeof(YotogiStage.Data).GetField("skillSelectLightData", BindingFlags.Instance | BindingFlags.Public).SetValue(stageData, new YotogiStage.Data.Light(new UnityEngine.Vector3(settings.light_x, settings.light_y, settings.light_z), settings.light_intensity));

                        //Update the entry
                        basicsData[stageData.id] = stageData;
                    }
                    else
                    {
                        UnityEngine.Debug.Log("YotogiAnywhere: YotogiStage_CreateData Missing: " + mainPath + "\\" + stageName + "\\[Night]");
                    }
                }
                else
                {
                    UnityEngine.Debug.Log("YotogiAnywhere: YotogiStage_CreateData Missing: " + mainPath + "\\" + stageName + "\\[Day]");
                }
            }

            //Update entire dictionary as precaution
            typeof(YotogiStage).GetField("basicDatas", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, basicsData);
        }