This commit is contained in:
Leonid Pershin
2026-08-18 23:51:10 +03:00
parent d8f8db6a48
commit 65feda3756
50 changed files with 1485 additions and 224 deletions
+1 -16
View File
@@ -33,7 +33,7 @@ public sealed class SchoolDemand
foreach (var room in map.Rooms)
{
var slots = PupilSlotsOf(catalog, room);
var slots = RoomOccupancy.PupilSlots(catalog, room);
if (catalog.Rooms.TryGetValue(room.Def, out var def))
{
foreach (var position in def.Positions)
@@ -67,19 +67,4 @@ public sealed class SchoolDemand
return new SchoolDemand(classes, seats, staff);
}
private static int PupilSlotsOf(DefCatalog catalog, RoomNode room)
{
var pupilSlots = 0L;
foreach (var fill in room.Slots)
{
var count = fill.Count < 1 ? 1 : Math.Min(fill.Count, byte.MaxValue);
if (catalog.Things.TryGetValue(fill.Thing, out var thing) && thing.PupilSlots > 0)
{
pupilSlots += (long)thing.PupilSlots * count;
}
}
return (int)Math.Clamp(pupilSlots, 0, ushort.MaxValue);
}
}