using System.Collections.Generic; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; namespace Questionable.LgbWorker; internal sealed class LgbWorkerManifest { [JsonPropertyName("sqpackPath")] public string SqpackPath { get; set; } = string.Empty; [JsonPropertyName("gameVersion")] public string GameVersion { get; set; } = string.Empty; [JsonPropertyName("npcCachePath")] public string NpcCachePath { get; set; } = string.Empty; [JsonPropertyName("boundaryCachePath")] public string BoundaryCachePath { get; set; } = string.Empty; [JsonPropertyName("territories")] public List Territories { get; set; } = new List(); [JsonPropertyName("levelEntries")] public List LevelEntries { get; set; } = new List(); public static LgbWorkerManifest Load(string path) { using FileStream utf8Json = File.OpenRead(path); LgbWorkerManifest? obj = JsonSerializer.Deserialize(utf8Json) ?? throw new InvalidDataException("Manifest deserialized to null"); if (string.IsNullOrWhiteSpace(obj.SqpackPath)) { throw new InvalidDataException("SqpackPath is missing"); } if (string.IsNullOrWhiteSpace(obj.GameVersion)) { throw new InvalidDataException("GameVersion is missing"); } return obj; } }