groupsCommunity

Sandbox: Full codebase architecture — systems, player components, weapons, tools, NPCs

calendar_today May 4, 2026 schedule ~2 min read person patrickjr verified 50

Sandbox Codebase Architecture Overview

The Facepunch Sandbox game is a large reference implementation. Here's a map of the major systems and how they connect.

Core systems

SystemClassTypeDescription
Game loopGameManagerGameObjectSystemPlayer spawning, NPC death, water, achievements
UndoUndoSystemGameObjectSystemPer-player undo stacks (128 steps max)
LimitsLimitsSystemGameObjectSystemPer-player prop/constraint/tool limits via ConVars
CleanupCleanupSystemGameObjectSystemScene cleanup, per-player cleanup
Save/LoadSaveSystemGameObjectSystemScene diff save/load with versioning
ControlControlSystemGameObjectSystemDrives IPlayerControllable on contraptions
Camera noiseCameraNoiseSystemGameObjectSystemScreen shake, punch, recoil
BanBanSystemGameObjectSystemPersistent ban list
FreeCamFreeCamGameObjectSystemGameObjectSystemSpectator free camera

Player components (all on the player prefab)

Weapon hierarchy

CODE
BaseCarryable
  └── BaseWeapon (ammo, reload, shoot delay)
        ├── BaseBulletWeapon (hitscan, BulletConfiguration)
        │     └── IronSightsWeapon (ADS)
        └── MeleeWeapon (swing, hit detection)

Tool Gun architecture

CODE
Toolgun (ScreenWeapon)
  └── ToolMode components (one per tool, only one enabled at a time)
        ├── BaseConstraintToolMode (two-stage selection)
        │     ├── Weld, Rope, BallSocket, Elastic, NoCollide
        │     ├── Slider, Hydraulic
        │     └── KeepUpright
        ├── Duplicator (copy/paste contraptions)
        ├── ThrusterTool, WheelTool, HoverballTool
        ├── StackerTool, LinkerTool, DecalTool
        └── Remover, Mass, Resizer, Trail, Balloon, Emitter

Spawner hierarchy

CODE
ISpawner
  ├── PropSpawner (cloud model ident)
  ├── EntitySpawner (scripted entity prefab)
  ├── DuplicatorSpawner (JSON contraption)
  └── MountSpawner (mounted content)

NPC architecture

CODE
Npc (base component)
  ├── Layers (continuous behaviours)
  │     ├── NavigationLayer (NavMeshAgent)
  │     ├── SensesLayer (scan for targets)
  │     ├── AnimationLayer (anim graph)
  │     └── SpeechLayer (subtitles)
  └── Schedules (discrete task sequences)
        └── Tasks (MoveTo, LookAt, Say, Wait, FireWeapon, PickUpProp, DropProp)

Key event interfaces

Was this helpful?