From ab544a3f02186aeca779cb4b30e5c1af4f96e35a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 20 Nov 2026 03:28:03 +0100 Subject: [PATCH] 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 --- client/Chamber.cs | 3 ++- client/Hud.cs | 4 ++-- client/Main.cs | 9 +-------- client/tests/Smoke.cs | 12 ++++++++++++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/client/Chamber.cs b/client/Chamber.cs index 42cd0b8..f45125e 100644 --- a/client/Chamber.cs +++ b/client/Chamber.cs @@ -32,8 +32,9 @@ public partial class Chamber : Node3D /// The glow last drawn, 0 (dark) to 1. 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); diff --git a/client/Hud.cs b/client/Hud.cs index ac4a9e8..c29e2f3 100644 --- a/client/Hud.cs +++ b/client/Hud.cs @@ -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; diff --git a/client/Main.cs b/client/Main.cs index 8287141..11ee9e1 100644 --- a/client/Main.cs +++ b/client/Main.cs @@ -42,13 +42,6 @@ public partial class Main : Node3D /// Every event the session has reported since the last Reset, oldest first. public IReadOnlyList Events => _events; - /// - /// 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. - /// - public double ShownBoxIntensity => - _session is { } s ? (s.Finished && s.Result().Outcome == Outcome.BoxDisabled ? 0.0 : s.BoxIntensity) : 0.0; - /// The parameters of a run at the given box intensity: every default except the 1/120 s tick the body needs. 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 events = stackalloc BodyEvent[8]; int n; while ((n = s.DrainEvents(events)) > 0) diff --git a/client/tests/Smoke.cs b/client/tests/Smoke.cs index b286e72..86c61f7 100644 --- a/client/tests/Smoke.cs +++ b/client/tests/Smoke.cs @@ -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()