80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
namespace HSchool.Content;
|
|
|
|
/// <summary>One school's map instance: tree grouping plus a walkable graph of territory and rooms.</summary>
|
|
public sealed class MapLayout
|
|
{
|
|
public TerritoryNode? Territory { get; init; }
|
|
|
|
public IReadOnlyList<BuildingNode> Buildings { get; init; } = [];
|
|
|
|
public IReadOnlyList<FloorNode> Floors { get; init; } = [];
|
|
|
|
public IReadOnlyList<RoomNode> Rooms { get; init; } = [];
|
|
|
|
public IReadOnlyList<MapLink> Links { get; init; } = [];
|
|
|
|
public static MapLayout Parse(string jsonc, string? source = null) =>
|
|
Jsonc.Deserialize<MapLayout>(Jsonc.Parse(jsonc, source));
|
|
}
|
|
|
|
public sealed class TerritoryNode
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public required string Def { get; init; }
|
|
}
|
|
|
|
public sealed class BuildingNode
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public required string Def { get; init; }
|
|
}
|
|
|
|
public sealed class FloorNode
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public required string Def { get; init; }
|
|
|
|
public required string Building { get; init; }
|
|
|
|
public string? Label { get; init; }
|
|
}
|
|
|
|
public sealed class RoomNode
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public required string Def { get; init; }
|
|
|
|
public required string Building { get; init; }
|
|
|
|
public required string Floor { get; init; }
|
|
|
|
/// <summary>Optional designation such as a classroom number. The def label still supplies the noun.</summary>
|
|
public string? Label { get; init; }
|
|
|
|
public IReadOnlyList<SlotFill> Slots { get; init; } = [];
|
|
}
|
|
|
|
public sealed class SlotFill
|
|
{
|
|
public required string Key { get; init; }
|
|
|
|
public required string Thing { get; init; }
|
|
|
|
/// <summary>
|
|
/// How many of <see cref="Thing"/> occupy this slot. Missing or non-positive JSON is 1, so
|
|
/// older maps without a count still round-trip.
|
|
/// </summary>
|
|
public int Count { get; init; } = 1;
|
|
}
|
|
|
|
public sealed class MapLink
|
|
{
|
|
public required string A { get; init; }
|
|
|
|
public required string B { get; init; }
|
|
}
|