using HSchool.Content; using HSchool.Simulation; namespace HSchool.Server.Game; /// /// Work item handed from a request or connection thread to the supervisor. Create, delete and /// name suggestions stay here; open/close/running/speed are forwarded to the school's worker. /// internal abstract record GameCommand { internal sealed record CreateSchool( string Name, DateTime StartDate, IReadOnlyList? ExtraModIds, MapLayout? Map, TaskCompletionSource Result) : GameCommand; internal sealed record DeleteSchool(int SchoolId, TaskCompletionSource Result) : GameCommand; internal sealed record SuggestName(SchoolNameLanguage Language, TaskCompletionSource Result) : GameCommand; /// A connection starts watching a school; clock frames follow from that worker. internal sealed record OpenSchool(uint PlayerId, int SchoolId) : GameCommand; /// /// Stops watching. The school id travels with the command because the connection may already /// be gone from the registry by the time the supervisor gets here. /// internal sealed record CloseSchool(uint PlayerId, int SchoolId) : GameCommand; internal sealed record SetRunning(uint PlayerId, bool Running) : GameCommand; internal sealed record SetSpeed(uint PlayerId, byte SpeedIndex) : GameCommand; /// Stops every worker, re-reads the save directory, starts workers from those files. internal sealed record ReloadSaves(TaskCompletionSource Result) : GameCommand; }