Pause the school on warning notices until the owner dismisses them.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 22:33:38 +03:00
co-authored by Cursor
parent e22d9bae33
commit f36af269bb
27 changed files with 993 additions and 51 deletions
+32 -14
View File
@@ -226,7 +226,15 @@ internal sealed class GameLoopService(
break;
case GameCommand.DismissNotice dismiss:
RouteOpenSchool(dismiss.PlayerId, new WorkerCommand.DismissNotice(dismiss.NoticeId));
HandleClockCommand(dismiss.PlayerId, dismiss.NormalizedUserName, new WorkerCommand.DismissNotice(dismiss.NoticeId));
break;
case GameCommand.DismissSchoolNotice dismissHttp:
HandleDismissHttp(dismissHttp);
break;
case GameCommand.PostSchoolNotice postNotice:
HandlePostNotice(postNotice);
break;
case GameCommand.ReloadSaves reload:
@@ -639,17 +647,6 @@ internal sealed class GameLoopService(
}
}
private void RouteOpenSchool(uint playerId, WorkerCommand command)
{
var client = clients.Find(playerId);
if (client?.OpenSchoolId is not { } schoolId)
{
return;
}
Route(schoolId, command);
}
private void HandleClockCommand(uint playerId, string normalizedUserName, WorkerCommand command)
{
var client = clients.Find(playerId);
@@ -667,6 +664,24 @@ internal sealed class GameLoopService(
Route(schoolId, command);
}
private void HandleDismissHttp(GameCommand.DismissSchoolNotice command)
{
if (!_workers.TryGetValue(command.SchoolId, out var worker)
|| !worker.Post(new WorkerCommand.DismissNoticeHttp(command.NoticeId, command.Result)))
{
command.Result.TrySetResult();
}
}
private void HandlePostNotice(GameCommand.PostSchoolNotice command)
{
if (!_workers.TryGetValue(command.SchoolId, out var worker)
|| !worker.Post(new WorkerCommand.PostNotice(command.DefName, command.PersonId, command.Result)))
{
command.Result.TrySetResult(null);
}
}
private async Task StartWorkersFromDiskAsync()
{
var saves = store.LoadAll();
@@ -725,7 +740,8 @@ internal sealed class GameLoopService(
save.DressRules,
save.SpeechRules,
save.Owner,
save.PortraitSettings is null ? null : SwarmUiConfigFile.Clone(save.PortraitSettings));
save.PortraitSettings is null ? null : SwarmUiConfigFile.Clone(save.PortraitSettings),
save.Notices);
worker.Start();
try
@@ -784,7 +800,8 @@ internal sealed class GameLoopService(
SchoolDressRules? dressRules = null,
SchoolSpeechRules? speechRules = null,
string? owner = null,
SwarmUiConfigFile? portraitSettings = null) =>
SwarmUiConfigFile? portraitSettings = null,
IReadOnlyList<StickyNoticeSave>? notices = null) =>
new(
id,
name,
@@ -803,6 +820,7 @@ internal sealed class GameLoopService(
speechRules,
owner,
portraitSettings,
notices,
_options,
clients,
metrics,