Ejemplo n.º 1
0
        public static Func <string, string> GetIncludesFunc(string filepath)
        {
            Func <string, string> includesFunc = x => null;

            if (File.Exists(filepath))
            {
                var path    = Path.GetDirectoryName(filepath) ?? "";
                var pattern = "*.gsheader";

                var includes = Directory.EnumerateFiles(path, pattern).ToDictionary(p => Path.GetFileName(p) ?? p, p => File.ReadAllText(p, Encoding.UTF8));

                includesFunc = x => includes.FirstOrDefault(p => LevelBlueprint.IsIncludeMatch(p.Key, x)).Value;
            }
            return(includesFunc);
        }
Ejemplo n.º 2
0
        public static LevelBlueprint ParseLevelFromFile(string path, bool sim)
        {
            var folder = Path.GetDirectoryName(path) ?? "";

            var includes = Directory.EnumerateFiles(folder, "*.gsheader").ToDictionary(p => Path.GetFileName(p) ?? p, p => File.ReadAllText(p, Encoding.UTF8));
            Func <string, string> includesFunc = x => includes.FirstOrDefault(p => LevelBlueprint.IsIncludeMatch(p.Key, x)).Value;

            var fp = new LevelParser(File.ReadAllText(path), includesFunc);
            var lf = fp.Parse(Path.GetFileName(path));

            LastParsedIncludedSources = fp.IncludedSources;

            if (sim)
            {
                BlueprintPreprocessor.ProcessLevel(lf);
            }

            return(lf);
        }