Table of Contents

Architecture

How SimLift's code is organised and how a training session runs through it. This is a condensed version of Docs/ProjectSpec.md (sections 2 and 3), which has the full design notes and the reasons behind them.

Three layers

The scripts in Assets/Scripts/ are split into three assemblies. Dependencies only point one way: Game -> Data -> Core, and Game also uses Core directly.

Layer Assembly / folder What it holds May use
Core Core - Assets/Scripts/Core/ All rules and state: sessions, phases, scoring, safety tasks, tutorial steps, equipment validation, guidance rules, application states, scene-loading policy. Plain C#. UnityEngine value types (Vector3, Quaternion, Mathf) and the Input System, but no MonoBehaviour, GameObject or other engine objects.
Data Data - Assets/Scripts/Data/ ScriptableObjects that describe content (scenarios, cargo, equipment, checks, badges, NPC profiles, audio cues) with converters to Core models (ToCoreModel(), BuildSessionConfig()), plus the settings and badge-progress storage services. Core.
Game Game - Assets/Scripts/Game/ MonoBehaviours: the bootstrapper, UI panels, player, crane input, triggers, guidance, NPCs, rigging, audio. They report Unity events to Core and show Core's state. Core, Data, Input System, TextMeshPro, Addressables, the third-party crane scripts.

Why it is split this way:

  • Testable rules. Everything that decides a score, a phase change or a pass/fail lives in Core, behind interfaces, so it runs in EditMode tests without a scene (Assets/Scripts/Tests/EditMode/, about 300 tests).
  • Content without code. A level, a check or a piece of equipment is a data asset; the Core never knows where it came from. See Create your own level.
  • The Game layer stays thin. A trigger says "the load hit something" or "the player answered N"; Core decides what that is worth.

Two rules follow from the layering:

  • All input goes through IInputService (InputContextService), never UnityEngine.Input or a raw InputAction.
  • Level scenes are separate Addressables bundles carrying their own copies of the ScriptableObjects they reference, so never compare ScriptableObjects across that boundary by reference: compare by id (SafetyCheckSO.SameCheck).

Start-up and services

The player is two scenes that are always loaded, Persistent and PersistentUI (the only scenes in Build Settings). The level scenes stream in and out on top of them.

Bootstrapper (in Persistent) is the composition root. It loads PersistentUI, then builds every service by hand - there is no DI framework:

Service (interface) Implementation Layer
ISceneLoaderService SceneLoaderService with AddressableSceneLoader as its IStreamedSceneLoader Core / Game
ISettingsService WebSettingsService (WebGL) or PCSettingsService Data
IAuthenticationService MockAuthenticationService (shipped) or WebAuthenticationService Core
IBadgeProgressService LocalBadgeProgressService Data
IApplicationStateService ApplicationStateService Core
IInputService InputContextService Core
IAudioService UnityAudioService Game

The per-session services - ScoringService, EquipmentValidator, SafetyTaskService, TimerService, TutorialService - go into a GameStateServiceFactory, which ApplicationStateService uses to create a fresh GameStateService for every session.

MonoBehaviours reach the services through small provider components (each with a static Instance) instead of finding or constructing services themselves: ApplicationStateServiceProvider (the current application state, the active session and the current scenario; it also ticks the application service every frame), InputServiceProvider and AudioServiceProvider.

Application flow

ApplicationStateService is a state machine over ApplicationState: Splash -> Login (skipped with the mock login) -> MainMenu -> BadgeHub -> LevelSelect -> Loading -> InTrainingSession -> Results, with Settings and Paused as overlays. ApplicationUIController in PersistentUI shows the panel for each state.

Starting a level:

  1. Level Select lists the scenarios of the opened badge's ScenarioDatabaseSO. Selecting a card prefetches the level's bundles in the background (PrefetchLevelAsync).
  2. Start calls ApplicationStateServiceProvider.StartTrainingSessionAsync(scenario): it remembers the scenario, turns it into a Core TrainingSessionConfig (TrainingScenarioSO.BuildSessionConfig()) and hands that to ApplicationStateService.StartTrainingSessionAsync.
  3. ApplicationStateService switches to Loading, streams the scene in by its address (the scenario's scene name), creates a GameStateService and starts the session, then switches to InTrainingSession.
  4. In the level scene, TrainingSessionController picks up the active session and the scenario, shows the panel for each phase and skips Preparation when the level has none.
  5. When the session completes, ApplicationStateService stores the results, decides progression (EvaluateProgression: success with grade A- or better marks the scenario completed and advances its badge) and shows Results. Retry reloads the scene; leaving unloads everything but the persistent scenes.

Inside a session

A GameStateService owns one TrainingSessionState and moves it through the GamePhases:

Phase What the player does Main pieces
Preparation (only with an equipment pool) Estimates the load's weight, inspects and picks a hook, sling and shackle. PreparationPanel, EquipmentPoolService, EquipmentValidator with the scenario's validation rules.
Site Inspection Walks the bay, answers Y/N inspection checks, rings the buzzer, asks workers to move, uses H guidance. PlayerInteractionController + Interactables, SafetyCheckPoint, SafetyTaskService, GuidanceLayer, TutorialObjectiveController.
Crane Operation Drives the crane, picks up the load, carries it along the route and sets it down, against the clock. NL_AttachCargo, ObjectiveRoute, SessionEndConditionsController, LoadCollisionDetector, RiggingAssembly.

Game components report what happened through IGameStateService - RecordSafetyTaskCompleted, RecordSafetyCheckFailed, NotifyCollisionDetected, NotifyEquipmentFailed, NotifyDestinationReached, ApplyPenalty - and Core turns each report into state, a scoring event and, if it ends the run, a CompletionStatus. Core raises OnPhaseChanged, OnScoreChanged, OnTimeUpdated and OnSessionCompleted, which the HUD and the application service listen to.

Systems at a glance

Each line points to the section of Docs/ProjectSpec.md with the details.

  • End conditions (3.2). SessionEndConditionsController turns route completion, load collisions, missed safety tasks (the forklift drives in if the buzzer was not rung), timer expiry and rigging failure into session results.
  • Tutorial (3.3). TutorialService (Core) sequences the steps of a TutorialSequenceSO; TutorialObjectiveController runs it in the scene, and TutorialGuideUI / the checklist show it. Informational steps advance with Enter. Steps can be tied to an inspection check or to the guidance key.
  • Safety tasks and inspection checks (3.4). Inline SafetyTaskDefinitions (the buzzer) and SafetyCheckSO checks, both listed on the scenario; each check has a SafetyCheckPoint on its item in the scene.
  • Input (3.5). InputContextService switches action maps with the application state: Player (walking), Operation (crane), UI, and Global (pause), which stays on. The objective bar, text size setting and UI fonts are described in the same section.
  • Interaction (3.6). PlayerInteractionController ranks nearby Interactables by aim (Core.Interaction.FocusScoring), Tab cycles between them, InteractionPromptUI shows the prompt. The guidance layer (H) highlights HintTargets and points at off-screen ones (GuidanceRules, GuidanceScreenMath); workers are asked to move with TalkToWorkerAction.
  • Load attachment (3.7). NL_AttachCargo on the hook joins the load with a joint at the contact point.
  • Route (3.8). ObjectiveRoute advances through ObjectiveWaypoints (LoadLifted, then LoadInZone); the drop-off only counts once the load is released.
  • Movement and penalties (3.9). The player follows the crane on a leash in Crane Operation. Obstacles are one layer (Obstacle) for both the load and the player. Carrying the load over a worker (WorkerOverheadTrigger) or walking through the crane area (CraneAreaPenaltyTrigger) costs points once. Workers are NPCControllers driven by an NPCBehaviorProfile. Invisible colliders on the PlayerBounds layer (in env.prefab) keep the player inside the warehouse.
  • Equipment validation (3.10). EquipmentValidator runs IValidationRules (hook, sling, shackle, weight estimate). A Critical fault fails the rig; Major/Minor faults pass with a penalty. All messages come from EquipmentMessages.
  • Scoring and results (3.11). ScoringService sums scoring events into a breakdown and a grade against the scenario's maximum score; the Results panel shows the outcome, the top events and the details.
  • Audio (3.12). IAudioService / UnityAudioService with AudioCueSO clip sets and mixer channels.
  • Rigging (3.13). RiggingAssembly builds the chosen shackle and a visual Verlet sling (RopeSimulator); RiggingFailureController snaps it at lift-off when validation failed.
  • Build and delivery (3.14 - 3.16). Lighting bake tooling, WebGL settings and memory ceiling, Addressables streaming of the level scenes with the shared-group layout that keeps every file under 25 MiB.

Where to look next

  • Create your own level - the data and scene setup of a level, step by step.
  • API reference - every type in the three layers.
  • Docs/ProjectSpec.md - design notes for every system.
  • Docs/ReleaseAndDeploy.md - restoring the project, baking lighting, building and deploying.