# Architecture This document follows the structure of the arc42 architecture documentation template. ## 1. Introduction and Goals ### Functional goals - Simulate believable security work at multiple public-facing venues. - Provide clear, low-pressure deterrence options before verbal or physical escalation. - Make access verification a meaningful gameplay decision. - Support distinct NPC behaviors and scenario events. - Make emergency response rare, consequential, and justified by observable danger. - Provide shift-level feedback so players can learn from decisions. ### Quality goals - **Clarity:** Players should understand why an NPC is allowed, denied, or escalated. - **Extensibility:** New venues should reuse shared systems and primarily provide configuration and content. - **Testability:** Rules and outcomes should be testable without rendering or real-time input. - **Consistency:** Similar situations should follow predictable venue and escalation rules. - **Respectful representation:** Mental-health crises and public interactions should not be reduced to stereotypes or treated as automatic threats. ## 2. Constraints - The first implementation should be small enough for a playable vertical slice. - The engine is Godot 4 with GDScript; a playable prototype vertical slice is implemented. - Venue-specific policies must be configurable rather than hard-coded into individual NPCs. - The game must preserve the de-escalation-first design described in [`PLAN.md`](../PLAN.md). - The project uses the repository workflow described in [`AGENTS.md`](../AGENTS.md). ## 3. Context and Scope The player interacts with NPCs, venue entrances, access artifacts, equipment, staff, and response services. The game itself owns the simulated world, rules, scoring, events, and shift review. External services are currently out of scope; radio, body camera, and emergency response are simulated systems. ## 4. Solution Strategy - Use a shared simulation core with venue-specific scenario data. - Represent NPC behavior using state machines or behavior trees with configurable traits. - Model escalation as explicit, auditable state transitions. - Separate access verification from NPC identity and presentation details. - Keep scoring and reputation event-driven so every action can be reviewed. - Use authored scenario events alongside procedural routine traffic. - Make the first playable target one venue and one complete shift before adding breadth. ## 5. Building Block View ### Level 1: Major components - **Presentation layer:** Camera, UI, prompts, interaction feedback, queues, and shift review. - **Input and interaction layer:** Player gestures, dialogue choices, access checks, equipment use, and radio controls. - **Simulation layer:** NPC movement, perception, intent, navigation, crowd behavior, and venue state. - **Rules layer:** Access policy, escalation policy, prohibited items, response thresholds, and venue configuration. - **Incident layer:** Incident lifecycle, evidence, radio reports, consequences, reputation, and review. - **Content layer:** Venue definitions, NPC profiles, dialogue, events, visual/audio assets, and shift schedules. ### Level 2: Key components - `ShiftCoordinator` starts, advances, and ends a shift. - `VenueScenario` provides venue rules, locations, event pools, and access policies. - `NPCController` manages an NPC’s intent, movement, compliance, and reaction. - `InteractionSystem` resolves gestures, dialogue, warnings, and physical positioning. - `AccessVerifier` evaluates recognition, wristbands, IDs, tickets, credentials, and guest lists. - `EscalationManager` tracks the current response level and available actions. - `RadioSystem` receives reports and schedules security or emergency responses. - `IncidentRecorder` stores actions, observations, evidence, and outcomes. - `ReputationEvaluator` converts incidents and shift outcomes into performance feedback. - `CrowdSystem` models queues, attention, congestion, and public reaction. - `ShiftReview` presents decisions, consequences, and improvement opportunities. ## 6. Runtime View ### Routine interaction 1. An NPC selects or receives an intent such as taking a photo, entering, waiting, or trespassing. 2. The player observes the NPC and chooses whether to intervene. 3. A gesture or verbal interaction changes the NPC’s state. 4. The NPC complies, negotiates, refuses, or escalates. 5. The rules layer validates access and determines available next actions. 6. The incident recorder stores the interaction. 7. Reputation and crowd systems react to the outcome. ### Access check 1. The player stops or receives an approaching person. 2. The player recognizes the person or inspects a wristband, ID, credential, ticket, or guest-list record. 3. The access verifier checks the artifact against the venue policy. 4. The player admits, redirects, holds, or refuses entry. 5. The decision is recorded for shift review. ### Emergency response 1. NPC behavior crosses the configured immediate-threat threshold. 2. The player holds and confirms the emergency-radio action. 3. The player submits a concise report describing location and behavior. 4. The response system dispatches an appropriate responder. 5. Crowd, venue, reputation, and incident systems apply consequences. 6. The shift review evaluates whether the call was justified. ## 7. Deployment View The initial target is a single-player local game. The expected runtime consists of one client process containing presentation, simulation, rules, content, and persistence for local settings and shift results. No online backend is required for the first prototype. Future options include external analytics, cloud saves, or replay sharing, but they are not part of the initial architecture. ## 8. Cross-Cutting Concepts - **Event-based incident recording:** Important actions emit records consumed by evidence, reputation, and review systems. - **Data-driven venue rules:** Access, escalation, equipment, and event differences live in scenario data. - **State transitions:** NPCs, incidents, and shifts expose explicit states for debugging and testing. - **Accessibility:** Input alternatives should exist for gestures, dialogue, visual alerts, and audio cues. - **Safety and proportionality:** The rules layer prevents ordinary noncompliance from automatically becoming a violent encounter. - **Determinism where useful:** Scenario tests should be able to use fixed seeds and scripted NPC behavior. - **Localization:** Dialogue and prompts should be externalized from logic. - **Observability:** Debug overlays should show NPC intent, access status, escalation level, active incidents, and response timers during development. ## 9. Architecture Decisions Architecture decisions are recorded as ADRs: - [ADR-0001: Venue-driven simulation architecture](adr/0001-venue-driven-simulation-architecture.md) - [ADR-0002: De-escalation-first escalation model](adr/0002-de-escalation-first-escalation-model.md) - [ADR-0003: Explicit access-verification system](adr/0003-explicit-access-verification-system.md) - [ADR-0004: Local single-player first](adr/0004-local-single-player-first.md) - [ADR-0005: Event-based incident recording](adr/0005-event-based-incident-recording.md) - [ADR-0006: Godot 4 with GDScript](adr/0006-godot-4-gdscript.md) ## 10. Quality Requirements | Requirement | Target | | --- | --- | | Player comprehension | Players can identify the reason for an access or escalation decision through UI and feedback. | | Response proportionality | Routine NPC behavior should be resolvable without emergency response. | | Extensibility | A new venue can be added primarily through scenario data and content. | | Performance | The target venue should support a believable crowd without harming input or simulation responsiveness. | | Testability | Access and escalation rules can be tested independently of presentation. | | Accessibility | Core actions are available through clear input alternatives and readable feedback. | ## 11. Risks and Technical Debt - NPC behavior may feel artificial if traits and reactions are too deterministic. - Crowd simulation may become expensive around busy studio or comedy-club entrances. - Access verification can become frustrating if the UI does not clearly show what the player is checking. - Emergency response can overshadow the core game if it is too powerful or too frequent. - Mental-health-crisis scenarios require careful writing, playtesting, and respectful presentation. - The choice of engine may affect navigation, crowd scale, tooling, and content authoring. ## 12. Glossary - **Access artifact:** A wristband, ID, ticket, credential, or other item used to verify entry. - **Authorized person:** Someone permitted to enter under the current venue policy. - **Door person:** The entrance security worker in The Joke Shop scenario. - **Incident:** A recorded interaction or event requiring player judgment. - **NPC:** Non-player character. - **Scenario:** A venue-specific configuration of rules, content, locations, and events. - **Shift:** One playable work period, normally 10–15 minutes. - **Simple deterrence:** A low-pressure gesture such as raising a hand, making eye contact, or pointing.