Пример #1
0
        public void DumpScriptsTo(string path, string destination)
        {
            var loader = new ScriptLoader(destination);

            var factory = new MapFactory(Path.GetDirectoryName(path));
            var h2map   = factory.Load(Path.GetFileName(path));

            if (h2map is not H2mccMap mccMap)
            {
                throw new NotSupportedException("Only MCC maps are supported in this tool");
            }

            var scnr = mccMap.Scenario;

            loader.Load(scnr);

            var scenarioParts = scnr.Name.Split('\\', StringSplitOptions.RemoveEmptyEntries)
                                .Select(p => p.Trim())
                                .ToArray();

            var debugRoot = $@"{destination}\{scenarioParts.Last()}";

            Directory.CreateDirectory(debugRoot);

            for (int i = 0; i < scnr.ScriptMethods.Length; i++)
            {
                var script = scnr.ScriptMethods[i];
                var text   = ScriptProcessor.GetScriptTree(scnr, script, i);
                CollectBuiltins(text);
                var debugTree = text.ToString(Args.CreateVerboseTrees);
                File.WriteAllText(Path.Combine(debugRoot, script.Description + ".tree"), debugTree);
            }
        }