54 lines
2.2 KiB
C#
54 lines
2.2 KiB
C#
using HSchool.Content;
|
|
using HSchool.Server.Api;
|
|
using HSchool.Simulation;
|
|
|
|
namespace HSchool.Server.Game;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
internal abstract record GameCommand
|
|
{
|
|
internal sealed record CreateSchool(
|
|
string Name,
|
|
DateTime StartDate,
|
|
IReadOnlyList<string>? ExtraModIds,
|
|
MapLayout? Map,
|
|
string? NameSetId,
|
|
TaskCompletionSource<SchoolCreationOutcome> Result) : GameCommand;
|
|
|
|
internal sealed record DeleteSchool(int SchoolId, TaskCompletionSource<bool> Result) : GameCommand;
|
|
|
|
internal sealed record SuggestName(SchoolNameLanguage Language, TaskCompletionSource<string> Result) : GameCommand;
|
|
|
|
/// <summary>A connection starts watching a school; clock frames follow from that worker.</summary>
|
|
internal sealed record OpenSchool(uint PlayerId, int SchoolId) : GameCommand;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
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;
|
|
|
|
/// <summary>Stops every worker, re-reads the save directory, starts workers from those files.</summary>
|
|
internal sealed record ReloadSaves(TaskCompletionSource Result) : GameCommand;
|
|
|
|
/// <summary>
|
|
/// A worker thread ended on an exception. The supervisor owns the table, so the worker asks
|
|
/// it to drop the school instead of removing itself.
|
|
/// </summary>
|
|
internal sealed record WorkerFailed(int SchoolId) : GameCommand;
|
|
|
|
/// <summary>One person's card, including live needs. Completes on that school's worker thread.</summary>
|
|
internal sealed record GetPerson(
|
|
int SchoolId,
|
|
string PersonId,
|
|
string Locale,
|
|
TaskCompletionSource<PersonCardResult> Result) : GameCommand;
|
|
}
|