using System.Text.Json; namespace Yuanshen.Gameserver.Game; internal sealed class OpenStateTable { private static readonly uint[] Fallback = { 1, 2, 3, 4, 5, 31, 32 }; public IReadOnlyList Ids { get; } public OpenStateTable() { List ids = Load("OpenStateConfigData.json"); Ids = ids.Count != 0 ? ids : Fallback; } private static List Load(string fileName) { List ids = new(); string path = Path.Combine(AppContext.BaseDirectory, "assets", "excel", fileName); if (!File.Exists(path)) return ids; using JsonDocument document = JsonDocument.Parse(File.ReadAllText(path)); foreach (JsonElement entry in document.RootElement.EnumerateArray()) { if (entry.TryGetProperty("id", out JsonElement id) && id.TryGetUInt32(out uint value) && value != 0) ids.Add(value); } return ids; } }