qstbak/Questionable/Questionable.LgbWorker/LgbWorkerManifest.cs
2026-08-17 20:29:32 +10:00

42 lines
1.3 KiB
C#

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<TerritoryEntry> Territories { get; set; } = new List<TerritoryEntry>();
[JsonPropertyName("levelEntries")]
public List<LevelEntry> LevelEntries { get; set; } = new List<LevelEntry>();
public static LgbWorkerManifest Load(string path)
{
using FileStream utf8Json = File.OpenRead(path);
LgbWorkerManifest? obj = JsonSerializer.Deserialize<LgbWorkerManifest>(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;
}
}