Esempio n. 1
0
        public static void Decompile()
        {
            var fMaterials = new Win32BinaryFileReader(Path.Combine(Common.InputPath, "core_physics_materials.brf"));
            var fSource    = new Win32FileWriter(Path.Combine(Common.OutputPath, "resource_physics_materials.py"));

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.PhysicsMaterials);

            // 6 + 4 = 10 for "rfver "
            // 4 for 1 (__int32)
            // 16 + 4 = 20 for "physics_material"
            fMaterials.SkipBytes(34);
            var iMaterials = fMaterials.ReadInt32();

            for (int m = 0; m < iMaterials; m++)
            {
                var name       = fMaterials.ReadAsciiString();
                var intValue   = fMaterials.ReadInt32();
                var floatValue = fMaterials.ReadFloat();
                fSource.WriteLine("  (\"{0}\", {1}, {2}),", name, intValue,
                                  floatValue.ToString(CultureInfo.GetCultureInfo("en-US")));
            }

            fSource.Write("]");
            fSource.Close();
            fMaterials.Close();
        }
Esempio n. 2
0
        public static void Decompile()
        {
            var fShaders = new Win32BinaryFileReader(Path.Combine(Common.InputPath, "core_shaders.brf"));
            var fSource  = new Win32FileWriter(Path.Combine(Common.OutputPath, "resource_shaders.py"));

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.ImprovedShaders);

            // 6 + 4 = 10 for "rfver "
            // 4 for 1 (__int32)
            // 6 + 4 = 10 for "shader"
            fShaders.SkipBytes(24);
            var iShaders = fShaders.ReadInt32();

            for (int s = 0; s < iShaders; s++)
            {
                var name       = fShaders.ReadAsciiString();
                var flags      = fShaders.ReadUInt32();
                var quality    = fShaders.ReadUInt32();
                var technique  = fShaders.ReadAsciiString();
                var technique2 = fShaders.ReadAsciiString();

                var iAlternatives = fShaders.ReadInt32();
                var alternatives  = new string[iAlternatives];
                for (int i = 0; i < iAlternatives; i++)
                {
                    alternatives[i] = fShaders.ReadAsciiString();
                }

                fShaders.ReadInt32(); //F*****G MAGIC!

                fSource.WriteLine("  (\"{0}\", \"{1}\", \"{2}\", {3}, {4}, [{5}]),", name, technique, technique2,
                                  DecompileFlags(flags), DecompileQuality(quality), String.Join(",", alternatives.Select(j => '"' + j + '"')));
            }


            fSource.Write("]");
            fSource.Close();
            fShaders.Close();
        }