Exemplo n.º 1
0
        public static void compile_acmd(string mlist, string output)
        {
            ACMDFile game       = new ACMDFile(),
                     effect     = new ACMDFile(),
                     sound      = new ACMDFile(),
                     expression = new ACMDFile();


            Directory.CreateDirectory(output);
            Console.WriteLine($">\tCompiling ACMD.. -> \"{output}\"");

            List <uint> hashes = new List <uint>();

            foreach (var line in File.ReadAllLines(mlist))
            {
                if (line.StartsWith("0x"))
                {
                    hashes.Add(Convert.ToUInt32(line.Substring(2), 16));
                }
                else
                {
                    hashes.Add(Crc32.Compute(line.ToLower()));
                }
            }

            foreach (var path in Directory.EnumerateFiles(Path.Combine(Path.GetDirectoryName(mlist), "animcmd"), "*", SearchOption.AllDirectories))
            {
                var defs = ACMDCompiler.CompileFile(path);
                foreach (var move in defs)
                {
#if DEBUG
                    Console.WriteLine($">\tCompiling {move.AnimName}..");
#endif

                    if (move["Main"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Main"].Cast <ICommand>().ToList();
                        game.Scripts.Add(move.CRC, script);
                    }
                    if (move["Sound"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Sound"].Cast <ICommand>().ToList();
                        sound.Scripts.Add(move.CRC, script);
                    }
                    if (move["Effect"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Effect"].Cast <ICommand>().ToList();
                        effect.Scripts.Add(move.CRC, script);
                    }
                    if (move["Expression"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Expression"].Cast <ICommand>().ToList();
                        expression.Scripts.Add(move.CRC, script);
                    }
                }
            }
            var table = new MTable(hashes, Endian);
            table.Export(Path.Combine(output, "motion.mtable"));
            game.Export(Path.Combine(output, "game.bin"), Endian);
            sound.Export(Path.Combine(output, "sound.bin"), Endian);
            effect.Export(Path.Combine(output, "effect.bin"), Endian);
            expression.Export(Path.Combine(output, "expression.bin"), Endian);
            Console.WriteLine(">\tFinished");
        }