Update wire protocol to version 5, introducing pupil slots and item counts in map snapshots. Enhance UI components to display pupil slots and item counts in game screens and map editors. Revise localization strings for improved user guidance. Update tests to validate new functionalities and ensure robustness in handling room and item data.
This commit is contained in:
@@ -94,7 +94,7 @@ internal sealed record CatalogResponse(
|
||||
Placeable(catalog.Buildings.Values, catalog, locale),
|
||||
Placeable(catalog.Floors.Values, catalog, locale),
|
||||
PlaceableRooms(catalog, locale),
|
||||
Placeable(catalog.Things.Values, catalog, locale),
|
||||
PlaceableThings(catalog, locale),
|
||||
map);
|
||||
|
||||
private static IReadOnlyList<DefInfoResponse> Placeable<T>(IEnumerable<T> defs, DefCatalog catalog, string locale)
|
||||
@@ -105,6 +105,13 @@ internal sealed record CatalogResponse(
|
||||
.Select(def => new DefInfoResponse(def.DefName, catalog.Label(locale, def)))
|
||||
.ToArray();
|
||||
|
||||
private static IReadOnlyList<DefInfoResponse> PlaceableThings(DefCatalog catalog, string locale) =>
|
||||
catalog.Things.Values
|
||||
.Where(def => !def.Abstract)
|
||||
.OrderBy(def => def.DefName, StringComparer.Ordinal)
|
||||
.Select(def => new DefInfoResponse(def.DefName, catalog.Label(locale, def), def.PupilSlots))
|
||||
.ToArray();
|
||||
|
||||
private static IReadOnlyList<RoomInfoResponse> PlaceableRooms(DefCatalog catalog, string locale) =>
|
||||
catalog.Rooms.Values
|
||||
.Where(def => !def.Abstract)
|
||||
@@ -112,12 +119,12 @@ internal sealed record CatalogResponse(
|
||||
.Select(def => new RoomInfoResponse(
|
||||
def.DefName,
|
||||
catalog.Label(locale, def),
|
||||
def.Slots.Select(slot => new RoomSlotInfo(slot.Key, slot.Thing)).ToArray(),
|
||||
def.Slots.Select(slot => new RoomSlotInfo(slot.Key, slot.Thing, slot.Count)).ToArray(),
|
||||
def.Positions.ToArray()))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
internal sealed record DefInfoResponse(string DefName, string Label);
|
||||
internal sealed record DefInfoResponse(string DefName, string Label, int PupilSlots = 0);
|
||||
|
||||
internal sealed record RoomInfoResponse(
|
||||
string DefName,
|
||||
@@ -125,4 +132,4 @@ internal sealed record RoomInfoResponse(
|
||||
IReadOnlyList<RoomSlotInfo> Slots,
|
||||
IReadOnlyList<string> Positions);
|
||||
|
||||
internal sealed record RoomSlotInfo(string Key, string Thing);
|
||||
internal sealed record RoomSlotInfo(string Key, string Thing, int Count);
|
||||
|
||||
@@ -449,12 +449,19 @@ internal sealed class SchoolWorker
|
||||
for (var i = 0; i < view.Count; i++)
|
||||
{
|
||||
var node = view[i];
|
||||
var items = new MapSnapshotItem[node.Items.Count];
|
||||
for (var item = 0; item < node.Items.Count; item++)
|
||||
{
|
||||
items[item] = new MapSnapshotItem(node.Items[item].Name, (byte)node.Items[item].Count);
|
||||
}
|
||||
|
||||
nodes[i] = new MapSnapshotNode(
|
||||
(byte)node.Kind,
|
||||
node.Id,
|
||||
node.ParentId,
|
||||
node.Name,
|
||||
node.Items,
|
||||
(ushort)node.PupilSlots,
|
||||
items,
|
||||
node.Positions);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"slots": [
|
||||
{ "key": "board", "thing": "Blackboard" },
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk", "count": 16 },
|
||||
],
|
||||
"positions": ["Teacher"],
|
||||
@@ -22,6 +23,7 @@
|
||||
"defName": "ComputerLab",
|
||||
"slots": [
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "computers", "thing": "Computer", "count": 12 },
|
||||
],
|
||||
"positions": ["Teacher"],
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[
|
||||
{ "defName": "Blackboard" },
|
||||
{ "defName": "StudentDesk", "parent": "Desk", "actions": ["Sit"] },
|
||||
{ "defName": "StudentDesk", "parent": "Desk", "actions": ["Sit"], "pupilSlots": 1 },
|
||||
{ "defName": "Bookshelf" },
|
||||
{ "defName": "DiningTable" },
|
||||
{ "defName": "Bench", "actions": ["Sit"] },
|
||||
{ "defName": "Computer" },
|
||||
{ "defName": "Computer", "pupilSlots": 1 },
|
||||
{ "defName": "MedicalCouch" },
|
||||
{ "defName": "Locker" },
|
||||
]
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"slots": [
|
||||
{ "key": "directorChair", "thing": "DirectorsChair" },
|
||||
{ "key": "desk", "thing": "Desk" },
|
||||
{ "key": "guestChair", "thing": "Chair" },
|
||||
{ "key": "guestChair", "thing": "Chair", "count": 2 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -43,7 +43,7 @@
|
||||
"floor": "floor-1",
|
||||
"slots": [
|
||||
{ "key": "table", "thing": "DiningTable" },
|
||||
{ "key": "chairs", "thing": "Chair" },
|
||||
{ "key": "chairs", "thing": "Chair", "count": 6 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -55,7 +55,8 @@
|
||||
"slots": [
|
||||
{ "key": "board", "thing": "Blackboard" },
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk", "count": 16 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -67,7 +68,8 @@
|
||||
"slots": [
|
||||
{ "key": "board", "thing": "Blackboard" },
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk", "count": 16 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -77,7 +79,7 @@
|
||||
"floor": "floor-1",
|
||||
"slots": [
|
||||
{ "key": "counter", "thing": "DiningTable" },
|
||||
{ "key": "seats", "thing": "Chair" },
|
||||
{ "key": "seats", "thing": "Chair", "count": 8 },
|
||||
],
|
||||
},
|
||||
{ "id": "restroom-1", "def": "Restroom", "building": "main", "floor": "floor-1", "label": "1" },
|
||||
@@ -102,7 +104,8 @@
|
||||
"slots": [
|
||||
{ "key": "board", "thing": "Blackboard" },
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk", "count": 16 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -114,7 +117,8 @@
|
||||
"slots": [
|
||||
{ "key": "board", "thing": "Blackboard" },
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "studentDesks", "thing": "StudentDesk", "count": 16 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -124,7 +128,7 @@
|
||||
"floor": "floor-2",
|
||||
"slots": [
|
||||
{ "key": "desk", "thing": "Desk" },
|
||||
{ "key": "shelves", "thing": "Bookshelf" },
|
||||
{ "key": "shelves", "thing": "Bookshelf", "count": 4 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -134,7 +138,8 @@
|
||||
"floor": "floor-2",
|
||||
"slots": [
|
||||
{ "key": "teacherDesk", "thing": "Desk" },
|
||||
{ "key": "computers", "thing": "Computer" },
|
||||
{ "key": "teacherChair", "thing": "Chair" },
|
||||
{ "key": "computers", "thing": "Computer", "count": 12 },
|
||||
],
|
||||
},
|
||||
{ "id": "restroom-2", "def": "Restroom", "building": "main", "floor": "floor-2", "label": "2" },
|
||||
@@ -144,7 +149,7 @@
|
||||
"building": "gym",
|
||||
"floor": "gym-floor",
|
||||
"slots": [
|
||||
{ "key": "benches", "thing": "Bench" },
|
||||
{ "key": "benches", "thing": "Bench", "count": 4 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -153,7 +158,7 @@
|
||||
"building": "gym",
|
||||
"floor": "gym-floor",
|
||||
"slots": [
|
||||
{ "key": "lockers", "thing": "Locker" },
|
||||
{ "key": "lockers", "thing": "Locker", "count": 12 },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user