using System.Text; using System.Text.RegularExpressions; using EvilEngine.Mounts; namespace EvilEngine.Adapters.Satisfactory; public static partial class Catalogue { public static readonly VirtualPath Resources = "CommunityResources"; public static readonly VirtualPath Docs = "CommunityResources/Docs"; public static readonly VirtualPath English = "CommunityResources/Docs/en-US.json"; public static readonly VirtualPath Mappings = "CommunityResources/FactoryGame.usmap"; public static readonly VirtualPath CustomVersions = "CommunityResources/CustomVersions.json"; public static IReadOnlyList Packages(IFileSource tree, List notes) { if (!tree.Exists(English)) { notes.Add($"{English} isn't there, so catalogue names no packages."); return []; } string text; using (var reader = new StreamReader(tree.Open(English), Encoding.UTF8, true)) { text = reader.ReadToEnd(); } var packages = new SortedSet(StringComparer.OrdinalIgnoreCase); foreach (Match match in GamePath().Matches(text)) { var package = match.Value.Split('.')[0]; if (VirtualPath.TryParse($"FactoryGame/Content/{package["/Game/".Length..]}", out var path) && !path.IsRoot) packages.Add(path.Value); } return [.. packages.Select(VirtualPath.Parse)]; } public static IEnumerable Files(IFileSource tree) { if (tree.DirectoryExists(Docs)) foreach (var entry in tree.Enumerate(Docs, true)) yield return entry.Path; foreach (var path in new[] { Mappings, CustomVersions }) if (tree.Exists(path)) yield return path; } [GeneratedRegex(@"/Game/[^'""\s,()\\]+")] private static partial Regex GamePath(); }