KCP gameserver with packet dispatch, scene streaming, combat, gacha and the shop, plus a small HTTP server for the login flow and the wish history page. Game data under assets is pulled out of the client instead of being typed by hand. The excel tables come from the packed bin container and the spawn points from the compiled scene scripts.
33 lines
958 B
C#
33 lines
958 B
C#
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<uint> Ids { get; }
|
|
|
|
public OpenStateTable()
|
|
{
|
|
List<uint> ids = Load("OpenStateConfigData.json");
|
|
Ids = ids.Count != 0 ? ids : Fallback;
|
|
}
|
|
|
|
private static List<uint> Load(string fileName)
|
|
{
|
|
List<uint> 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;
|
|
}
|
|
}
|