public IEnumerable <Map> EnumerateMapsWithoutCaching(MapClassification classification = MapClassification.System) { // Utility mod that does not support maps if (!modData.Manifest.Contains <MapGrid>()) { yield break; } // Enumerate map directories foreach (var kv in modData.Manifest.MapFolders) { MapClassification packageClassification; if (!Enum.TryParse(kv.Value, out packageClassification)) { continue; } if (!classification.HasFlag(packageClassification)) { continue; } var name = kv.Key; var optional = name.StartsWith("~", StringComparison.Ordinal); if (optional) { name = name.Substring(1); } // Don't try to open the map directory in the support directory if it doesn't exist if (Platform.IsPathRelativeToSupportDirectory(name)) { var resolved = Platform.ResolvePath(name); if (!Directory.Exists(resolved) || !File.Exists(resolved)) { continue; } } using (var package = (IReadWritePackage)modData.ModFiles.OpenPackage(name)) { foreach (var map in package.Contents) { var mapPackage = package.OpenPackage(map, modData.ModFiles); if (mapPackage != null) { yield return(new Map(modData, mapPackage)); } } } } }
public IEnumerable <IReadWritePackage> EnumerateMapDirPackages(MapClassification classification = MapClassification.System) { // Utility mod that does not support maps if (!modData.Manifest.Contains <MapGrid>()) { yield break; } // Enumerate map directories foreach (var kv in modData.Manifest.MapFolders) { if (!Enum.TryParse(kv.Value, out MapClassification packageClassification)) { continue; } if (!classification.HasFlag(packageClassification)) { continue; } var name = kv.Key; var optional = name.StartsWith("~", StringComparison.Ordinal); if (optional) { name = name.Substring(1); } // Don't try to open the map directory in the support directory if it doesn't exist var resolved = Platform.ResolvePath(name); if (resolved.StartsWith(Platform.SupportDir) && (!Directory.Exists(resolved) || !File.Exists(resolved))) { continue; } using (var package = (IReadWritePackage)modData.ModFiles.OpenPackage(name)) yield return(package); } }