Client: compile against the goal and box-state changes; the HUD and chamber read the session's box state

Hud.cs reads BadDay.Core.Goal.Withdraw (the session's goal type). Main's
ShownBoxIntensity special case is deleted: the chamber draws session.BoxIntensity
and the HUD adds 'off' from session.BoxOn. The smoke gains the probe the finding
asks for: Box off after the will broke darkens the chamber and the readout.
The event log prints GoalChanged where it printed Withdrew (a flag's name).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-20 03:28:03 +01:00
commit ab544a3f02
4 changed files with 17 additions and 11 deletions

View file

@ -32,8 +32,9 @@ public partial class Chamber : Node3D
/// <summary>The glow last drawn, 0 (dark) to 1.</summary>
public float Glow { get; private set; }
public void Sync(BodyPainBoxSession session, double intensity)
public void Sync(BodyPainBoxSession session)
{
double intensity = session.BoxIntensity; // 0 once the box is off
var box = session.Chamber;
Position = new Vector3(box.CenterX, box.CenterY, box.CenterZ);
_volume.Scale = new Vector3(2f * box.HalfX, 2f * box.HalfY, 2f * box.HalfZ);

View file

@ -76,10 +76,10 @@ public partial class Hud : CanvasLayer
var r = s.Result();
_text.Clear();
_text.Append($"seed {_main.Seed} t {s.TickIndex * BodyPainBox.TickSeconds:F2} s (tick {s.TickIndex})\n");
_text.Append($"box intensity {_main.ShownBoxIntensity:F2} (set {_main.Intensity:F2})\n");
_text.Append($"box intensity {s.BoxIntensity:F2}{(s.BoxOn ? "" : " off")} (set {_main.Intensity:F2})\n");
_text.Append($"pain {s.Pain:F2} strain {s.Strain:F2} resolve {s.Resolve:F2}\n");
_text.Append($"goal {s.Goal} flinches {r.Flinches}\n");
_text.Append($"will broke at {Ms(r.TimeToBreakMs)} withdrew {(s.Goal == Lodur.Goal.Withdraw ? "yes" : "no")}\n");
_text.Append($"will broke at {Ms(r.TimeToBreakMs)} withdrew {(s.Goal == Goal.Withdraw ? "yes" : "no")}\n");
_text.Append($"hand {(s.Hand.InBox ? "in box" : "out of box")} hand out at {Ms(s.HandOutMs)}\n");
_text.Append(s.Finished ? $"outcome {r.Outcome}\n" : "running\n");
var events = _main.Events;

View file

@ -42,13 +42,6 @@ public partial class Main : Node3D
/// <summary>Every event the session has reported since the last Reset, oldest first.</summary>
public IReadOnlyList<BodyEvent> Events => _events;
/// <summary>
/// The box's intensity as the player should see it. The session stops writing it once a run ends because the box
/// was switched off, so the last written value would stay on screen; that run ended with the box off.
/// </summary>
public double ShownBoxIntensity =>
_session is { } s ? (s.Finished && s.Result().Outcome == Outcome.BoxDisabled ? 0.0 : s.BoxIntensity) : 0.0;
/// <summary>The parameters of a run at the given box intensity: every default except the 1/120 s tick the body needs.</summary>
public static PainBoxParameters ParametersFor(double intensity) =>
new() { TickSeconds = BodyPainBox.TickSeconds, BoxIntensity = intensity };
@ -129,7 +122,7 @@ public partial class Main : Node3D
{
var s = Session;
_bodies.Sync(s.View, teleport);
_chamber.Sync(s, ShownBoxIntensity);
_chamber.Sync(s);
Span<BodyEvent> events = stackalloc BodyEvent[8];
int n;
while ((n = s.DrainEvents(events)) > 0)

View file

@ -133,6 +133,18 @@ public partial class Smoke : Node
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); // the HUD draws in _Process, after this frame's signal
Check(_main.Chamber.Glow == 0f, $"the chamber still glows ({_main.Chamber.Glow}) with the box off");
Check(Hud.Readout.Contains("box intensity 0.00"), "the readout does not show the box off: " + Hud.Readout.Split('\n')[1]);
// Box off after the will has broken: the run is over, and the box the player switches off still goes dark.
PressReset(Seed);
while (!Session.Finished) await Frame();
Check(Session.Result().Outcome == Outcome.WillBroke && Session.BoxOn, $"the run ended {Session.Result().Outcome} with the box on: expected WillBroke");
await Frame();
Check(_main.Chamber.Glow > 0.1f, $"the chamber is dark ({_main.Chamber.Glow}) after the will broke, so the probe proves nothing");
Hud.BoxOffButton.EmitSignal(BaseButton.SignalName.Pressed);
await Frame();
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
Check(!Session.BoxOn && _main.Chamber.Glow == 0f && Hud.Readout.Contains("box intensity 0.00 off"), $"after Box off on a finished run: on {Session.BoxOn}, glow {_main.Chamber.Glow}");
}
private void CheckEngineAndScene()