コード例 #1
0
ファイル: UpdateUtils.cs プロジェクト: reaperrr/OpenRA
        /// <summary>
        /// Loads a YamlFileSet from a list of mod files.
        /// </summary>
        static YamlFileSet LoadModYaml(ModData modData, IEnumerable <string> files)
        {
            var yaml = new YamlFileSet();

            foreach (var filename in files)
            {
                string           name;
                IReadOnlyPackage package;
                if (!modData.ModFiles.TryGetPackageContaining(filename, out package, out name) || !(package is IReadWritePackage))
                {
                    Console.WriteLine("Failed to load file `{0}` for writing. It will not be updated.", filename);
                    continue;
                }

                yaml.Add(Tuple.Create((IReadWritePackage)package, name, MiniYaml.FromStream(package.GetStream(name), name, false)));
            }

            return(yaml);
        }
コード例 #2
0
ファイル: UpdateUtils.cs プロジェクト: reaperrr/OpenRA
        /// <summary>
        /// Loads a YamlFileSet containing any internal definitions yaml referenced by a map yaml block.
        /// External references or internal references to missing files are ignored.
        /// </summary>
        static YamlFileSet LoadInternalMapYaml(ModData modData, IReadWritePackage mapPackage, MiniYaml yaml, HashSet <string> externalFilenames)
        {
            var fileSet = new YamlFileSet()
            {
                Tuple.Create <IReadWritePackage, string, List <MiniYamlNode> >(null, "map.yaml", yaml.Nodes)
            };

            var files = FieldLoader.GetValue <string[]>("value", yaml.Value);

            foreach (var filename in files)
            {
                // Ignore any files that aren't in the map bundle
                if (!filename.Contains("|") && mapPackage.Contains(filename))
                {
                    fileSet.Add(Tuple.Create(mapPackage, filename, MiniYaml.FromStream(mapPackage.GetStream(filename), filename, false)));
                }
                else if (modData.ModFiles.Exists(filename))
                {
                    externalFilenames.Add(filename);
                }
            }

            return(fileSet);
        }