Compare commits

..
2 Commits
Author SHA1 Message Date
zwitschi 71b0b53705 Add crowd presentation, fix NPC navigation, refresh screenshots
Full build / Import + headless tests (push) Successful in 27s
Full build / Full desktop build + optional release (push) Failing after 3m37s
NPC navigation (previously dead in the live game)
- Only assign NavigationAgent3D.target_position when it changes: re-assigning every
  frame invalidated the path, so get_next_path_position() kept returning the current
  point and avatars never moved.
- Follow the first path point that is closer to the destination than the avatars are.
  Nav points sit on the navmesh plane (y=0) while bodies stand at y~0.5, so the old
  3D distance test always looked "already there"; path[0] is also the old start point,
  so a naive "far enough away" pick steered backwards and oscillated.
- Fix fsm.state -> fsm.current_state in the idle-lifetime check.

Crowd presentation
- Aggressive behavior, visible weapons, and responder arrivals make idle bystanders
  stop and face the incident for 12 s; someone waiting at the entrance keeps focus.
- Panic (mood >= 0.75) walks people away from the door at 2.4 m/s, then they despawn.
- Wire reactions to EventBus.crowd_changed: CrowdSystem.apply_event() emits on the bus,
  not on its own `changed` signal (the first wiring received nothing).
- Measured a 16-NPC entrance at ~1.2 ms/frame (824 fps, vsync off), so no LOD/culling.

World and HUD
- Skyline is now a ring of four alpha-scissored planes at 200 m instead of a single
  plane; PlaneMesh defaults to horizontal, which is why the backdrop rendered as a band
  overhead. Larger ground plane, mipmapped texture, scissor threshold 0.5 (0.3 left
  mip dashes in the sky), lifted albedo so the city is not pure black.
- Flashlight aims straight ahead and lights the person/door instead of the ground.
- Shorter HUD controls line so it stops overlapping itself.

Tests, tooling, docs
- Headless suite 98 -> 105 (new test_crowd_presentation.gd, 7 tests).
- New smoke_crowd.gd: rubbernecking, panic, and flee-target sanity.
- capture_screenshots.gd starts a shift from the venue menu and stages the night set
  properly; all six README screenshots regenerated.
- README, TODO/DONE (crowd section moved), MEMORY updated. Version 0.2.4.
2026-10-31 20:55:10 +01:00
zwitschi f5ad1642b5 Add PLAN verbs and fix dead incident recording
Full build / Import + headless tests (push) Successful in 26s
Full build / Full desktop build + optional release (push) Failing after 3m31s
Verbs (PLAN levels 1-3)
- Eye contact: own Level 1 radial slice, logged as "eye contact".
- Recognition is a player decision: "Recognize" sets NPCController.player_recognized,
  writes access evidence, and GameManager only then appends a RECOGNITION artifact.
  It is no longer implied by NPC type.
- Body camera: real flag (off by default) driving the REC overlay; B toggles it and
  a formal warning arms it automatically, writing a body_camera incident event.
- Blocking stations the guard 0.9 m from the person toward the entrance and turns
  to face them, instead of only emitting the escalation level.
- Request reason: Level 3 ask answered from the NPC's seeded dialogue_lines.
- Radial grows to 12 slices (174 px outer radius, centered labels).

Incident recording fix
- IncidentRecorder.start_incident() was never called, so add_event /
  add_access_evidence / add_escalation silently no-opped and the shift review
  always reported zero incidents. Incidents now open on focus (guarded by
  has_open_incident), verbs call _ensure_incident, and ShiftCoordinator closes
  leftovers as "unresolved" before building the review.

Copy and docs
- 9 new string keys (eye contact, body camera, recognition, reason, station).
- README controls, 26-step smoke checklist, test count, status lists.
- TODO section moved to DONE; MEMORY records the verb design and the recorder bug.

Verification: headless 98/98, smoke_plan_verbs.gd + smoke_session_shell.gd +
windowed smoke_focus_radial.gd all pass. Version bumped to 0.2.3.
2026-10-31 20:29:50 +01:00
29 changed files with 995 additions and 80 deletions

No files matched your search

+28
View File
@@ -445,3 +445,31 @@ Completed 2026-10-31 (working tree).
- [x] `PLAN.md` Tech Stack / Planned Commands still say GUT and GitHub Actions; the project - [x] `PLAN.md` Tech Stack / Planned Commands still say GUT and GitHub Actions; the project
uses `src/test/test_runner.gd` and `.gitea/workflows/build.yml`. uses `src/test/test_runner.gd` and `.gitea/workflows/build.yml`.
- [x] MEMORY: door_staff_lines log through `GameManager`; 300 s default removed. - [x] MEMORY: door_staff_lines log through `GameManager`; 300 s default removed.
## Remaining PLAN verbs (radial exists)
Completed 2026-10-31 (working tree). Headless **98/98**; `src/test/smoke_plan_verbs.gd` exercises all five verbs.
- [x] Eye contact as a Level 1 action (PLAN / glossary). Distinct from raise-hand. Add a
radial slice if it ships.
- [x] "I recognize this person" is a player decision recorded as evidence, not a pre-attached
artifact on every staff/guest type. Staff still auto-recognize when `override_access` is
empty (`AccessLoadout`).
- [x] Formal warning can activate the body-camera / security-light flag (PLAN Level 2). Overlay
is currently always on; toggling should write an incident event.
- [x] Blocking stations the guard between the person and the door (PLAN Level 3). Today it only
sends `apply_player_action(BLOCKING)`.
- [x] "Request reason for entry" as a Level 3 ask, with a short NPC reply from `dialogue_lines`.
## Crowd presentation
Completed 2026-10-31 (working tree). Headless **105/105**; `src/test/smoke_crowd.gd` verifies rubbernecking and panic clearing. A 16-NPC entrance measured ~1.2 ms/frame (824 fps, vsync off), so no LOD/culling was added at the current cap.
`CrowdSystem` is a mood/attention float. PLAN wants people watching, gathering, and panicking.
- [x] On `aggressive_behavior` / `emergency_responder`, nearby idle NPCs stop and face the
incident (rubberneck). On `crowd_panic`, they move away from the door.
- [x] Profile a busy entrance with textured materials and props; add LOD or culling for distant
NPCs if frame time drops.
+43 -2
View File
@@ -21,8 +21,8 @@ Session memory for durable decisions, state, and gotchas. Keep concise, remove o
Windowed control smoke: `godot --path . --script res://src/test/smoke_focus_radial.gd` → exit 0. Windowed control smoke: `godot --path . --script res://src/test/smoke_focus_radial.gd` → exit 0.
- `main` is in sync with origin. **v0.2.2** tags the session-shell + world-follow-up commit; - `main` is in sync with origin. **v0.2.2** tags the session-shell + world-follow-up commit;
CI builds the portable binaries, NSIS installer, and AppImage on the tag push. CI builds the portable binaries, NSIS installer, and AppImage on the tag push.
- Next work: remaining PLAN verbs in `TODO.md` (eye contact, recognize decision, warning body-cam - Next work: `TODO.md` emergency aftermath (evacuation, unjustified-call investigation), then
flag, blocking station, request reason), then crowd presentation (rubberneck + evacuation). body-camera replay timeline and NPC theater poses.
- Do not re-open `override_access`. Do not bind wand to `W`. Do not remove the radio easter egg. - Do not re-open `override_access`. Do not bind wand to `W`. Do not remove the radio easter egg.
## Current State ## Current State
@@ -60,6 +60,47 @@ Session memory for durable decisions, state, and gotchas. Keep concise, remove o
`StaticBody3D` with per-tread `BoxShape3D` colliders; marquee `font_size` 160 / outline 24; focus `StaticBody3D` with per-tread `BoxShape3D` colliders; marquee `font_size` 160 / outline 24; focus
torus 0.26–0.34 + name tag 48px; `NpcAvatar.ephemeral`/`lifetime_s` despawns routine traffic torus 0.26–0.34 + name tag 48px; `NpcAvatar.ephemeral`/`lifetime_s` despawns routine traffic
(authored events stay). Guard spawn height verified on the landing (guard_y=0.84). (authored events stay). Guard spawn height verified on the landing (guard_y=0.84).
- **PLAN verbs (2026-10-31, uncommitted):** the radial now has 12 slices
(`Stop, Look, Point, No, Ask, Inspect, Wand, Warn, Block, Reason, Recognize, Radio`).
`eye_contact` reuses the Level 1 reaction table via `_apply_interaction`. Recognition is a player
decision: `NPCController.player_recognized` + `IncidentRecorder.add_access_evidence`, and
`GameManager._artifacts_for()` prepends a `RECOGNITION` artifact only after the player declares
it. The body camera is a real flag (`GameManager.body_camera_on`, `Hud.set_body_camera`), off by
default, `B` toggles it, and a formal warning arms it and writes a `body_camera` incident event.
Blocking also calls `_station_between()` to physically place the guard 0.9 m from the NPC toward
the entrance. `_request_reason()` logs the NPC's seeded `dialogue_lines` pick.
- **NPC navigation was dead (fixed 2026-10-31):** avatars never moved in the live game, for three
stacked reasons. (1) `agent.target_position` was re-assigned every physics frame, which
invalidates the path so `get_next_path_position()` keeps returning the current point — only set
it when the target changes. (2) Nav path points sit on the navmesh plane (y=0) while bodies stand
at y≈0.5, so a 3D "are we there" test always looked 0.5 m away and the horizontal direction was
zero — compare horizontally. (3) `path[0]` is the old start point, so picking any point "far
enough away" can pick the point behind you and oscillate — pick the first point that is
**closer to the goal** than the current position. `_nav_try_frames`/`_move_direct` fallback is
still there.
- **Crowd reactions listen on the EventBus:** `CrowdSystem.apply_event()` emits
`event_bus.crowd_changed`; its own `changed` signal is never emitted. `GameManager._connect_crowd()`
therefore connects to `coordinator.event_bus.crowd_changed` (reconnect after every
`coordinator.setup()`, which recreates both crowd and event bus).
- **Crowd presentation:** `NpcAvatar.start_rubberneck(at)` (idle bystanders away from the door stop
and face the incident for 12 s) and `start_flee(from)` (panic: walk away at 2.4 m/s, then free
themselves). Someone `awaiting_interaction` within 3 m of the door is "engaged" and does not
rubberneck. Use `position` (not `global_position`) for that distance check so it also works in
headless tests outside the tree.
- **Perf:** a busy 16-NPC entrance measured ~1.2 ms/frame (824 fps with vsync off, 800 samples),
so LOD/culling is not warranted at `MAX_LIVE_NPCS = 16`. Re-measure before raising the cap.
- **Incident recording was dead:** `IncidentRecorder.start_incident()` was never called, so every
`add_event`/`add_access_evidence` silently no-opped and the review always showed 0 incidents.
`_begin_incident()` now starts one per focused NPC (`has_open_incident()` guard), verbs call
`_ensure_incident()`, and `ShiftCoordinator._finish_shift()` closes leftovers as `unresolved`
before building the review.
- **Skyline backdrop (2026-10-31):** `PlaneMesh` defaults to a **horizontal** XZ plane — set
`mesh.orientation = PlaneMesh.FACE_Z` or the "backdrop" renders as a band overhead. The skyline
is now a ring of four 400x60 planes at 200 m (center y=30, so building bases meet the ground),
`TEXTURE_FILTER` default, `TRANSPARENCY_ALPHA_SCISSOR` with threshold **0.5** (0.3 left faint
mip dashes across the sky), unshaded with a lifted albedo (`Color(2.6,2.7,3.0)`) so it is not
pure black. Ground is 500x500 so no sky gap shows under the buildings. The `skyline.png` import
needs `mipmaps/generate=true`.
- **Asset gotcha:** `assets/textures/game_ready/` is *not* imported (no `.import`). Use the - **Asset gotcha:** `assets/textures/game_ready/` is *not* imported (no `.import`). Use the
imported `assets/textures/skyline.png` path. Untracked duplicate folder should not be referenced. imported `assets/textures/skyline.png` path. Untracked duplicate folder should not be referenced.
- Host sign-in follow-up remains deferred. PLAN.md + ADRs 0007–0010 still describe the intended UX. - Host sign-in follow-up remains deferred. PLAN.md + ADRs 0007–0010 still describe the intended UX.
+29 -9
View File
@@ -28,9 +28,9 @@ The central design goal is simple:
**All releases:** <https://git.allucanget.biz/zwitschi/security-game/releases> **All releases:** <https://git.allucanget.biz/zwitschi/security-game/releases>
> **Latest: v0.2.2** — session shell (venue menu, pause overlay, persisted settings) and the > **Latest: v0.2.4** — crowd presentation (rubbernecking and panic), the distant skyline ring,
> world presentation follow-ups (walkable steps, transparent skyline, larger marquee and focus > working NPC navigation, and a refreshed screenshot gallery.
> ring). Releases are built automatically when a `vX.Y.Z` tag is pushed > Releases are built automatically when a `vX.Y.Z` tag is pushed
> (see [`docs/RELEASING.md`](docs/RELEASING.md)); manual builds use > (see [`docs/RELEASING.md`](docs/RELEASING.md)); manual builds use
> `./tools/build_releases.sh`. Installer/AppImage packaging runs in the same pipeline > `./tools/build_releases.sh`. Installer/AppImage packaging runs in the same pipeline
> (NSIS + appimagetool) and uploads with the portable binaries. > (NSIS + appimagetool) and uploads with the portable binaries.
@@ -208,6 +208,12 @@ godot --path . --script res://src/test/smoke_focus_radial.gd
# Session-shell smoke: menu → shift → pause → settings → menu (headless or windowed) # Session-shell smoke: menu → shift → pause → settings → menu (headless or windowed)
godot --headless --path . --script res://src/test/smoke_session_shell.gd godot --headless --path . --script res://src/test/smoke_session_shell.gd
# PLAN-verb smoke: recognize, request reason, body camera, warning, blocking
godot --headless --path . --script res://src/test/smoke_plan_verbs.gd
# Crowd smoke: rubbernecking on aggression, panic clearing the entrance
godot --headless --path . --script res://src/test/smoke_crowd.gd
``` ```
The unit test runner is the project's own lightweight harness (no editor plugin required) so CI can run it without the editor. The unit test runner is the project's own lightweight harness (no editor plugin required) so CI can run it without the editor.
@@ -217,7 +223,7 @@ The unit test runner is the project's own lightweight harness (no editor plugin
| Input | Action | | Input | Action |
| --- | --- | | --- | --- |
| W/A/S/D + mouse | Move and look | | W/A/S/D + mouse | Move and look |
| Space / left click | Action wheel for the focused person | | Space / left click | Action wheel for the focused person (Stop, Look, Point, No, Ask, Inspect, Wand, Warn, Block, Reason, Recognize, Radio) |
| A / D or ←/→ | Step through the action wheel (while it is open) | | A / D or ←/→ | Step through the action wheel (while it is open) |
| Space / left click | Confirm the highlighted action (while the wheel is open) | | Space / left click | Confirm the highlighted action (while the wheel is open) |
| Esc / right click | Close the top panel; Esc with nothing open pauses the shift (Esc again resumes) | | Esc / right click | Close the top panel; Esc with nothing open pauses the shift (Esc again resumes) |
@@ -235,6 +241,7 @@ The unit test runner is the project's own lightweight harness (no editor plugin
| V | Cycle venue (debug shortcut; restart via V restarts the current shift) | | V | Cycle venue (debug shortcut; restart via V restarts the current shift) |
| Tab | Cycle target among nearby NPCs (aim-free alternative) | | Tab | Cycle target among nearby NPCs (aim-free alternative) |
| G | Toggle flashlight (widens NPC perception at night) | | G | Toggle flashlight (widens NPC perception at night) |
| B | Toggle the body camera; a formal warning switches it on automatically |
| L | Lock / unlock the restricted door (thwarts forced entry) | | L | Lock / unlock the restricted door (thwarts forced entry) |
| F | Toggle debug overlay | | F | Toggle debug overlay |
@@ -259,17 +266,22 @@ Implemented so far:
- Godot 4.3 project scaffold, input map, procedural world builder - Godot 4.3 project scaffold, input map, procedural world builder
- Venue-driven simulation core: `ShiftCoordinator`, `VenueScenario`, `EventScheduler`, `NPCController` + FSM, `AccessVerifier`, `EscalationManager`, `RadioSystem`, `IncidentRecorder`, `ReputationEvaluator`, `CrowdSystem` - Venue-driven simulation core: `ShiftCoordinator`, `VenueScenario`, `EventScheduler`, `NPCController` + FSM, `AccessVerifier`, `EscalationManager`, `RadioSystem`, `IncidentRecorder`, `ReputationEvaluator`, `CrowdSystem`
- Three authored scenarios (Hollywood Boulevard building, The Joke Shop, Late Night TV Studio) with access policies, NPC archetypes, and event pools - Three authored scenarios (Hollywood Boulevard building, The Joke Shop, Late Night TV Studio) with access policies, NPC archetypes, and event pools
- Headless unit tests: **88 passing** (access rules and venue-correct access loadout, escalation, radio cooldown/battery, NPC reaction determinism, door lock, flashlight perception, persistence round-trip, settings round-trip, navmesh, step colliders, skyline alpha, scenario data, full-shift simulation, wand screening, responder dispatch, localization strings, focus cone, action wheel, session shell) - Headless unit tests: **105 passing** (access rules and venue-correct access loadout, escalation, radio cooldown/battery, NPC reaction determinism, door lock, flashlight perception, persistence round-trip, settings round-trip, navmesh, step colliders, skyline alpha, scenario data, full-shift simulation, wand screening, responder dispatch, localization strings, focus cone, action wheel, session shell, PLAN verbs and incident recording, crowd presentation)
- Simulation extras: protester archetype, CALL_SOMEONE reaction, door lock/secure mechanic (visual indicator), flashlight with night perception bonus, LATE shift phase reaching the violent-threat event - Simulation extras: protester archetype, CALL_SOMEONE reaction, door lock/secure mechanic (visual indicator), flashlight with night perception bonus, LATE shift phase reaching the violent-threat event
- First-person prototype with interaction HUD, access inspection, wand screening, radio report form (incl. emergency hold-to-confirm), dispatched responder avatars, aim-free targeting, venue cycling between all three scenarios, color-coded escalation feedback, procedural audio cues, navigation-mesh NPC paths, JSON-backed localized strings, persisted shift history, debug overlay, and shift review - First-person prototype with interaction HUD, access inspection, wand screening, radio report form (incl. emergency hold-to-confirm), dispatched responder avatars, aim-free targeting, venue cycling between all three scenarios, color-coded escalation feedback, procedural audio cues, navigation-mesh NPC paths, JSON-backed localized strings, persisted shift history, debug overlay, and shift review
- Control pass: focus cone on NPC heads with a billboarded gold ring and name, action wheel (LMB/Space) with de-escalation-first slices, mouse-look freeze while a panel is open, acceleration-based walking, and named input actions (`action_menu`, `confirm`, `cancel`, `inspect`, `wand`) - Control pass: focus cone on NPC heads with a billboarded gold ring and name, action wheel (LMB/Space) with de-escalation-first slices, mouse-look freeze while a panel is open, acceleration-based walking, and named input actions (`action_menu`, `confirm`, `cancel`, `inspect`, `wand`)
- Session shell: venue start menu (keyboard + mouse), Esc pause overlay (resume / restart / settings / quit to menu), settings panel with mouse-look sensitivity and HUD font scale persisted to `user://settings.json`, and "Run another shift" returning to the venue menu - Session shell: venue start menu (keyboard + mouse), Esc pause overlay (resume / restart / settings / quit to menu), settings panel with mouse-look sensitivity and HUD font scale persisted to `user://settings.json`, and "Run another shift" returning to the venue menu
- World presentation: skyline backdrop rendered with an alpha material, walkable step and landing colliders, larger marquee text, and larger focus ring / name tag - World presentation: skyline backdrop rendered with an alpha material, walkable step and landing colliders, larger marquee text, and larger focus ring / name tag
- Routine traffic despawns after a while at its waypoint so the crowd cap no longer fills with idle standers - Routine traffic despawns after a while at its waypoint so the crowd cap no longer fills with idle standers
- PLAN verbs: eye contact (distinct Level 1 cue), recognizing a person as a player decision recorded as access evidence, a body-camera flag that a formal warning arms (and `B` toggles), blocking that physically stations the guard between the person and the door, and a Level 3 request-reason ask answered from the NPC's `dialogue_lines`
- Incidents are now actually opened on focus and closed at shift end, so player actions, access evidence, escalation levels, and unresolved interactions reach the review (previously every recorded event was dropped)
- Crowd presentation: aggressive behavior and responder arrivals make idle bystanders stop and face the incident; panic sends people away from the door (and they leave the scene). A busy 16-NPC entrance measured ~1.2 ms/frame, so no LOD/culling was needed at the current cap
- Distant skyline ring: four alpha-scissored planes at 200 m read as a hazy city on the horizon (the baked backdrop used to show as a black slab), with a larger ground plane so the buildings meet the street
- Flashlight aims straight ahead and lights the person/door being checked instead of the ground in front of the guard
- Visual polish pass (v0.2.0): phase-based lighting (sun/sky/ambient per shift phase), street lamps with night-mode bulbs and omni lights, glowing marquee signage, crosswalk, planters and low-poly street trees, NPC height/brightness variety, denser routine traffic — day and late-night screenshot sets - Visual polish pass (v0.2.0): phase-based lighting (sun/sky/ambient per shift phase), street lamps with night-mode bulbs and omni lights, glowing marquee signage, crosswalk, planters and low-poly street trees, NPC height/brightness variety, denser routine traffic — day and late-night screenshot sets
- Assets pass: authored textures in `assets/textures/` (brick facade, concrete, asphalt, awning, skyline, vignette, HUD icons, access-card art) generated by `tools/generate_textures.py`, soft sun shadows, humanoid NPC rigs with archetype props + procedural walk bob and attention head-turn, inspection artifact cards, escalation vignette, mode icons, and a body-camera overlay (REC + shift clock) - Assets pass: authored textures in `assets/textures/` (brick facade, concrete, asphalt, awning, skyline, vignette, HUD icons, access-card art) generated by `tools/generate_textures.py`, soft sun shadows, humanoid NPC rigs with archetype props + procedural walk bob and attention head-turn, inspection artifact cards, escalation vignette, mode icons, and a body-camera overlay (REC + shift clock)
Not yet implemented: body-camera replay timeline, eye-contact and request-reason verbs, crowd rubbernecking, emergency aftermath, editor-based GUT integration, and crowd performance profiling/LOD (see `TODO.md`). Not yet implemented: body-camera replay timeline, emergency aftermath, editor-based GUT integration, and crowd performance profiling/LOD (see `TODO.md`).
### Smoke Test Checklist ### Smoke Test Checklist
@@ -290,9 +302,17 @@ Not yet implemented: body-camera replay timeline, eye-contact and request-reason
15. `R` opens the emergency form; the button must be held ~1.6s or the call cancels. 15. `R` opens the emergency form; the button must be held ~1.6s or the call cancels.
16. `G` toggles the flashlight (indicator appears in the HUD); `L` toggles the door lock (indicator turns red when locked). 16. `G` toggles the flashlight (indicator appears in the HUD); `L` toggles the door lock (indicator turns red when locked).
17. `F` toggles the debug overlay with NPC states and shift stats. 17. `F` toggles the debug overlay with NPC states and shift stats.
18. `Esc` with nothing open pauses the shift; resume / restart / settings / quit-to-menu all work, and settings changes persist across a restart. 18. The wheel's `Look` slice is eye contact (Level 1) and logs as its own action.
19. NPCs route around the building using the navigation mesh (no stuck-at-wall behavior during a smoke run). 19. `Reason` asks why the person is there and logs their `dialogue_lines` reply.
20. When the shift timer reaches 0, the shift review screen shows grade, incident summary, and persisted shift history; "Run another shift" returns to the venue menu. 20. `Recognize` records the guard's recognition as access evidence; pressing it twice says so.
21. `Warn` turns the body camera on (REC overlay appears); `B` toggles it manually.
22. `Block` moves the guard between the person and the door.
23. The shift review reports the incident count, including interactions left unresolved.
24. Escalating on someone (or a responder arriving) makes idle bystanders stop and face the incident.
25. Repeated alarms panic the crowd and nearby people clear away from the door instead of standing around.
26. `Esc` with nothing open pauses the shift; resume / restart / settings / quit-to-menu all work, and settings changes persist across a restart.
27. NPCs route around the building using the navigation mesh (no stuck-at-wall behavior during a smoke run).
28. When the shift timer reaches 0, the shift review screen shows grade, incident summary, and persisted shift history; "Run another shift" returns to the venue menu.
## Development Workflow ## Development Workflow
+3 -25
View File
@@ -1,33 +1,11 @@
# TODO # TODO
Godot 4.3 prototype. Release **v0.2.2** is tagged from the session-shell commit; CI builds the Godot 4.3 prototype. Release **v0.2.4** is tagged; CI builds the installers and AppImage.
installers and AppImage. Headless suite **88/88**, plus `smoke_session_shell.gd` and the windowed Headless suite **105/105**, plus `smoke_session_shell.gd`, `smoke_plan_verbs.gd`,
focus/radial smoke. `smoke_crowd.gd`, and the windowed focus/radial smoke.
Host `REQUIRE_SIGNIN_VIEW` stays deferred. Host `REQUIRE_SIGNIN_VIEW` stays deferred.
## Remaining PLAN verbs (radial exists)
- [ ] Eye contact as a Level 1 action (PLAN / glossary). Distinct from raise-hand. Add a
radial slice if it ships.
- [ ] "I recognize this person" is a player decision recorded as evidence, not a pre-attached
artifact on every staff/guest type. Staff still auto-recognize when `override_access` is
empty (`AccessLoadout`).
- [ ] Formal warning can activate the body-camera / security-light flag (PLAN Level 2). Overlay
is currently always on; toggling should write an incident event.
- [ ] Blocking stations the guard between the person and the door (PLAN Level 3). Today it only
sends `apply_player_action(BLOCKING)`.
- [ ] "Request reason for entry" as a Level 3 ask, with a short NPC reply from `dialogue_lines`.
## Crowd presentation
`CrowdSystem` is a mood/attention float. PLAN wants people watching, gathering, and panicking.
- [ ] On `aggressive_behavior` / `emergency_responder`, nearby idle NPCs stop and face the
incident (rubberneck). On `crowd_panic`, they move away from the door.
- [ ] Profile a busy entrance with textured materials and props; add LOD or culling for distant
NPCs if frame time drops.
## Emergency aftermath ## Emergency aftermath
Responder outcomes (`command` / `restraint` / `evacuation` / `arrest`) are log lines. PLAN also Responder outcomes (`command` / `restraint` / `evacuation` / `arrest`) are log lines. PLAN also
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

+13 -1
View File
@@ -1,6 +1,7 @@
{ {
"hud.controls": "LMB/Space action menu · A/D or arrows highlight · Space confirm · Esc/RMB cancel · R emergency · E inspect · C wand · Q polite · 1-6 shortcuts · Tab cycle · G light · L lock · V venue · F debug", "hud.controls": "LMB/Space wheel · A/D step · Space confirm · Esc cancel · R emergency · E inspect · C wand · Q polite · B camera · Tab cycle · G light · L lock · F debug",
"radial.raise_hand": "Stop", "radial.raise_hand": "Stop",
"radial.eye_contact": "Look",
"radial.point": "Point", "radial.point": "Point",
"radial.head_shake": "No", "radial.head_shake": "No",
"radial.polite": "Ask", "radial.polite": "Ask",
@@ -8,6 +9,8 @@
"radial.wand": "Wand", "radial.wand": "Wand",
"radial.warning": "Warn", "radial.warning": "Warn",
"radial.block": "Block", "radial.block": "Block",
"radial.reason": "Reason",
"radial.recognize": "Recognize",
"radial.radio": "Radio", "radial.radio": "Radio",
"hud.escalation_prefix": "Escalation: %s", "hud.escalation_prefix": "Escalation: %s",
"hud.cooldown": "EMERGENCY RADIO COOLDOWN: %.0fs", "hud.cooldown": "EMERGENCY RADIO COOLDOWN: %.0fs",
@@ -42,6 +45,15 @@
"react.return_later": "%s leaves but may come back.", "react.return_later": "%s leaves but may come back.",
"react.call_someone": "%s calls someone for help.", "react.call_someone": "%s calls someone for help.",
"react.none": "No reaction (yet).", "react.none": "No reaction (yet).",
"bodycam.on": "Body camera on.",
"bodycam.off": "Body camera off.",
"bodycam.warning": "Formal warning recorded on the body camera.",
"recognition.declared": "You tell %s you recognize them. Logged as evidence.",
"recognition.already": "You have already recognized %s this shift.",
"reason.ask": "You ask %s why they are here.",
"reason.reply": "%s: \"%s\"",
"reason.silent": "%s says nothing and looks away.",
"station.blocking": "You step between %s and the door.",
"perception.near": "%s notices you standing close.", "perception.near": "%s notices you standing close.",
"perception.aware": "%s notices you watching.", "perception.aware": "%s notices you watching.",
"door.locked": "The door is now locked.", "door.locked": "The door is now locked.",
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 953 KiB

After

Width:  |  Height:  |  Size: 986 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

+1 -1
View File
@@ -8,7 +8,7 @@ config_version=5
config/name="Step Line" config/name="Step Line"
config/description="Workplace security simulation about observation, access verification, and proportionate escalation." config/description="Workplace security simulation about observation, access verification, and proportionate escalation."
config/version="0.2.2" config/version="0.2.4"
run/main_scene="res://scenes/main.tscn" run/main_scene="res://scenes/main.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility") config/features=PackedStringArray("4.3", "GL Compatibility")
+14
View File
@@ -45,6 +45,20 @@ func apply_event(event_type: String) -> void:
"event": event_type, "event": event_type,
}) })
## Presentation cue for the avatars after a crowd event (PLAN: Public Crowd
## Reaction). "watch" = rubberneck at the incident, "flee" = move away from the
## door, "" = no reaction. Pure so it is headless-testable.
static func reaction_for_event(event_type: String) -> String:
match event_type:
"aggressive_behavior", "visible_weapon", "emergency_responder":
return "watch"
_:
return ""
## True once the crowd is panicking hard enough that people should clear out.
func should_flee() -> bool:
return crowd_panic
func summary() -> Dictionary: func summary() -> Dictionary:
return { return {
"mood": mood, "mood": mood,
+13
View File
@@ -78,6 +78,19 @@ func close_incident(npc_id: String, outcome: String) -> Dictionary:
func open_incidents_count() -> int: func open_incidents_count() -> int:
return _open_incidents.size() return _open_incidents.size()
## True when an incident is already open for this NPC (avoids duplicating one
## incident every time the player re-focuses the same person).
func has_open_incident(npc_id: String) -> bool:
return _open_incidents.has(npc_id)
## Close every still-open incident at shift end so the review does not silently
## drop interactions the player never resolved. Returns how many were closed.
func close_all_open(outcome: String = "unresolved") -> int:
var ids: Array = _open_incidents.keys()
for npc_id in ids:
close_incident(str(npc_id), outcome)
return ids.size()
func to_dict() -> Dictionary: func to_dict() -> Dictionary:
return { return {
"incidents": incidents.duplicate(true), "incidents": incidents.duplicate(true),
+15
View File
@@ -34,6 +34,11 @@ var guard_noticed := false
## Whether this NPC has passed the handheld wand screening (The Joke Shop). ## Whether this NPC has passed the handheld wand screening (The Joke Shop).
var screened := false var screened := false
## Whether the guard has declared they recognize this person (a player decision
## recorded as evidence, PLAN.md: Authorized Access).
var player_recognized := false
## Last reply the NPC gave when asked for their reason for entry.
var last_reason_reply := ""
## Event-level access payload (`has_id`, `has_ticket`, statuses). Empty means ## Event-level access payload (`has_id`, `has_ticket`, statuses). Empty means
## venue/type defaults from AccessLoadout. ## venue/type defaults from AccessLoadout.
var access_override: Dictionary = {} var access_override: Dictionary = {}
@@ -150,6 +155,16 @@ func tick_return(delta: float) -> bool:
func decide_leave() -> bool: func decide_leave() -> bool:
return leave_requested return leave_requested
## Level 3 ask: request the person's reason for entry (PLAN.md). Pure and
## headless-testable; returns the line this NPC answers with ("" if silent).
func request_reason() -> String:
var lines: Array[String] = profile.dialogue_lines if profile else []
if lines.is_empty():
last_reason_reply = ""
return ""
last_reason_reply = lines[rng.randi_range(0, lines.size() - 1)]
return last_reason_reply
## Perception pass: given the guard's distance (meters), return a perception ## Perception pass: given the guard's distance (meters), return a perception
## result describing how the NPC reacts to the guard's presence. Pure and ## result describing how the NPC reacts to the guard's presence. Pure and
## headless-testable; the presentation layer feeds it the real distance. ## headless-testable; the presentation layer feeds it the real distance.
+2
View File
@@ -119,6 +119,8 @@ func _finish_shift() -> void:
return return
_shift_finished = true _shift_finished = true
running = false running = false
# Interactions the player never resolved still belong in this shift's review.
recorder.close_all_open("unresolved")
var review := build_review() var review := build_review()
event_bus.shift_state_changed.emit({"running": false, "review": review}) event_bus.shift_state_changed.emit({"running": false, "review": review})
shift_ended.emit(review) shift_ended.emit(review)
+197 -5
View File
@@ -9,6 +9,7 @@ const AccessArtifact := preload("res://src/core/access_artifact.gd")
const AccessLoadout := preload("res://src/core/access_loadout.gd") const AccessLoadout := preload("res://src/core/access_loadout.gd")
const AccessVerifier := preload("res://src/core/access_verifier.gd") const AccessVerifier := preload("res://src/core/access_verifier.gd")
const DoorState := preload("res://src/core/door_state.gd") const DoorState := preload("res://src/core/door_state.gd")
const CrowdSystem := preload("res://src/core/crowd_system.gd")
const WandScreener := preload("res://src/core/wand_screener.gd") const WandScreener := preload("res://src/core/wand_screener.gd")
const RadioSystem := preload("res://src/core/radio_system.gd") const RadioSystem := preload("res://src/core/radio_system.gd")
const ScenarioFactory := preload("res://src/content/scenario_factory.gd") const ScenarioFactory := preload("res://src/content/scenario_factory.gd")
@@ -30,6 +31,7 @@ const SettingsPanel := preload("res://src/game/ui/settings_panel.gd")
var world_builder: WorldBuilder = null var world_builder: WorldBuilder = null
var door := DoorState.new() var door := DoorState.new()
var flashlight_on := false var flashlight_on := false
var body_camera_on := false
var coordinator: ShiftCoordinator = null var coordinator: ShiftCoordinator = null
var guard: GuardController = null var guard: GuardController = null
var _sun: DirectionalLight3D = null var _sun: DirectionalLight3D = null
@@ -133,6 +135,7 @@ func _ready() -> void:
coordinator.npc_spawn_requested.connect(_spawn_npc) coordinator.npc_spawn_requested.connect(_spawn_npc)
coordinator.shift_ended.connect(_on_shift_ended) coordinator.shift_ended.connect(_on_shift_ended)
coordinator.radio.responder_arrived.connect(_on_responder_arrived) coordinator.radio.responder_arrived.connect(_on_responder_arrived)
_connect_crowd()
_build_ui() _build_ui()
_last_phase = -1 _last_phase = -1
@@ -159,10 +162,13 @@ func _build_guard() -> GuardController:
flashlight.name = "Flashlight" flashlight.name = "Flashlight"
flashlight.visible = false flashlight.visible = false
flashlight.position = Vector3(0, -0.15, -0.4) flashlight.position = Vector3(0, -0.15, -0.4)
flashlight.rotation_degrees = Vector3(-10, 0, 0) # Aim straight ahead: tilting it down made the cone hit the ground right in
flashlight.spot_range = 18.0 # front of the guard instead of the person or door being checked.
flashlight.spot_angle = 28.0 flashlight.rotation_degrees = Vector3.ZERO
flashlight.light_energy = 2.5 flashlight.spot_range = 22.0
flashlight.spot_angle = 30.0
flashlight.light_energy = 4.0
flashlight.spot_attenuation = 0.6
head.add_child(flashlight) head.add_child(flashlight)
var collider := CollisionShape3D.new() var collider := CollisionShape3D.new()
var shape := CapsuleShape3D.new() var shape := CapsuleShape3D.new()
@@ -211,8 +217,12 @@ func _reset_shift_state() -> void:
inspection_open = false inspection_open = false
wand_open = false wand_open = false
_wand_cooldown = 0.0 _wand_cooldown = 0.0
body_camera_on = false
if hud:
hud.set_body_camera(false)
scenario_duration_s = selected_scenario.shift_duration_s scenario_duration_s = selected_scenario.shift_duration_s
coordinator.setup(selected_scenario, scenario_duration_s, 4242) coordinator.setup(selected_scenario, scenario_duration_s, 4242)
_connect_crowd()
_last_phase = -1 _last_phase = -1
_apply_phase_lighting() _apply_phase_lighting()
@@ -477,6 +487,51 @@ func _on_responder_arrived(call: Dictionary) -> void:
}) })
coordinator.crowd.apply_event("emergency_responder" if call.get("type", "") == "emergency" else "calm_professionalism") coordinator.crowd.apply_event("emergency_responder" if call.get("type", "") == "emergency" else "calm_professionalism")
## Crowd presentation (PLAN: Public Crowd Reaction). The crowd system is a
## mood/attention float; this turns its events into avatar behavior.
func _connect_crowd() -> void:
# CrowdSystem routes its updates through the EventBus (`event_bus.crowd_changed`);
# its own `changed` signal is not emitted by apply_event().
if coordinator == null or coordinator.event_bus == null:
return
if not coordinator.event_bus.crowd_changed.is_connected(_on_crowd_changed):
coordinator.event_bus.crowd_changed.connect(_on_crowd_changed)
func _on_crowd_changed(payload: Dictionary) -> void:
var event_type := str(payload.get("event", ""))
var panic := bool(payload.get("panic", false))
# Panic wins: people clear away from the entrance.
if panic or event_type == "crowd_panic":
_flee_crowd()
return
if CrowdSystem.reaction_for_event(event_type) == "watch":
_rubberneck_crowd()
func _incident_point() -> Vector3:
if targeted_npc is Node3D and is_instance_valid(targeted_npc):
return (targeted_npc as Node3D).global_position
if guard:
return guard.global_position
return Vector3(0, 0, 1.2)
## Idle bystanders stop and face the incident instead of walking on.
func _rubberneck_crowd() -> void:
var point := _incident_point()
for npc in npcs:
if not is_instance_valid(npc) or not npc.has_method("start_rubberneck"):
continue
if npc == targeted_npc:
continue
npc.start_rubberneck(point)
## Panic: everyone nearby moves away from the door.
func _flee_crowd() -> void:
var door_pos: Vector3 = selected_scenario._location_or_default("entrance", Vector3(0, 0.5, 1.2))
for npc in npcs:
if not is_instance_valid(npc) or not npc.has_method("start_flee"):
continue
npc.start_flee(door_pos)
func _responder_profile() -> NpcProfile: func _responder_profile() -> NpcProfile:
var p := NpcProfile.new() var p := NpcProfile.new()
p.id = "responder" p.id = "responder"
@@ -520,6 +575,11 @@ func _begin_incident(avatar: Node3D) -> void:
current_incident_npc_id = controller.npc_id current_incident_npc_id = controller.npc_id
current_incident_active = true current_incident_active = true
current_npc_truth = _read_npc_truth(controller) current_npc_truth = _read_npc_truth(controller)
# Open a structured incident so player actions, access evidence, and
# escalation levels are actually recorded (ADR-0005). Without this the
# recorder drops every event and the review reports zero incidents.
if not coordinator.recorder.has_open_incident(controller.npc_id):
coordinator.recorder.start_incident(controller.npc_id, "player_focus")
var profile: Object = controller.profile var profile: Object = controller.profile
var label := "%s — %s" % [ var label := "%s — %s" % [
profile.display_name if profile else "?", profile.display_name if profile else "?",
@@ -602,6 +662,8 @@ func _handle_key(event: InputEvent) -> void:
_toggle_flashlight() _toggle_flashlight()
KEY_L: KEY_L:
_toggle_door_lock() _toggle_door_lock()
KEY_B:
_toggle_body_camera()
KEY_V: KEY_V:
_cycle_venue() _cycle_venue()
_: _:
@@ -720,6 +782,8 @@ func _on_radial_confirmed(slice_id: String) -> void:
match slice_id: match slice_id:
"raise_hand": "raise_hand":
_apply_interaction(Rules.Level.SIMPLE_DETERRENCE, "raise hand") _apply_interaction(Rules.Level.SIMPLE_DETERRENCE, "raise hand")
"eye_contact":
_eye_contact()
"point": "point":
_apply_interaction(Rules.Level.SIMPLE_DETERRENCE, "point") _apply_interaction(Rules.Level.SIMPLE_DETERRENCE, "point")
"head_shake": "head_shake":
@@ -734,6 +798,10 @@ func _on_radial_confirmed(slice_id: String) -> void:
_apply_interaction(Rules.Level.FORMAL_WARNING, "formal warning") _apply_interaction(Rules.Level.FORMAL_WARNING, "formal warning")
"block": "block":
_apply_interaction(Rules.Level.BLOCKING, "blocking") _apply_interaction(Rules.Level.BLOCKING, "blocking")
"reason":
_request_reason()
"recognize":
_recognize_target()
"radio": "radio":
_open_radio(false) _open_radio(false)
@@ -768,6 +836,29 @@ func _toggle_flashlight() -> void:
hud.set_flashlight(flashlight_on) hud.set_flashlight(flashlight_on)
hud.log(Strings.lookup("flashlight.on") if flashlight_on else Strings.lookup("flashlight.off")) hud.log(Strings.lookup("flashlight.on") if flashlight_on else Strings.lookup("flashlight.off"))
## Toggle the body camera (PLAN Level 2). The overlay is only visible while the
## camera is on, and turning it on or off is written to the incident log.
func _toggle_body_camera() -> void:
_set_body_camera(not body_camera_on, "manual")
func _set_body_camera(on: bool, reason: String) -> void:
if body_camera_on == on:
return
body_camera_on = on
if hud:
hud.set_body_camera(on)
var controller: Object = _targeted_controller()
if controller != null:
_ensure_incident(controller)
if coordinator and current_incident_active:
coordinator.recorder.add_event(current_incident_npc_id, {
"type": "body_camera",
"on": on,
"reason": reason,
})
if hud:
hud.log(Strings.lookup("bodycam.on") if on else Strings.lookup("bodycam.off"))
## Lock or unlock the restricted door (PLAN.md: Level 3). Locked doors thwart ## Lock or unlock the restricted door (PLAN.md: Level 3). Locked doors thwart
## FORCE_ENTRY attempts during the reaction flow. ## FORCE_ENTRY attempts during the reaction flow.
func _toggle_door_lock() -> void: func _toggle_door_lock() -> void:
@@ -819,6 +910,7 @@ func _apply_interaction(level: int, action_name: String) -> void:
var controller: Object = _targeted_controller() var controller: Object = _targeted_controller()
if controller == null or coordinator == null: if controller == null or coordinator == null:
return return
_ensure_incident(controller)
var outcome: Dictionary = controller.apply_player_action(level) var outcome: Dictionary = controller.apply_player_action(level)
var npc_id: String = controller.npc_id var npc_id: String = controller.npc_id
coordinator.recorder.add_event(npc_id, { coordinator.recorder.add_event(npc_id, {
@@ -829,11 +921,88 @@ func _apply_interaction(level: int, action_name: String) -> void:
coordinator.recorder.add_escalation(npc_id, level, "%s on %s" % [action_name, npc_id]) coordinator.recorder.add_escalation(npc_id, level, "%s on %s" % [action_name, npc_id])
if level >= Rules.Level.FORMAL_WARNING: if level >= Rules.Level.FORMAL_WARNING:
coordinator.reputation.apply("prop", -1.5, "escalation L%d %s" % [level, action_name]) coordinator.reputation.apply("prop", -1.5, "escalation L%d %s" % [level, action_name])
# A formal warning is the documented point where the body camera / security
# light goes on: it creates a record of the interaction (PLAN Level 2).
if level == Rules.Level.FORMAL_WARNING and not body_camera_on:
_set_body_camera(true, "formal warning")
# Blocking also means physically standing between the person and the door
# (PLAN Level 3), not just sending the escalation level.
if level == Rules.Level.BLOCKING:
_station_between(controller, controller.profile.display_name if controller.profile else "them")
hud.set_escalation(level) hud.set_escalation(level)
if audio: if audio:
audio.play_escalation(level) audio.play_escalation(level)
_react_to_outcome(controller, outcome) _react_to_outcome(controller, outcome)
## Level 1 eye contact: a distinct, quieter cue than raise-hand (PLAN.md). It
## uses the same Level 1 reaction table but is logged as its own action.
func _eye_contact() -> void:
_apply_interaction(Rules.Level.SIMPLE_DETERRENCE, "eye contact")
## "I recognize this person" is the player's own decision, recorded as access
## evidence rather than pre-attached to every staff/guest type (PLAN.md).
func _recognize_target() -> void:
var controller: Object = _targeted_controller()
if controller == null:
hud.log(Strings.lookup("hud.aim_first"))
return
var name: String = controller.profile.display_name if controller.profile else "them"
if controller.player_recognized:
hud.log(Strings.fmt("recognition.already", [name]))
return
_ensure_incident(controller)
controller.player_recognized = true
coordinator.recorder.add_access_evidence(controller.npc_id, {
"kind": "recognition",
"source": "guard_decision",
"recognized": true,
})
coordinator.recorder.add_event(controller.npc_id, {
"type": "recognition_decision",
"recognized": true,
"source": "player",
})
hud.log(Strings.fmt("recognition.declared", [name]))
## Level 3 ask: request the person's reason for entry. The reply comes from the
## NPC's authored `dialogue_lines`; silence is a valid, telling answer.
func _request_reason() -> void:
var controller: Object = _targeted_controller()
if controller == null:
hud.log(Strings.lookup("hud.aim_first"))
return
var name: String = controller.profile.display_name if controller.profile else "They"
_ensure_incident(controller)
var reply: String = controller.request_reason()
coordinator.recorder.add_event(controller.npc_id, {
"type": "reason_requested",
"reply": reply,
})
hud.set_escalation(Rules.Level.BLOCKING)
hud.log(Strings.fmt("reason.ask", [name]))
if reply == "":
hud.log(Strings.fmt("reason.silent", [name]))
else:
hud.log(Strings.fmt("reason.reply", [name, reply]))
## Physically move the guard between the person and the door (PLAN Level 3).
func _station_between(controller: Object, name: String) -> void:
if guard == null or targeted_npc == null:
return
var npc_pos: Vector3 = (targeted_npc as Node3D).global_position
var door_pos: Vector3 = selected_scenario._location_or_default("entrance", Vector3(0, 0.5, 1.2))
var to_door := door_pos - npc_pos
to_door.y = 0.0
if to_door.length() < 0.05:
return
var station: Vector3 = npc_pos + to_door.normalized() * 0.9
station.y = guard.global_position.y
guard.global_position = station
var look_at_point := Vector3(npc_pos.x, guard.global_position.y, npc_pos.z)
if (look_at_point - guard.global_position).length() > 0.05:
guard.look_at(look_at_point, Vector3.UP)
hud.log(Strings.fmt("station.blocking", [name]))
func _react_to_outcome(controller: Object, outcome: Dictionary) -> void: func _react_to_outcome(controller: Object, outcome: Dictionary) -> void:
var reaction: int = outcome.get("reaction", -1) var reaction: int = outcome.get("reaction", -1)
var name: String = (controller.profile.display_name if controller.profile else "Person") var name: String = (controller.profile.display_name if controller.profile else "Person")
@@ -1079,7 +1248,19 @@ func _artifacts_for(controller: Object) -> Array:
var profile: NpcProfile = controller.profile as NpcProfile var profile: NpcProfile = controller.profile as NpcProfile
var override: Dictionary = controller.access_override var override: Dictionary = controller.access_override
var policy = selected_scenario.access_policy if selected_scenario else null var policy = selected_scenario.access_policy if selected_scenario else null
return AccessLoadout.build(profile, policy, override) var artifacts: Array = AccessLoadout.build(profile, policy, override)
# The guard's own recognition is evidence the player created, so it is
# appended here rather than baked into every staff/guest artifact set.
if controller.player_recognized and not _has_recognition_artifact(artifacts):
artifacts.push_front(AccessArtifact.new(
Rules.AccessKind.RECOGNITION, Rules.ArtifactStatus.VALID, {"known": true, "source": "player"}))
return artifacts
func _has_recognition_artifact(artifacts: Array) -> bool:
for artifact in artifacts:
if artifact is AccessArtifact and artifact.kind == Rules.AccessKind.RECOGNITION:
return true
return false
func _read_npc_truth(controller: Object) -> Dictionary: func _read_npc_truth(controller: Object) -> Dictionary:
var profile: Object = controller.profile var profile: Object = controller.profile
@@ -1096,6 +1277,17 @@ func _targeted_controller() -> Object:
return targeted_npc.get_npc_controller() return targeted_npc.get_npc_controller()
return null return null
## Guarantee an open incident for this NPC before recording evidence, so verbs
## work even if the player acted without a prior focus change.
func _ensure_incident(controller: Object) -> void:
if controller == null or coordinator == null:
return
if coordinator.recorder.has_open_incident(controller.npc_id):
return
coordinator.recorder.start_incident(controller.npc_id, "player_action")
current_incident_npc_id = controller.npc_id
current_incident_active = true
func _close_incident(outcome: String) -> void: func _close_incident(outcome: String) -> void:
if current_incident_active and not current_incident_npc_id.is_empty(): if current_incident_active and not current_incident_npc_id.is_empty():
coordinator.recorder.close_incident(current_incident_npc_id, outcome) coordinator.recorder.close_incident(current_incident_npc_id, outcome)
+104 -5
View File
@@ -17,6 +17,14 @@ var arrived := false
var idle_s := 0.0 var idle_s := 0.0
var lifetime_s := 90.0 var lifetime_s := 90.0
var ephemeral := true var ephemeral := true
## Crowd presentation (PLAN: Public Crowd Reaction). "watch" rubbernecks at the
## incident, "flee" clears away from it, "" is normal navigation.
var reaction_mode := ""
var reaction_point := Vector3.ZERO
var _reaction_timer := 0.0
const RUBBERNECK_S := 12.0
const FLEE_S := 20.0
const FLEE_SPEED := 2.4
var agent: NavigationAgent3D = null var agent: NavigationAgent3D = null
## Set once the nav agent proves it has a path; direct movement is the fallback. ## Set once the nav agent proves it has a path; direct movement is the fallback.
var _nav_usable := false var _nav_usable := false
@@ -225,10 +233,78 @@ func _add_box_prop(parent: Node3D, size: Vector3, pos: Vector3, color: Color) ->
mi.material_override = _material(color) mi.material_override = _material(color)
parent.add_child(mi) parent.add_child(mi)
## Rubberneck: idle people stop and turn toward the incident. Returns false when
## this NPC is too engaged (walking, being talked to, already leaving) to watch.
func start_rubberneck(at: Vector3) -> bool:
if not arrived or npc.leave_requested or leave_requested_by_lifetime:
return false
# Someone actually waiting at the entrance is being dealt with, not a bystander.
# Avatars live under the identity SceneRoot, so `position` matches world space
# and also works before the node enters the tree (tests).
if awaiting_interaction and (position - door_position).length() < 3.0:
return false
if reaction_mode == "flee":
return false
reaction_mode = "watch"
reaction_point = at
_reaction_timer = RUBBERNECK_S
velocity = Vector3.ZERO
return true
## Panic: clear away from the incident (usually the door) in a straight line.
func start_flee(from: Vector3) -> void:
if npc.leave_requested or leave_requested_by_lifetime:
return
reaction_mode = "flee"
reaction_point = from
_reaction_timer = FLEE_S
var away := global_position - from
away.y = 0.0
if away.length() < 0.5:
away = Vector3(0.0, 0.0, 1.0)
target_position = global_position + away.normalized() * 25.0
target_position.y = 0.5
arrived = false
awaiting_interaction = false
func reaction_is_active() -> bool:
return reaction_mode != ""
func _tick_reaction(delta: float) -> void:
if reaction_mode == "":
return
_reaction_timer -= delta
if reaction_mode == "flee":
if _reaction_timer <= 0.0 or (global_position - target_position).length() < 1.5:
reaction_mode = ""
queue_free()
return
if _reaction_timer <= 0.0:
reaction_mode = ""
## Turn the body toward the reaction point without moving.
func _face_reaction_point(delta: float) -> void:
var to_point := reaction_point - global_position
to_point.y = 0.0
if to_point.length() < 0.1:
return
var target_yaw := atan2(-to_point.x, -to_point.z)
rotation.y = lerp_angle(rotation.y, target_yaw, clampf(delta * 4.0, 0.0, 1.0))
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if npc == null or npc.fsm == null: if npc == null or npc.fsm == null:
return return
_advance_fsm(delta) _advance_fsm(delta)
_tick_reaction(delta)
if reaction_mode == "watch":
velocity = Vector3.ZERO
_face_reaction_point(delta)
_animate(delta)
return
if reaction_mode == "flee":
_move_toward_target(delta)
_animate(delta)
return
_move_toward_target(delta) _move_toward_target(delta)
_animate(delta) _animate(delta)
@@ -264,7 +340,7 @@ func _animate(delta: float) -> void:
func _advance_fsm(delta: float) -> void: func _advance_fsm(delta: float) -> void:
# Routine traffic despawns after a while once it has finished its walk, so # Routine traffic despawns after a while once it has finished its walk, so
# the crowd cap is not permanently occupied by idle standers. # the crowd cap is not permanently occupied by idle standers.
if ephemeral and arrived and npc.fsm.state != "LEAVING": if ephemeral and arrived and npc.fsm.current_state != "LEAVING":
idle_s += delta idle_s += delta
if idle_s >= lifetime_s: if idle_s >= lifetime_s:
leave_requested_by_lifetime = true leave_requested_by_lifetime = true
@@ -291,6 +367,10 @@ func _move_toward_target(delta: float) -> void:
if agent == null: if agent == null:
_move_direct(delta) _move_direct(delta)
return return
# Re-assigning the target every physics frame invalidates the path, so
# get_next_path_position() keeps returning the current position and the
# avatar never moves. Only update the agent when the target changes.
if agent.target_position != target_position:
agent.target_position = target_position agent.target_position = target_position
if agent.is_navigation_finished(): if agent.is_navigation_finished():
if (global_position - target_position).length() < 3.0: if (global_position - target_position).length() < 3.0:
@@ -308,14 +388,32 @@ func _move_toward_target(delta: float) -> void:
_move_direct(delta) _move_direct(delta)
return return
var next := agent.get_next_path_position() var next := agent.get_next_path_position()
# Godot reports the current position as the first path point (on the navmesh
# plane, so below the body) and only advances past it once the agent is within
# path_desired_distance. Steering at the point we are standing on gives a
# zero-length direction, and steering at any point merely "far enough" away can
# pick the old start behind us. Follow the first path point that is genuinely
# closer to the destination than we are.
var path := agent.get_current_navigation_path()
if path.size() >= 2:
var goal: Vector3 = path[path.size() - 1]
var here_to_goal := Vector2(goal.x - global_position.x, goal.z - global_position.z).length()
for i in range(1, path.size()):
var candidate: Vector3 = path[i]
candidate.y = global_position.y
var candidate_to_goal := Vector2(goal.x - candidate.x, goal.z - candidate.z).length()
if candidate_to_goal < here_to_goal - 0.05:
next = candidate
break
var dir := (next - global_position) var dir := (next - global_position)
dir.y = 0.0 dir.y = 0.0
if dir.length() < 0.2: if dir.length() < 0.2:
velocity = Vector3.ZERO velocity = Vector3.ZERO
return return
dir = dir.normalized() dir = dir.normalized()
velocity.x = dir.x * 1.3 var speed := FLEE_SPEED if reaction_mode == "flee" else 1.3
velocity.z = dir.z * 1.3 velocity.x = dir.x * speed
velocity.z = dir.z * speed
velocity.y -= 9.8 * delta velocity.y -= 9.8 * delta
look_at(global_position + Vector3(dir.x, 0, dir.z), Vector3.UP) look_at(global_position + Vector3(dir.x, 0, dir.z), Vector3.UP)
move_and_slide() move_and_slide()
@@ -329,8 +427,9 @@ func _move_direct(delta: float) -> void:
_arrive() _arrive()
return return
var dir := to_target.normalized() var dir := to_target.normalized()
velocity.x = dir.x * 1.3 var speed := FLEE_SPEED if reaction_mode == "flee" else 1.3
velocity.z = dir.z * 1.3 velocity.x = dir.x * speed
velocity.z = dir.z * speed
velocity.y -= 9.8 * delta velocity.y -= 9.8 * delta
look_at(global_position + Vector3(dir.x, 0, dir.z), Vector3.UP) look_at(global_position + Vector3(dir.x, 0, dir.z), Vector3.UP)
move_and_slide() move_and_slide()
+9 -3
View File
@@ -10,6 +10,7 @@ const Strings := preload("res://src/core/strings.gd")
const SLICE_DEFS := [ const SLICE_DEFS := [
{"id": "raise_hand", "label_key": "radial.raise_hand", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "raise hand"}, {"id": "raise_hand", "label_key": "radial.raise_hand", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "raise hand"},
{"id": "eye_contact", "label_key": "radial.eye_contact", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "eye contact"},
{"id": "point", "label_key": "radial.point", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "point"}, {"id": "point", "label_key": "radial.point", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "point"},
{"id": "head_shake", "label_key": "radial.head_shake", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "head shake"}, {"id": "head_shake", "label_key": "radial.head_shake", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "head shake"},
{"id": "polite", "label_key": "radial.polite", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "polite direction"}, {"id": "polite", "label_key": "radial.polite", "level": Rules.Level.SIMPLE_DETERRENCE, "action": "polite direction"},
@@ -17,6 +18,8 @@ const SLICE_DEFS := [
{"id": "wand", "label_key": "radial.wand", "level": -1, "action": "wand"}, {"id": "wand", "label_key": "radial.wand", "level": -1, "action": "wand"},
{"id": "warning", "label_key": "radial.warning", "level": Rules.Level.FORMAL_WARNING, "action": "formal warning"}, {"id": "warning", "label_key": "radial.warning", "level": Rules.Level.FORMAL_WARNING, "action": "formal warning"},
{"id": "block", "label_key": "radial.block", "level": Rules.Level.BLOCKING, "action": "blocking"}, {"id": "block", "label_key": "radial.block", "level": Rules.Level.BLOCKING, "action": "blocking"},
{"id": "reason", "label_key": "radial.reason", "level": Rules.Level.BLOCKING, "action": "request reason"},
{"id": "recognize", "label_key": "radial.recognize", "level": -1, "action": "recognize"},
{"id": "radio", "label_key": "radial.radio", "level": -1, "action": "radio assist"}, {"id": "radio", "label_key": "radial.radio", "level": -1, "action": "radio assist"},
] ]
@@ -146,8 +149,8 @@ func _on_wheel_draw() -> void:
return return
var center := _wheel.size * 0.5 var center := _wheel.size * 0.5
var n := SLICE_DEFS.size() var n := SLICE_DEFS.size()
var outer := 150.0 var outer := 174.0
var inner := 58.0 var inner := 64.0
for i in n: for i in n:
var a0 := -PI / 2.0 + TAU * float(i) / float(n) var a0 := -PI / 2.0 + TAU * float(i) / float(n)
var a1 := -PI / 2.0 + TAU * float(i + 1) / float(n) var a1 := -PI / 2.0 + TAU * float(i + 1) / float(n)
@@ -160,7 +163,10 @@ func _on_wheel_draw() -> void:
var mid := (a0 + a1) * 0.5 var mid := (a0 + a1) * 0.5
var label_pos := center + Vector2(cos(mid), sin(mid)) * ((inner + outer) * 0.5) var label_pos := center + Vector2(cos(mid), sin(mid)) * ((inner + outer) * 0.5)
var text := Strings.lookup(str(SLICE_DEFS[i]["label_key"])) var text := Strings.lookup(str(SLICE_DEFS[i]["label_key"]))
_wheel.draw_string(ThemeDB.fallback_font, label_pos + Vector2(-28, 4), text, HORIZONTAL_ALIGNMENT_LEFT, -1, 13, Color.WHITE) # With 12 slices the label box is tight: center it on the slice midpoint.
var font := ThemeDB.fallback_font
var text_size := font.get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, 12)
_wheel.draw_string(font, label_pos - Vector2(text_size.x * 0.5, -4), text, HORIZONTAL_ALIGNMENT_LEFT, -1, 12, Color.WHITE)
func _draw_slice(center: Vector2, inner: float, outer: float, a0: float, a1: float, color: Color) -> void: func _draw_slice(center: Vector2, inner: float, outer: float, a0: float, a1: float, color: Color) -> void:
var pts := PackedVector2Array() var pts := PackedVector2Array()
+24 -3
View File
@@ -47,6 +47,8 @@ var escalation_label: Label
var _debug_enabled := false var _debug_enabled := false
var _log_lines: Array[String] = [] var _log_lines: Array[String] = []
var _cam_overlay: Control = null
var _body_camera_on := false
func _init() -> void: func _init() -> void:
name = "HUD" name = "HUD"
@@ -138,11 +140,19 @@ func _init() -> void:
add_child(vignette_rect) add_child(vignette_rect)
# --- body-camera overlay (REC + shift clock + corner brackets, top right) --- # --- body-camera overlay (REC + shift clock + corner brackets, top right) ---
# Toggled by the body-camera flag (PLAN Level 2); off until the guard activates
# it or issues a formal warning.
_cam_overlay = Control.new()
_cam_overlay.name = "BodyCameraOverlay"
_cam_overlay.set_anchors_preset(Control.PRESET_FULL_RECT)
_cam_overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE
_cam_overlay.visible = false
add_child(_cam_overlay)
var cam_box := VBoxContainer.new() var cam_box := VBoxContainer.new()
cam_box.set_anchors_preset(Control.PRESET_TOP_RIGHT) cam_box.set_anchors_preset(Control.PRESET_TOP_RIGHT)
cam_box.position = Vector2(-180, 50) cam_box.position = Vector2(-180, 50)
cam_box.alignment = BoxContainer.ALIGNMENT_END cam_box.alignment = BoxContainer.ALIGNMENT_END
add_child(cam_box) _cam_overlay.add_child(cam_box)
var rec_row := HBoxContainer.new() var rec_row := HBoxContainer.new()
rec_row.alignment = BoxContainer.ALIGNMENT_END rec_row.alignment = BoxContainer.ALIGNMENT_END
cam_box.add_child(rec_row) cam_box.add_child(rec_row)
@@ -279,6 +289,16 @@ func set_wand_icon(visible: bool) -> void:
if wand_icon: if wand_icon:
wand_icon.visible = visible wand_icon.visible = visible
## Show or hide the body-camera overlay (REC + clock + brackets). The flag is a
## record of the interaction (PLAN Level 2), not a permanent HUD fixture.
func set_body_camera(on: bool) -> void:
_body_camera_on = on
if _cam_overlay:
_cam_overlay.visible = on
func is_body_camera_on() -> bool:
return _body_camera_on
## Scale the whole HUD text block (accessibility settings). ## Scale the whole HUD text block (accessibility settings).
func set_font_scale(scale: float) -> void: func set_font_scale(scale: float) -> void:
var clamped := clampf(scale, 0.75, 1.75) var clamped := clampf(scale, 0.75, 1.75)
@@ -308,6 +328,7 @@ func _add_corner_brackets(color: Color) -> void:
var corners := [ var corners := [
Vector2(OFF, OFF), Vector2(vp.x - OFF, OFF), Vector2(OFF, vp.y - OFF), Vector2(vp.x - OFF, vp.y - OFF), Vector2(OFF, OFF), Vector2(vp.x - OFF, OFF), Vector2(OFF, vp.y - OFF), Vector2(vp.x - OFF, vp.y - OFF),
] ]
var parent: Node = _cam_overlay if _cam_overlay != null else self
for i in 4: for i in 4:
var c: Vector2 = corners[i] var c: Vector2 = corners[i]
var flip_x: bool = (i % 2) == 1 var flip_x: bool = (i % 2) == 1
@@ -317,13 +338,13 @@ func _add_corner_brackets(color: Color) -> void:
h.size = Vector2(LEN, TH) h.size = Vector2(LEN, TH)
h.position = Vector2(c.x - (LEN if flip_x else 0.0), c.y - (TH if flip_y else 0.0)) h.position = Vector2(c.x - (LEN if flip_x else 0.0), c.y - (TH if flip_y else 0.0))
h.mouse_filter = Control.MOUSE_FILTER_IGNORE h.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(h) parent.add_child(h)
var v := ColorRect.new() var v := ColorRect.new()
v.color = color v.color = color
v.size = Vector2(TH, LEN) v.size = Vector2(TH, LEN)
v.position = Vector2(c.x - (TH if flip_x else 0.0), c.y - (LEN if flip_y else 0.0)) v.position = Vector2(c.x - (TH if flip_x else 0.0), c.y - (LEN if flip_y else 0.0))
v.mouse_filter = Control.MOUSE_FILTER_IGNORE v.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(v) parent.add_child(v)
func set_action_hint(text: String) -> void: func set_action_hint(text: String) -> void:
hint_label.text = text hint_label.text = text
+36 -14
View File
@@ -57,9 +57,11 @@ func _add_box(parent: Node3D, size: Vector3, pos: Vector3, color: Color, cast_sh
func _build_ground() -> void: func _build_ground() -> void:
var ground := StaticBody3D.new() var ground := StaticBody3D.new()
ground.name = "Ground" ground.name = "Ground"
_add_box(root, Vector3(160, 0.5, 160), Vector3(0, -0.25, 20), Color(0.22, 0.24, 0.26)) # Large enough that the ground meets the distant skyline ring (no gap of sky
# under the buildings when looking down the boulevard).
_add_box(root, Vector3(500, 0.5, 500), Vector3(0, -0.25, 20), Color(0.22, 0.24, 0.26))
var col := BoxShape3D.new() var col := BoxShape3D.new()
col.size = Vector3(160, 1, 160) col.size = Vector3(500, 1, 500)
var shape_owner := ground.create_shape_owner(ground) var shape_owner := ground.create_shape_owner(ground)
ground.shape_owner_add_shape(shape_owner, col) ground.shape_owner_add_shape(shape_owner, col)
root.add_child(ground) root.add_child(ground)
@@ -165,29 +167,49 @@ func _build_navmesh() -> void:
root.add_child(region) root.add_child(region)
func _build_skyline_backdrop() -> void: func _build_skyline_backdrop() -> void:
## Skyline silhouette backdrop behind the building. The texture has a ## Distant skyline surrounding the block. The texture's sky is transparent
## transparent sky, so only the building silhouettes show; the material must ## (alpha scissor), so only building silhouettes show. Four planes form a
## be set up for alpha or the plane renders as an opaque slab (ADR/TODO). ## ring: a single plane placed behind the building reads as a floating black
## band from the sidewalk.
var backdrop := Node3D.new() var backdrop := Node3D.new()
backdrop.name = "SkylineBackdrop" backdrop.name = "SkylineBackdrop"
var plane := MeshInstance3D.new()
var mesh := PlaneMesh.new()
mesh.size = Vector2(240, 60) # wide, low horizon
plane.mesh = mesh
var mat := StandardMaterial3D.new() var mat := StandardMaterial3D.new()
mat.albedo_texture = T_SKYLINE mat.albedo_texture = T_SKYLINE
mat.albedo_texture_repeat = true mat.texture_repeat = true
mat.uv1_scale = Vector3(2.0, 1.0, 1.0) mat.uv1_scale = Vector3(3.0, 1.0, 1.0)
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_SCISSOR mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_SCISSOR
mat.alpha_scissor_threshold = 0.3 mat.alpha_scissor_threshold = 0.5
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
mat.cull_mode = BaseMaterial3D.CULL_DISABLED mat.cull_mode = BaseMaterial3D.CULL_DISABLED
# Unshaded silhouettes read as pure black at 255-scale; lift the albedo so the
# distant skyline sits closer to a hazy daytime city.
mat.albedo_color = Color(2.6, 2.7, 3.0, 1.0)
_skyline_mat = mat
var mesh := PlaneMesh.new()
# PlaneMesh defaults to a horizontal (XZ) plane; the skyline must stand up.
mesh.orientation = PlaneMesh.FACE_Z
mesh.size = Vector2(400, 60)
# Far enough that the skyline reads as background and its top edge stays out
# of the middle of the sky.
const DIST := 200.0
# The texture keeps its buildings in the lower part of the image, so the plane
# center sits at half its height: the building bases meet the ground.
const CENTER_Y := 30.0
var placements := [
[Vector3(0, CENTER_Y, -DIST), 0.0],
[Vector3(0, CENTER_Y, DIST), 0.0],
[Vector3(-DIST, CENTER_Y, 0), PI / 2.0],
[Vector3(DIST, CENTER_Y, 0), PI / 2.0],
]
for placement in placements:
var plane := MeshInstance3D.new()
plane.mesh = mesh
plane.material_override = mat plane.material_override = mat
plane.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF plane.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
plane.position = Vector3(0, 18, -60) # behind and above the building plane.position = placement[0]
plane.rotation.y = placement[1]
backdrop.add_child(plane) backdrop.add_child(plane)
root.add_child(backdrop) root.add_child(backdrop)
_skyline_mat = mat
var _skyline_mat: StandardMaterial3D = null var _skyline_mat: StandardMaterial3D = null
+18 -10
View File
@@ -31,6 +31,10 @@ func _process(_delta: float) -> bool:
quit(1) quit(1)
return true return true
if gm != null and not camera_staged: if gm != null and not camera_staged:
# The game boots into the venue menu now; start the Hollywood shift first.
var menu = gm.get("start_menu")
if menu != null and menu.visible:
gm.call("_on_venue_selected", "hollywood_building")
gm.guard.global_position = Vector3(0, 0.1, 10.5) gm.guard.global_position = Vector3(0, 0.1, 10.5)
gm.guard.rotation.y = 0.0 gm.guard.rotation.y = 0.0
gm.guard.head.rotation.x = deg_to_rad(2.0) gm.guard.head.rotation.x = deg_to_rad(2.0)
@@ -52,7 +56,8 @@ func _advance() -> void:
state = 1 state = 1
state_frames = 0 state_frames = 0
1: 1:
# Wait for a nearby NPC so the interaction HUD has a target. # Wait for a nearby NPC so the interaction HUD has a target. NPCs now
# walk in from the street, so this can take a few simulated seconds.
if gm != null and gm.npcs.size() > 0: if gm != null and gm.npcs.size() > 0:
gm.call("_cycle_nearby_target") gm.call("_cycle_nearby_target")
_face_target() _face_target()
@@ -83,24 +88,27 @@ func _advance() -> void:
# Close the radio form, then jump the shift to the LATE phase. # Close the radio form, then jump the shift to the LATE phase.
if gm != null: if gm != null:
gm.radio_panel.hide() gm.radio_panel.hide()
gm.guard.rotation.y = 0.0 gm.hud.set_action_hint("")
gm.guard.head.rotation.x = deg_to_rad(2.0)
gm.coordinator.elapsed_s = 750.0 gm.coordinator.elapsed_s = 750.0
state = 5 state = 5
state_frames = 0 state_frames = 0
5: 5:
# Let the phase transition (and street lamps / marquee) settle, then # Stage the avenue view down the boulevard (not into the wall) and let
# take the night avenue shot. # the night lighting and street lamps settle.
if state_frames == 1 and gm != null:
gm.guard.rotation.y = deg_to_rad(-70)
gm.guard.head.rotation.x = deg_to_rad(3.0)
if state_frames >= 90: if state_frames >= 90:
gm.guard.rotation.y = 0.0
gm.guard.head.rotation.x = deg_to_rad(2.0)
_shoot("05-late-night-avenue.png") _shoot("05-late-night-avenue.png")
if gm != null:
gm.call("_toggle_flashlight")
state = 6 state = 6
state_frames = 0 state_frames = 0
6: 6:
if state_frames >= 40: # Face the entrance again and switch the flashlight on for the night set.
if state_frames == 1 and gm != null:
gm.guard.rotation.y = 0.0
gm.guard.head.rotation.x = deg_to_rad(4.0)
gm.call("_toggle_flashlight")
if state_frames >= 30:
_shoot("06-night-flashlight.png") _shoot("06-night-flashlight.png")
state = 7 state = 7
quit(0) quit(0)
+114
View File
@@ -0,0 +1,114 @@
extends SceneTree
## Crowd-presentation smoke: starts a shift, waits for bystanders to settle, then
## checks that an aggressive crowd event makes idle NPCs stop and watch, and that
## panic sends them away from the door.
##
## Usage:
## godot --headless --path . --script res://src/test/smoke_crowd.gd
## Exit code 0 = pass, 1 = failure.
const MAX_FRAMES := 2400
var frame := 0
var gm: Node = null
var started := false
var phase := 0
var failures: Array[String] = []
func _initialize() -> void:
root.size = Vector2i(1280, 720)
root.add_child(load("res://scenes/main.tscn").instantiate())
func _process(_delta: float) -> bool:
frame += 1
if gm == null:
gm = root.find_child("GameManager", true, false)
return false
if not started:
gm.call("_on_venue_selected", "hollywood_building")
started = true
return false
if frame > MAX_FRAMES:
_fail("timeout before crowd reactions were observed")
return true
match phase:
0:
if frame < 300:
return false
# Wait until at least one settled bystander is away from the door (someone
# waiting at the entrance is being dealt with and must not rubberneck).
if _bystander_count() == 0:
return false
gm.coordinator.crowd.apply_event("aggressive_behavior")
var watching := _count_mode("watch")
_check(watching > 0, "aggressive behavior makes idle NPCs watch (%d watching)" % watching)
phase = 1
1:
if frame < 320:
return false
var door: Vector3 = gm.selected_scenario._location_or_default("entrance", Vector3(0, 0.5, 1.2))
for npc in gm.npcs:
if is_instance_valid(npc) and npc.has_method("reaction_is_active"):
pass
gm.coordinator.crowd.apply_event("visible_weapon")
gm.coordinator.crowd.apply_event("aggressive_behavior")
gm.coordinator.crowd.apply_event("aggressive_behavior")
gm.coordinator.crowd.apply_event("emergency_responder")
_check(gm.coordinator.crowd.should_flee(), "stacked alarms panic the crowd")
var fleeing := _count_mode("flee")
_check(fleeing > 0, "panic sends NPCs away from the door (%d fleeing)" % fleeing)
var away_ok := true
for npc in gm.npcs:
if not is_instance_valid(npc) or npc.reaction_mode != "flee":
continue
if (npc.target_position - door).length() <= (npc.global_position - door).length():
away_ok = false
_check(away_ok, "every fleeing NPC targets a point farther from the door")
phase = 2
_:
_finish()
return true
return false
func _bystander_count() -> int:
var n := 0
for npc in gm.npcs:
if not is_instance_valid(npc) or not npc.arrived:
continue
if npc.awaiting_interaction and npc.global_position.distance_to(npc.door_position) < 3.0:
continue
n += 1
return n
func _settled_count() -> int:
var n := 0
for npc in gm.npcs:
if is_instance_valid(npc) and npc.arrived:
n += 1
return n
func _count_mode(mode: String) -> int:
var n := 0
for npc in gm.npcs:
if is_instance_valid(npc) and npc.reaction_mode == mode:
n += 1
return n
func _check(condition: bool, message: String) -> void:
if condition:
print("ok: " + message)
else:
_fail(message)
func _fail(message: String) -> void:
failures.append(message)
_finish()
func _finish() -> void:
if failures.is_empty():
print("SMOKE OK: crowd rubberneck and panic flee")
quit(0)
else:
for message in failures:
printerr("SMOKE FAIL: " + message)
quit(1)
+84
View File
@@ -0,0 +1,84 @@
extends SceneTree
## PLAN-verb smoke: starts a shift, focuses one person, then exercises the verbs
## added after the radial pass — recognize, request reason, body camera, formal
## warning (which must arm the body camera), and blocking (which must move the
## guard between the person and the door). Also checks that an incident is
## actually recorded, then closing it at shift end.
##
## Usage:
## godot --headless --path . --script res://src/test/smoke_plan_verbs.gd
## Exit code 0 = pass, 1 = failure.
const MAX_FRAMES := 1200
var frame := 0
var gm: Node = null
var started := false
var step := 0
var failures: Array[String] = []
func _initialize() -> void:
root.size = Vector2i(1280, 720)
root.add_child(load("res://scenes/main.tscn").instantiate())
func _process(_delta: float) -> bool:
frame += 1
if gm == null:
gm = root.find_child("GameManager", true, false)
return false
if not started:
gm.call("_on_venue_selected", "hollywood_building")
started = true
return false
if frame > MAX_FRAMES:
_fail("timeout before the verbs ran")
return true
if frame < 200:
return false
if step == 0:
if gm.npcs.is_empty():
_fail("no NPCs spawned to test the verbs on")
return true
var npc: Node = gm.npcs[0]
gm.call("_on_guard_target", npc)
var controller: Object = npc.get_npc_controller()
gm.call("_recognize_target")
_check(controller.player_recognized, "recognize marks the person as recognized")
gm.call("_request_reason")
_check(typeof(controller.last_reason_reply) == TYPE_STRING, "reason request returns a reply")
gm.call("_set_body_camera", false, "smoke")
_check(not gm.body_camera_on, "body camera can be switched off")
gm.call("_apply_interaction", 2, "formal warning")
_check(gm.body_camera_on, "formal warning arms the body camera")
var before: Vector3 = gm.guard.global_position
gm.call("_apply_interaction", 3, "blocking")
_check(before.distance_to(gm.guard.global_position) > 0.05, "blocking moves the guard")
_check(gm.coordinator.recorder.open_incidents_count() > 0 or gm.coordinator.recorder.incidents.size() > 0,
"an incident was recorded")
gm.coordinator.call("_finish_shift")
_check(gm.coordinator.recorder.open_incidents_count() == 0, "open incidents close at shift end")
_check(gm.coordinator.recorder.incidents.size() > 0, "shift history keeps the incident")
step = 1
if step == 1:
_finish()
return true
return false
func _check(condition: bool, message: String) -> void:
if condition:
print("ok: " + message)
else:
_fail(message)
func _fail(message: String) -> void:
failures.append(message)
_finish()
func _finish() -> void:
if failures.is_empty():
print("SMOKE OK: PLAN verbs (recognize, reason, body camera, warning, blocking)")
quit(0)
else:
for message in failures:
printerr("SMOKE FAIL: " + message)
quit(1)
+106
View File
@@ -0,0 +1,106 @@
extends RefCounted
## Crowd presentation: rubbernecking on aggressive/emergency events and clearing
## out when the crowd panics (PLAN: Public Crowd Reaction).
const CrowdSystem := preload("res://src/core/crowd_system.gd")
const NpcAvatar := preload("res://src/game/npc_avatar.gd")
const NpcProfile := preload("res://src/core/npc_profile.gd")
const Rules := preload("res://src/core/rules.gd")
func _profile() -> NpcProfile:
var p := NpcProfile.new()
p.id = "bystander"
p.display_name = "Bystander"
p.npc_type = Rules.NpcType.TOURIST
return p
func _avatar() -> Node:
var avatar: Node = NpcAvatar.new()
avatar.setup(_profile(), "photo", 99, Vector3(4, 0.5, 8), Vector3(2, 0.5, 12))
return avatar
func test_reaction_for_event() -> bool:
var a := TestUtils.check_eq(CrowdSystem.reaction_for_event("aggressive_behavior"), "watch", "aggression draws watchers")
var b := TestUtils.check_eq(CrowdSystem.reaction_for_event("emergency_responder"), "watch", "responder draws watchers")
var c := TestUtils.check_eq(CrowdSystem.reaction_for_event("visible_weapon"), "watch", "a weapon draws watchers")
var d := TestUtils.check_eq(CrowdSystem.reaction_for_event("de_escalation"), "", "de-escalation is not a watch cue")
var e := TestUtils.check_eq(CrowdSystem.reaction_for_event("calm_professionalism"), "", "calm is not a watch cue")
return a and b and c and d and e
func test_panic_flag_and_flee_cue() -> bool:
var crowd := CrowdSystem.new()
var a := TestUtils.check(not crowd.should_flee(), "crowd starts calm")
crowd.apply_event("visible_weapon")
crowd.apply_event("aggressive_behavior")
crowd.apply_event("aggressive_behavior")
crowd.apply_event("emergency_responder")
var b := TestUtils.check(crowd.should_flee(), "stacked alarms reach panic")
var c := TestUtils.check_eq(crowd.summary().get("panic"), true, "summary reports panic")
var calm := CrowdSystem.new()
calm.apply_event("de_escalation")
calm.apply_event("calm_professionalism")
var d := TestUtils.check(not calm.should_flee(), "a calm crowd does not flee")
crowd = null
calm = null
return a and b and c and d
func test_idle_bystander_rubbernecks() -> bool:
var avatar := _avatar()
# Still walking: should refuse so traffic is not frozen mid-approach.
var walking := TestUtils.check(not avatar.start_rubberneck(Vector3(0, 1, 1)), "walkers keep walking")
avatar.arrived = true
var accepted := TestUtils.check(avatar.start_rubberneck(Vector3(0, 1, 1)), "idle bystander watches")
var mode := TestUtils.check_eq(avatar.reaction_mode, "watch", "watch mode is set")
var active := TestUtils.check(avatar.reaction_is_active(), "reaction is active")
avatar.free()
return walking and accepted and mode and active
func test_engaged_person_does_not_rubberneck() -> bool:
var avatar := _avatar()
avatar.arrived = true
avatar.awaiting_interaction = true
# Not in a tree, so use local position (global_position is a no-op here).
avatar.position = avatar.door_position
var ok := TestUtils.check(not avatar.start_rubberneck(Vector3.ZERO), "someone waiting at the door does not rubberneck")
# The same person further away is an ordinary bystander and does watch.
avatar.position = avatar.door_position + Vector3(8, 0, 0)
var far_ok := TestUtils.check(avatar.start_rubberneck(Vector3.ZERO), "a bystander away from the door still watches")
avatar.free()
return ok and far_ok
func test_panic_moves_people_away_from_the_door() -> bool:
var avatar := _avatar()
avatar.position = Vector3(1, 0.5, 2)
var door := Vector3(0, 0.5, 1.2)
avatar.start_flee(door)
var a := TestUtils.check_eq(avatar.reaction_mode, "flee", "flee mode is set")
var b := TestUtils.check((avatar.target_position - door).length() > (avatar.position - door).length(),
"flee target is farther from the door than the start")
var c := TestUtils.check(not avatar.awaiting_interaction, "fleeing cancels waiting at the entrance")
avatar.free()
return a and b and c
func test_crowd_updates_arrive_through_the_event_bus() -> bool:
## CrowdSystem.apply_event() emits EventBus.crowd_changed, not its own
## `changed` signal; wiring the wrong one silently disables crowd reactions.
var src := FileAccess.get_file_as_string("res://src/game/game_manager.gd")
var ok := TestUtils.check(src.contains("event_bus.crowd_changed.connect(_on_crowd_changed)"),
"GameManager listens on EventBus.crowd_changed")
var bus: Object = load("res://src/core/event_bus.gd").new()
var seen: Array = []
bus.crowd_changed.connect(func(payload): seen.append(payload.get("event", "")))
var crowd := CrowdSystem.new()
crowd.set_event_bus(bus)
crowd.apply_event("aggressive_behavior")
var delivers := TestUtils.check_eq(seen, ["aggressive_behavior"], "apply_event reaches the bus listener")
bus = null
crowd = null
return ok and delivers
func test_leaving_npc_does_not_flee() -> bool:
var avatar := _avatar()
avatar.npc.leave_requested = true
avatar.start_flee(Vector3.ZERO)
var ok := TestUtils.check_eq(avatar.reaction_mode, "", "someone already leaving is left alone")
avatar.free()
return ok
+9 -1
View File
@@ -32,7 +32,9 @@ func test_radial_wrap_and_skip_wand() -> bool:
var a := TestUtils.check(menu.selected != start, "step wrap moves selection") var a := TestUtils.check(menu.selected != start, "step wrap moves selection")
var b := TestUtils.check(menu.is_slice_enabled(menu.selected), "landed on an enabled slice") var b := TestUtils.check(menu.is_slice_enabled(menu.selected), "landed on an enabled slice")
# Walk forward until we would hit wand; it must skip. # Walk forward until we would hit wand; it must skip.
menu.selected = 4 var wand_index := _slice_index("wand")
var warning_index := _slice_index("warning")
menu.selected = wand_index - 1
menu.step(1) menu.step(1)
var c := TestUtils.check_eq(menu.slice_id(menu.selected), "warning", "wand skipped when venue has none") var c := TestUtils.check_eq(menu.slice_id(menu.selected), "warning", "wand skipped when venue has none")
menu.free() menu.free()
@@ -91,6 +93,12 @@ func test_cancel_has_right_mouse() -> bool:
found = true found = true
return TestUtils.check(found, "cancel action includes right mouse button") return TestUtils.check(found, "cancel action includes right mouse button")
func _slice_index(id: String) -> int:
for i in ActionRadial.SLICE_DEFS.size():
if str(ActionRadial.SLICE_DEFS[i]["id"]) == id:
return i
return -1
func _action_has_key(action: String, keycode: Key) -> bool: func _action_has_key(action: String, keycode: Key) -> bool:
if not InputMap.has_action(action): if not InputMap.has_action(action):
return false return false
+132
View File
@@ -0,0 +1,132 @@
extends RefCounted
## PLAN verbs added after the radial pass: eye contact, recognition as a player
## decision, the body-camera flag, blocking station, and requesting a reason.
const Rules := preload("res://src/core/rules.gd")
const ActionRadial := preload("res://src/game/ui/action_radial.gd")
const IncidentRecorder := preload("res://src/core/incident_recorder.gd")
const NPCController := preload("res://src/core/npc_controller.gd")
const NpcProfile := preload("res://src/core/npc_profile.gd")
const AccessLoadout := preload("res://src/core/access_loadout.gd")
const AccessArtifact := preload("res://src/core/access_artifact.gd")
func _slice_index(id: String) -> int:
for i in ActionRadial.SLICE_DEFS.size():
if str(ActionRadial.SLICE_DEFS[i]["id"]) == id:
return i
return -1
func test_radial_has_new_verbs() -> bool:
var a := TestUtils.check(_slice_index("eye_contact") >= 0, "eye contact slice exists")
var b := TestUtils.check(_slice_index("reason") >= 0, "request-reason slice exists")
var c := TestUtils.check(_slice_index("recognize") >= 0, "recognize slice exists")
return a and b and c
func test_eye_contact_is_level_one() -> bool:
var def: Dictionary = ActionRadial.SLICE_DEFS[_slice_index("eye_contact")]
var ok := TestUtils.check_eq(int(def.get("level", -1)), Rules.Level.SIMPLE_DETERRENCE,
"eye contact is a Level 1 action")
var action_ok := TestUtils.check_eq(str(def.get("action", "")), "eye contact", "logs as eye contact")
return ok and action_ok
func test_every_slice_has_a_string_key() -> bool:
var strings = load("res://src/core/strings.gd")
var ok := true
for def in ActionRadial.SLICE_DEFS:
var key: String = str(def.get("label_key", ""))
if key == "":
ok = false
continue
if strings.lookup(key) == key:
ok = false
return TestUtils.check(ok, "every radial slice resolves a localized label")
func _profile(name: String, lines: Array[String] = []) -> NpcProfile:
var p := NpcProfile.new()
p.id = "test"
p.display_name = name
p.dialogue_lines = lines
return p
func test_request_reason_uses_dialogue_lines() -> bool:
var p := _profile("Visitor", ["I have a ticket for tonight.", "I am meeting a friend."])
var npc := NPCController.new()
npc.setup("npc_1", p, "enter", 4242)
var a := TestUtils.check_eq(npc.request_reason(), npc.last_reason_reply, "reply is stored")
var b := TestUtils.check_eq(npc.last_reason_reply, p.dialogue_lines[0], "seeded pick is deterministic")
var c := TestUtils.check(not npc.last_reason_reply.is_empty(), "reply is non-empty")
npc = null
return a and b and c
func test_request_reason_silent_without_lines() -> bool:
var npc := NPCController.new()
npc.setup("npc_2", _profile("Silent"), "enter", 7)
var reply: String = npc.request_reason()
var ok := TestUtils.check_eq(reply, "", "no dialogue lines means silence")
npc = null
return ok
func test_player_recognition_is_not_default() -> bool:
var p := _profile("Staffer")
p.npc_type = Rules.NpcType.AUTHORIZED_GUEST
var npc := NPCController.new()
npc.setup("npc_3", p, "enter", 11)
var a := TestUtils.check(not npc.player_recognized, "guests are not pre-recognized")
var override := {}
var artifacts := AccessLoadout.build(p, null, override)
var has_recognition := false
for artifact in artifacts:
if artifact is AccessArtifact and artifact.kind == Rules.AccessKind.RECOGNITION:
has_recognition = true
var b := TestUtils.check(not has_recognition, "guest artifact set has no recognition")
npc = null
return a and b
func test_recorder_starts_and_closes_incidents() -> bool:
var recorder := IncidentRecorder.new()
var a := TestUtils.check(not recorder.has_open_incident("npc_a"), "no incident before start")
recorder.start_incident("npc_a", "player_focus")
var b := TestUtils.check(recorder.has_open_incident("npc_a"), "incident opens")
recorder.add_event("npc_a", {"type": "recognition_decision", "recognized": true})
var c := TestUtils.check_eq(recorder.incidents.size(), 0, "open incident is not yet in history")
var closed: int = recorder.close_all_open("unresolved")
var d := TestUtils.check_eq(closed, 1, "close_all_open closes the open incident")
var e := TestUtils.check_eq(recorder.incidents.size(), 1, "closed incident lands in history")
var events: Array = recorder.incidents[0].get("events", [])
var f := TestUtils.check_eq(events.size(), 1, "recorded event survived the close")
recorder = null
return a and b and c and d and e and f
func test_shift_end_closes_open_incidents_into_review() -> bool:
var Coordinator := load("res://src/core/shift_coordinator.gd")
var Factory := load("res://src/content/scenario_factory.gd")
var coordinator = Coordinator.new()
coordinator.setup(Factory.hollywood_building(), 60.0, 99)
coordinator.start()
coordinator.recorder.start_incident("npc_x", "player_action")
coordinator.recorder.add_event("npc_x", {"type": "reason_requested", "reply": ""})
coordinator.call("_finish_shift")
var review: Dictionary = coordinator.build_review()
var incidents: Dictionary = review.get("incidents", {})
var list: Array = incidents.get("incidents", [])
var a := TestUtils.check_eq(list.size(), 1, "unresolved incident appears in the review")
var b := TestUtils.check_eq(str(list[0].get("outcome", "")), "unresolved", "outcome is unresolved")
var open := TestUtils.check_eq(int(incidents.get("open_count", -1)), 0, "nothing left open")
coordinator = null
return a and b and open
func test_body_camera_not_on_by_default() -> bool:
var src := FileAccess.get_file_as_string("res://src/game/game_manager.gd")
var a := TestUtils.check(src.contains("func _set_body_camera"), "body camera has a setter")
var b := TestUtils.check(src.contains("KEY_B"), "B toggles the body camera")
var c := TestUtils.check(
src.contains("level == Rules.Level.FORMAL_WARNING and not body_camera_on"),
"a formal warning turns the body camera on")
return a and b and c
func test_blocking_stations_the_guard() -> bool:
var src := FileAccess.get_file_as_string("res://src/game/game_manager.gd")
var a := TestUtils.check(src.contains("func _station_between"), "blocking has a stationing step")
var b := TestUtils.check(src.contains("_station_between(controller"), "blocking calls it")
var c := TestUtils.check(src.contains("to_door.normalized() * 0.9"), "station point is between NPC and door")
return a and b and c
+1 -1
View File
@@ -221,7 +221,7 @@ def skyline():
x = -40 x = -40
while x < w + 40: while x < w + 40:
bw = rnd.randint(64, 170) bw = rnd.randint(64, 170)
bh = rnd.randint(150, 400) bh = rnd.randint(90, 165)
d.rectangle([x, h - bh, x + bw, h], fill=build_color) d.rectangle([x, h - bh, x + bw, h], fill=build_color)
# few lit windows # few lit windows
for _ in range(bw * bh // 900): for _ in range(bw * bh // 900):