示例#1
0
    public static void LoadAsset(string assetPath, string savePath)
    {
        using (BinaryReader reader = new BinaryReader(File.Open(assetPath, FileMode.Open)))
        {
            int          iVar1;
            LevelManager levelManager = GameObject.FindObjectOfType <LevelManager>();
            VigTerrain   terrain      = GameObject.FindObjectOfType <VigTerrain>();
            string       relativePath = savePath;

            if (savePath.StartsWith(Application.dataPath))
            {
                relativePath = "Assets" + savePath.Substring(Application.dataPath.Length);
            }

            iVar1 = reader.ReadInt32BE();
            reader.ReadInt32();
            string bmpApsolute = savePath + "/XBGM" + 0.ToString().PadLeft(2, '0') + ".bmp";
            string bmpRelative = relativePath + "/XBGM" + 0.ToString().PadLeft(2, '0') + ".bmp";
            string matPath     = relativePath + "/XBGM" + 0.ToString().PadLeft(2, '0') + ".mat";
            IMP_TIM.LoadTIM(reader, bmpApsolute);
            Material newMaterial = null;
#if UNITY_EDITOR
            AssetDatabase.Refresh();
            newMaterial             = new Material(AssetDatabase.LoadAssetAtPath(relativePath + "/default.mat", typeof(Material)) as Material);
            newMaterial.mainTexture = AssetDatabase.LoadAssetAtPath(bmpRelative, typeof(Texture2D)) as Texture2D;
            Utilities.SaveObjectToFile(newMaterial, matPath);
#endif
            levelManager.DAT_DD0   = newMaterial;
            levelManager.DAT_6398A = (short)(iVar1 << 4);
            levelManager.DAT_63972 = (short)((iVar1 - levelManager.DAT_DD0.mainTexture.height) * 16);
            levelManager.DAT_6397A = levelManager.DAT_63972;
            levelManager.DAT_63982 = levelManager.DAT_63972;
            levelManager.DAT_63992 = levelManager.DAT_6398A;
            levelManager.DAT_6399A = levelManager.DAT_6398A;

            if (levelManager.DAT_E48 == null)
            {
                levelManager.DAT_E48 = levelManager.DAT_DD0;
            }

#if UNITY_EDITOR
            levelManager.DAT_E58 = AssetDatabase.LoadAssetAtPath("Assets/SHELL/glow.mat", typeof(Material)) as Material;
            EditorUtility.SetDirty(levelManager.gameObject);
#endif
        }
    }
示例#2
0
    public static void LoadAsset(string assetPath, string savePath)
    {
        using (BinaryReader reader = new BinaryReader(File.Open(assetPath, FileMode.Open)))
        {
            int          iVar3;
            int          iVar4;
            int          local_210;
            MemoryStream auStack520;
            LevelManager levelManager = GameObject.FindObjectOfType <LevelManager>();
            string       relativePath = savePath;

            iVar4 = 0;
            iVar3 = 0;
            levelManager.DAT_DF8 = new Material[16];
            long begin = reader.BaseStream.Position;
            Utilities.SetFarColor(levelManager.DAT_DDC.r, levelManager.DAT_DDC.g, levelManager.DAT_DDC.b);

            if (savePath.StartsWith(Application.dataPath))
            {
                relativePath = "Assets" + savePath.Substring(Application.dataPath.Length);
            }

            do
            {
                reader.BaseStream.Seek(begin, SeekOrigin.Begin);
                auStack520 = new MemoryStream();

                using (BinaryWriter writer = new BinaryWriter(auStack520, Encoding.Default, true))
                {
                    writer.Write(reader.ReadBytes(16));
                    local_210 = reader.ReadInt16();
                    writer.Write((short)local_210);
                    writer.Write(reader.ReadInt16());
                    Utilities.FUN_18C54(reader, local_210, writer, iVar3);
                    writer.Write(reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position)));
                    writer.BaseStream.Seek(4, SeekOrigin.Begin);
                }

                using (BinaryReader reader2 = new BinaryReader(auStack520, Encoding.Default, true))
                {
                    string bmpApsolute = savePath + "/XBMP_FAR" + iVar4.ToString().PadLeft(2, '0') + ".bmp";
                    string bmpRelative = relativePath + "/XBMP_FAR" + iVar4.ToString().PadLeft(2, '0') + ".bmp";
                    string matPath     = relativePath + "/XBMP_FAR" + iVar4.ToString().PadLeft(2, '0') + ".mat";
                    IMP_TIM.LoadTIM(reader2, bmpApsolute);
                    Material newMaterial = null;
#if UNITY_EDITOR
                    AssetDatabase.Refresh();
                    newMaterial             = new Material(AssetDatabase.LoadAssetAtPath(relativePath + "/default.mat", typeof(Material)) as Material);
                    newMaterial.mainTexture = AssetDatabase.LoadAssetAtPath(bmpRelative, typeof(Texture2D)) as Texture2D;
                    Utilities.SaveObjectToFile(newMaterial, matPath);
#endif
                    levelManager.DAT_DF8[iVar4] = newMaterial;
                }

                iVar4++;
                iVar3 += 0x100;
            } while (iVar4 < 16);

#if UNITY_EDITOR
            EditorUtility.SetDirty(levelManager.gameObject);
#endif
        }
    }
示例#3
0
    //76B8 (LOAD.DLL)
    public void LoadDB(string assetPath)
    {
        ushort       uVar2;
        short        sVar3;
        int          iVar4;
        int          uVar5;
        int          iVar6;
        short        local_21c;
        MemoryStream auStack536;

        LevelManager levelManager = GameObject.FindObjectOfType <LevelManager>();
        string       relativePath = prefabPath;

        if (prefabPath.StartsWith(Application.dataPath))
        {
            relativePath = "Assets" + prefabPath.Substring(Application.dataPath.Length);
        }

        using (BinaryReader reader = new BinaryReader(File.Open(assetPath, FileMode.Open)))
        {
            levelManager.xrtpList.Add(this);
            uVar5     = reader.ReadInt32BE();
            DAT_24    = uVar5;
            uVar5     = reader.ReadInt32BE();
            DAT_28    = uVar5;
            uVar5     = reader.ReadUInt16BE();
            DAT_1C    = uVar5;
            uVar2     = reader.ReadUInt16BE();
            DAT_2C    = uVar2;
            DAT_14    = 0;
            V3_DAT_0C = null;
            V3_DAT_10 = null;

            if (DAT_1C < 16)
            {
                DAT_1C = 48;
            }

            iVar4  = DAT_28 >> 8;
            iVar6  = DAT_24 >> 8;
            sVar3  = (short)(int)Utilities.SquareRoot(iVar4 * iVar4 + iVar6 * iVar6);
            iVar4  = DAT_24;
            DAT_30 = (short)(sVar3 - 128);

            if (iVar4 < 0)
            {
                iVar4 += 255;
            }

            iVar6 = DAT_28;

            if (iVar6 < 0)
            {
                iVar6 += 255;
            }

            iVar4 = (iVar4 >> 8) * (iVar6 >> 8);

            if (iVar4 < 0)
            {
                iVar4 += 127;
            }

            DAT_2E = (short)(iVar4 >> 7);

            if (12 < reader.BaseStream.Length)
            {
                long begin = reader.BaseStream.Position;
                iVar6      = 0;
                timFarList = new List <Material>();
                Utilities.SetFarColor(levelManager.DAT_DDC.r, levelManager.DAT_DDC.g, levelManager.DAT_DDC.b);

                for (int i = 0; i < 16; i++)
                {
                    reader.BaseStream.Seek(begin, SeekOrigin.Begin);
                    auStack536 = new MemoryStream();

                    using (BinaryWriter writer = new BinaryWriter(auStack536, Encoding.Default, true))
                    {
                        writer.Write(reader.ReadBytes(16));
                        local_21c = reader.ReadInt16();
                        writer.Write(local_21c);
                        writer.Write(reader.ReadInt16());
                        Utilities.FUN_18C54(reader, local_21c, writer, iVar6);
                        writer.Write(reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position)));
                        writer.BaseStream.Seek(0, SeekOrigin.Begin);
                    }

                    using (BinaryReader reader2 = new BinaryReader(auStack536, Encoding.Default, true))
                    {
                        string bmpApsolute = prefabPath + "/" + prefabName + "_FAR" + i.ToString().PadLeft(2, '0') + ".bmp";
                        string bmpRelative = relativePath + "/" + prefabName + "_FAR" + i.ToString().PadLeft(2, '0') + ".bmp";
                        string matPath     = relativePath + "/" + prefabName + "_FAR" + i.ToString().PadLeft(2, '0') + ".mat";
                        reader2.ReadInt32();
                        IMP_TIM.LoadTIM(reader2, bmpApsolute);
#if UNITY_EDITOR
                        AssetDatabase.Refresh();
                        Material newMaterial = new Material(AssetDatabase.LoadAssetAtPath(relativePath + "/default.mat", typeof(Material)) as Material);
                        newMaterial.mainTexture = AssetDatabase.LoadAssetAtPath(bmpRelative, typeof(Texture2D)) as Texture2D;
                        Utilities.SaveObjectToFile(newMaterial, matPath);
                        timFarList.Add(newMaterial);
#endif
                    }

                    iVar6 += 0x100;
                }
            }

#if UNITY_EDITOR
            EditorUtility.SetDirty(gameObject);
            EditorUtility.SetDirty(levelManager.gameObject);
#endif
        }
    }