Ejemplo n.º 1
0
        public static void CompileScript(this Map map)
        {
            if (map is null)
            {
                throw new ArgumentNullException(nameof(map));
            }

            if (map.Info.ScriptLanguage != ScriptLanguage.Jass)
            {
                throw new InvalidOperationException($"The map's script language must be set to jass in order to use the jass compiler.");
            }

            using var stream = new MemoryStream();

            var mapScriptBuilder = new MapScriptBuilder();

            mapScriptBuilder.SetDefaultOptionsForMap(map);

            var compilationUnit = mapScriptBuilder.Build(map);

            using (var writer = new StreamWriter(stream, _defaultEncoding, leaveOpen: true))
            {
                var renderer = new JassRenderer(writer);
                renderer.Render(compilationUnit);
            }

            stream.Position = 0;
            map.SetScriptFile(stream);
        }
Ejemplo n.º 2
0
        public static void CompileScript(this Map map)
        {
            var mapScriptBuilder = new MapScriptBuilder();

            mapScriptBuilder.SetDefaultOptionsForMap(map);

            map.CompileScript(mapScriptBuilder);
        }