Add speech-topic policy from tomorrow and a morning family talk.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -113,4 +113,14 @@ internal abstract record GameCommand
|
||||
DressRulePair? PendingStudents,
|
||||
DressRulePair? PendingStaff,
|
||||
TaskCompletionSource<DressRulesOutcome> Result) : GameCommand;
|
||||
|
||||
internal sealed record GetSpeechRules(
|
||||
int SchoolId,
|
||||
TaskCompletionSource<SpeechRulesOutcome> Result) : GameCommand;
|
||||
|
||||
internal sealed record SetSpeechRules(
|
||||
int SchoolId,
|
||||
string? PendingStudents,
|
||||
string? PendingStaff,
|
||||
TaskCompletionSource<SpeechRulesOutcome> Result) : GameCommand;
|
||||
}
|
||||
|
||||
@@ -290,6 +290,17 @@ internal sealed class GameLoopService(
|
||||
new WorkerCommand.SetDressRules(setRules.PendingStudents, setRules.PendingStaff, setRules.Result),
|
||||
setRules.Result);
|
||||
break;
|
||||
|
||||
case GameCommand.GetSpeechRules getSpeech:
|
||||
HandleSpeechRules(getSpeech.SchoolId, new WorkerCommand.GetSpeechRules(getSpeech.Result), getSpeech.Result);
|
||||
break;
|
||||
|
||||
case GameCommand.SetSpeechRules setSpeech:
|
||||
HandleSpeechRules(
|
||||
setSpeech.SchoolId,
|
||||
new WorkerCommand.SetSpeechRules(setSpeech.PendingStudents, setSpeech.PendingStaff, setSpeech.Result),
|
||||
setSpeech.Result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,6 +339,14 @@ internal sealed class GameLoopService(
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSpeechRules(int schoolId, WorkerCommand command, TaskCompletionSource<SpeechRulesOutcome> result)
|
||||
{
|
||||
if (!_workers.TryGetValue(schoolId, out var worker) || !worker.Post(command))
|
||||
{
|
||||
result.TrySetResult(SpeechRulesOutcome.Fail(SpeechRulesError.UnknownSchool));
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleStaffing(int schoolId, WorkerCommand command, TaskCompletionSource<StaffingOutcome> result)
|
||||
{
|
||||
if (!_workers.TryGetValue(schoolId, out var worker) || !worker.Post(command))
|
||||
@@ -700,6 +719,7 @@ internal sealed class GameLoopService(
|
||||
createSeed: null,
|
||||
save.Presence,
|
||||
save.DressRules,
|
||||
save.SpeechRules,
|
||||
save.Owner,
|
||||
save.PortraitSettings);
|
||||
worker.Start();
|
||||
@@ -758,6 +778,7 @@ internal sealed class GameLoopService(
|
||||
int? createSeed = null,
|
||||
IReadOnlyList<PresenceSnapshot>? presence = null,
|
||||
SchoolDressRules? dressRules = null,
|
||||
SchoolSpeechRules? speechRules = null,
|
||||
string? owner = null,
|
||||
SwarmUiConfigFile? portraitSettings = null) =>
|
||||
new(
|
||||
@@ -775,6 +796,7 @@ internal sealed class GameLoopService(
|
||||
createSeed,
|
||||
presence,
|
||||
dressRules,
|
||||
speechRules,
|
||||
owner,
|
||||
portraitSettings,
|
||||
_options,
|
||||
|
||||
@@ -36,6 +36,8 @@ internal sealed class SchoolSave
|
||||
|
||||
public SchoolDressRules? DressRules { get; init; }
|
||||
|
||||
public SchoolSpeechRules? SpeechRules { get; init; }
|
||||
|
||||
/// <summary>Normalized player name. Missing or blank means ownerless.</summary>
|
||||
public string? Owner { get; init; }
|
||||
|
||||
@@ -179,6 +181,7 @@ internal sealed class SchoolStore
|
||||
NativeLanguage = save.NativeLanguage,
|
||||
Presence = save.Presence,
|
||||
DressRules = save.DressRules,
|
||||
SpeechRules = save.SpeechRules,
|
||||
Owner = save.Owner,
|
||||
PortraitSettings = save.PortraitSettings,
|
||||
});
|
||||
|
||||
@@ -38,6 +38,7 @@ internal sealed class SchoolWorker
|
||||
private readonly int? _createSeed;
|
||||
private readonly IReadOnlyList<PresenceSnapshot>? _savedPresence;
|
||||
private readonly SchoolDressRules? _savedDressRules;
|
||||
private readonly SchoolSpeechRules? _savedSpeechRules;
|
||||
private readonly string? _owner;
|
||||
private readonly SwarmUiConfigFile? _portraitSettings;
|
||||
private readonly Action<int> _onFailed;
|
||||
@@ -76,6 +77,7 @@ internal sealed class SchoolWorker
|
||||
int? createSeed,
|
||||
IReadOnlyList<PresenceSnapshot>? savedPresence,
|
||||
SchoolDressRules? savedDressRules,
|
||||
SchoolSpeechRules? savedSpeechRules,
|
||||
string? owner,
|
||||
SwarmUiConfigFile? portraitSettings,
|
||||
SimulationOptions options,
|
||||
@@ -100,6 +102,7 @@ internal sealed class SchoolWorker
|
||||
_createSeed = createSeed;
|
||||
_savedPresence = savedPresence;
|
||||
_savedDressRules = savedDressRules;
|
||||
_savedSpeechRules = savedSpeechRules;
|
||||
_owner = string.IsNullOrWhiteSpace(owner) ? null : owner;
|
||||
_portraitSettings = portraitSettings;
|
||||
_options = options;
|
||||
@@ -261,6 +264,7 @@ internal sealed class SchoolWorker
|
||||
|
||||
_school = school;
|
||||
school.DressRules = _savedDressRules ?? new SchoolDressRules();
|
||||
school.SpeechRules = _savedSpeechRules ?? new SchoolSpeechRules();
|
||||
PublishSnapshot();
|
||||
|
||||
if (_isNew)
|
||||
@@ -494,6 +498,29 @@ internal sealed class SchoolWorker
|
||||
dirty = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case WorkerCommand.GetSpeechRules getSpeech:
|
||||
getSpeech.Result.TrySetResult(SpeechRulesOutcome.Ok(school.SpeechRules));
|
||||
break;
|
||||
|
||||
case WorkerCommand.SetSpeechRules setSpeech:
|
||||
{
|
||||
var next = school.SpeechRules;
|
||||
if (setSpeech.PendingStudents is { } students)
|
||||
{
|
||||
next = next with { PendingStudents = students };
|
||||
}
|
||||
|
||||
if (setSpeech.PendingStaff is { } staff)
|
||||
{
|
||||
next = next with { PendingStaff = staff };
|
||||
}
|
||||
|
||||
school.SpeechRules = next;
|
||||
setSpeech.Result.TrySetResult(SpeechRulesOutcome.Ok(school.SpeechRules));
|
||||
dirty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -553,6 +580,12 @@ internal sealed class SchoolWorker
|
||||
case WorkerCommand.SetDressRules setRules:
|
||||
setRules.Result.TrySetResult(DressRulesOutcome.Fail(DressRulesError.UnknownSchool));
|
||||
break;
|
||||
case WorkerCommand.GetSpeechRules getSpeech:
|
||||
getSpeech.Result.TrySetResult(SpeechRulesOutcome.Fail(SpeechRulesError.UnknownSchool));
|
||||
break;
|
||||
case WorkerCommand.SetSpeechRules setSpeech:
|
||||
setSpeech.Result.TrySetResult(SpeechRulesOutcome.Fail(SpeechRulesError.UnknownSchool));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,6 +623,12 @@ internal sealed class SchoolWorker
|
||||
case WorkerCommand.SetDressRules setRules:
|
||||
setRules.Result.TrySetException(exception);
|
||||
break;
|
||||
case WorkerCommand.GetSpeechRules getSpeech:
|
||||
getSpeech.Result.TrySetException(exception);
|
||||
break;
|
||||
case WorkerCommand.SetSpeechRules setSpeech:
|
||||
setSpeech.Result.TrySetException(exception);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1092,6 +1131,7 @@ internal sealed class SchoolWorker
|
||||
NativeLanguage = _nativeLanguage,
|
||||
Presence = school.CapturePresence(),
|
||||
DressRules = school.DressRules,
|
||||
SpeechRules = school.SpeechRules,
|
||||
Owner = _owner,
|
||||
PortraitSettings = _portraitSettings,
|
||||
});
|
||||
|
||||
@@ -71,4 +71,11 @@ internal abstract record WorkerCommand
|
||||
DressRulePair? PendingStudents,
|
||||
DressRulePair? PendingStaff,
|
||||
TaskCompletionSource<DressRulesOutcome> Result) : WorkerCommand;
|
||||
|
||||
internal sealed record GetSpeechRules(TaskCompletionSource<SpeechRulesOutcome> Result) : WorkerCommand;
|
||||
|
||||
internal sealed record SetSpeechRules(
|
||||
string? PendingStudents,
|
||||
string? PendingStaff,
|
||||
TaskCompletionSource<SpeechRulesOutcome> Result) : WorkerCommand;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user