Implement yearly intake functionality in school simulation, allowing for the graduation of students and the addition of new first-year pupils. Update the roster management to reflect these changes, ensuring proper entity handling in the simulation. Enhance the API to support name sets during roster installation and revise related tests to validate the new intake process and roster updates.
ci / server (push) Failing after 3m40s
ci / client (push) Failing after 20s

This commit is contained in:
Leonid Pershin
2026-08-18 19:57:59 +03:00
parent 533bd80f5e
commit 7f6852548d
12 changed files with 600 additions and 17 deletions
+21
View File
@@ -6,6 +6,9 @@ namespace HSchool.Simulation;
/// <summary>Turns roster records into Arch entities. Parents have no map location — by design.</summary>
public static class RosterSpawner
{
private static readonly QueryDescription People = new QueryDescription().WithAll<PersonIdentity>();
private static readonly QueryDescription Classes = new QueryDescription().WithAll<ClassIdentity>();
public static void Spawn(World world, Roster roster)
{
foreach (var schoolClass in roster.Classes)
@@ -36,4 +39,22 @@ public static class RosterSpawner
person.WorkplaceRoomId));
}
}
/// <summary>Drops the previous composition and spawns <paramref name="roster"/>. Called on yearly intake.</summary>
public static void Replace(World world, Roster roster)
{
DestroyAll(world, People);
DestroyAll(world, Classes);
Spawn(world, roster);
}
private static void DestroyAll(World world, QueryDescription query)
{
var entities = new List<Entity>();
world.Query(in query, (Entity entity) => entities.Add(entity));
foreach (var entity in entities)
{
world.Destroy(entity);
}
}
}