public string Decompile(MSCScript script) { var analyzer = new MSCAnalyzer(script); analyzer.Analyze_1(); Target = script; Manager = new MSCCommandManager(Target); StringBuilder sb = new StringBuilder(); while (!Manager.End) { MSCCommand cmd = Manager.Next(); // Do ending brackets while (INDENT_STACK.Contains(cmd.FileOffset - 0x30)) { INDENT_STACK.Remove(cmd.FileOffset - 0x30); foreach (int off in INDENT_STACK) { sb.Append(" "); } sb.Append("}\n"); } // If the command is passed to the next add it to the assignment stack if (Manager.Position != script.Count && cmd.Ident == 0x0A && Manager.PeekNext().Ident == 0x36) { sb.Append(DoIndent(cmd.ToString()) + "\n"); continue; } else if (cmd.Returns) { COMMANDS.Push(cmd); continue; } sb.Append(DecompileCMD(cmd) /*.TrimEnd() + $" \t// 0x{cmd.FileOffset - 0x30:X}*/ + "\n"); } return(sb.ToString()); }
public MSCAnalyzer(MSCScript script) { Target = script; _commands = new List <Tuple <int, MSCCommand> >(); Manager = new MSCCommandManager(Target); }