using System.Text.Json; namespace Yuanshen.Gameserver.Game; internal readonly record struct SpawnGroup(uint GroupId, float X, float Z, float Extent) { public bool IsCompact => Extent <= CompactExtent; private const float CompactExtent = 60f; } internal sealed class SpawnGroupTable { private readonly Dictionary _groups = new(); public SpawnGroupTable() { Load("scene3_groups.json"); } public bool TryGet(uint groupId, out SpawnGroup group) => _groups.TryGetValue(groupId, out group); private void Load(string fileName) { string path = Path.Combine(AppContext.BaseDirectory, "assets", "scene", fileName); if (!File.Exists(path)) return; using JsonDocument document = JsonDocument.Parse(File.ReadAllText(path)); foreach (JsonElement row in document.RootElement.EnumerateArray()) { uint groupId = row.GetProperty("g").GetUInt32(); _groups[groupId] = new SpawnGroup( groupId, (float)row.GetProperty("x").GetDouble(), (float)row.GetProperty("z").GetDouble(), (float)row.GetProperty("e").GetDouble()); } } }