# try/opengothic architecture

> Architecture diagram of the GitHub repository try/opengothic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/try/opengothic
- Repository: https://github.com/try/opengothic

## Overview

OpenGothic is a Gothic 2 game client that loads the player’s original game data, runs a scripted world simulation, and presents it through game UI, graphics, audio, and physics. Its principal startup path is the game executable into the main window and Gothic runtime. The tree also contains Spacer, a world-editing application with project management and background asset loading. Edges below are limited to relationships visible in excerpts or the source index; unsampled subsystems are included where the README or tree establishes their role, without guessing their call paths.

Main entry points: [`common/gothic.cpp`](https://github.com/try/opengothic/blob/master/common/gothic.cpp) (Gothic runtime), [`common/world/world.cpp`](https://github.com/try/opengothic/blob/master/common/world/world.cpp) (World simulation), [`game/main.cpp`](https://github.com/try/opengothic/blob/master/game/main.cpp) (Game startup), [`common/mainwindow.cpp`](https://github.com/try/opengothic/blob/master/common/mainwindow.cpp) (Game window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_game_entry["Game startup<br/>[main.cpp]"]
  node_game_window["Game window<br/>[mainwindow.cpp]"]
  node_gothic_runtime["Gothic runtime<br/>[gothic.cpp]"]
  node_command_line["Launch options<br/>[commandline.h]"]
end

subgraph group_simulation["World simulation"]
  node_game_session["Game session<br/>[gamesession.h]"]
  node_game_script["Game scripting<br/>[gamescript.h]"]
  node_world["World simulation<br/>[world.cpp]"]
  node_npc_ai["NPC behavior<br/>[npc.cpp]"]
  node_physics["Physics simulation<br/>[dynamicworld.cpp]"]
  node_world_triggers["World triggers"]
end

subgraph group_presentation["Game presentation"]
  node_renderer["World rendering<br/>[renderer.cpp]"]
  node_mesh_rendering["Meshes and animation<br/>[meshobjects.h]"]
  node_shader_system["Graphics shaders<br/>[shaders.h]"]
  node_game_ui["Game menus<br/>[menuroot.h]"]
  node_game_audio["Sound and music<br/>[soundfx.cpp]"]
end

subgraph group_content["Content and persistence"]
  node_resource_loading["Game resources<br/>[resources.h]"]
  node_game_serialization["Save serialization<br/>[serialize.h]"]
  node_world_state[("World save state")]
  node_original_data[("Original game data")]
end

subgraph group_editor["Spacer editor"]
  node_editor_entry["Spacer startup<br/>[main.cpp]"]
  node_editor_window["Editor window<br/>[editorwindow.h]"]
  node_project_manager["Project manager<br/>[projectmgr.h]"]
  node_editor_world["World editing<br/>[worldedit.h]"]
  node_editor_loader["Asset loader<br/>[dataworker.cpp]"]
  node_project_items["Project items<br/>[projectitem.cpp]"]
  node_ray_query["Ray queries<br/>[rayquery.cpp]"]
end

node_player(("Player"))

node_player -->|"starts"| node_game_entry
node_game_entry -->|"parses options"| node_command_line
node_game_entry -->|"creates window"| node_game_window
node_game_window -->|"uses runtime"| node_gothic_runtime
node_gothic_runtime -->|"manages session"| node_game_session
node_gothic_runtime -->|"accesses world"| node_world
node_world -->|"exposes scripts"| node_game_script
node_world -->|"owns physics"| node_physics
node_world -->|"provides world view"| node_renderer
node_npc_ai -->|"uses scripts"| node_game_script
node_npc_ai -->|"uses physics"| node_physics
node_world_triggers -->|"uses collision world"| node_physics
node_world_triggers -->|"creates particle effects"| node_renderer
node_renderer -.->|"renders meshes"| node_mesh_rendering
node_mesh_rendering -->|"uses shaders"| node_shader_system
node_game_window -->|"hosts menus"| node_game_ui
node_gothic_runtime -->|"provides sound"| node_game_audio
node_gothic_runtime -.->|"loads resources"| node_resource_loading
node_game_session -->|"serializes state"| node_game_serialization
node_world_state -->|"saves and loads"| node_world
node_game_serialization -->|"writes save data"| node_world_state
node_original_data -->|"supplies game content"| node_gothic_runtime
node_player -.->|"launches editor"| node_editor_entry
node_editor_entry -->|"creates editor"| node_editor_window
node_editor_entry -->|"creates manager"| node_project_manager
node_project_manager -.->|"manages items"| node_project_items
node_editor_world -->|"loads previews"| node_editor_loader
node_editor_loader -->|"loads items"| node_project_items
node_ray_query -->|"queries world"| node_editor_world

click node_game_entry "https://github.com/try/opengothic/blob/master/game/main.cpp"
click node_game_window "https://github.com/try/opengothic/blob/master/common/mainwindow.cpp"
click node_gothic_runtime "https://github.com/try/opengothic/blob/master/common/gothic.cpp"
click node_command_line "https://github.com/try/opengothic/blob/master/common/commandline.h"
click node_game_session "https://github.com/try/opengothic/blob/master/common/game/gamesession.h"
click node_game_script "https://github.com/try/opengothic/blob/master/common/game/gamescript.h"
click node_world "https://github.com/try/opengothic/blob/master/common/world/world.cpp"
click node_npc_ai "https://github.com/try/opengothic/blob/master/common/world/objects/npc.cpp"
click node_physics "https://github.com/try/opengothic/blob/master/common/physics/dynamicworld.cpp"
click node_world_triggers "https://github.com/try/opengothic/blob/master/common/world/triggers/abstracttrigger.cpp"
click node_renderer "https://github.com/try/opengothic/blob/master/common/graphics/renderer.cpp"
click node_mesh_rendering "https://github.com/try/opengothic/blob/master/common/graphics/meshobjects.h"
click node_shader_system "https://github.com/try/opengothic/blob/master/common/graphics/shaders.h"
click node_game_ui "https://github.com/try/opengothic/blob/master/common/ui/menuroot.h"
click node_game_audio "https://github.com/try/opengothic/blob/master/common/sound/soundfx.cpp"
click node_resource_loading "https://github.com/try/opengothic/blob/master/common/resources.h"
click node_game_serialization "https://github.com/try/opengothic/blob/master/common/game/serialize.h"
click node_world_state "https://github.com/try/opengothic/blob/master/common/game/worldstatestorage.cpp"
click node_editor_entry "https://github.com/try/opengothic/blob/master/spacer/main.cpp"
click node_editor_window "https://github.com/try/opengothic/blob/master/spacer/editorwindow.h"
click node_project_manager "https://github.com/try/opengothic/blob/master/spacer/project/projectmgr.h"
click node_editor_world "https://github.com/try/opengothic/blob/master/spacer/objects/worldedit.h"
click node_editor_loader "https://github.com/try/opengothic/blob/master/spacer/workers/dataworker.cpp"
click node_project_items "https://github.com/try/opengothic/blob/master/spacer/project/projectitem.cpp"
click node_ray_query "https://github.com/try/opengothic/blob/master/spacer/objects/rayquery.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game_entry,node_game_window,node_gothic_runtime,node_command_line toneBlue
class node_game_session,node_game_script,node_world,node_npc_ai,node_physics,node_world_triggers toneAmber
class node_renderer,node_mesh_rendering,node_shader_system,node_game_ui,node_game_audio toneMint
class node_resource_loading,node_game_serialization,node_world_state,node_original_data toneRose
class node_editor_entry,node_editor_window,node_project_manager,node_editor_world,node_editor_loader,node_project_items,node_ray_query,node_player toneIndigo
```

## Components

### Game runtime

- [Game startup](https://github.com/try/opengothic/blob/master/game/main.cpp): `game/main.cpp`
- [Game window](https://github.com/try/opengothic/blob/master/common/mainwindow.cpp): `common/mainwindow.cpp`
- [Gothic runtime](https://github.com/try/opengothic/blob/master/common/gothic.cpp): `common/gothic.cpp`
- [Launch options](https://github.com/try/opengothic/blob/master/common/commandline.h): `common/commandline.h`

### World simulation

- [Game session](https://github.com/try/opengothic/blob/master/common/game/gamesession.h): `common/game/gamesession.h`
- [Game scripting](https://github.com/try/opengothic/blob/master/common/game/gamescript.h): `common/game/gamescript.h`
- [World simulation](https://github.com/try/opengothic/blob/master/common/world/world.cpp): `common/world/world.cpp`
- [NPC behavior](https://github.com/try/opengothic/blob/master/common/world/objects/npc.cpp): `common/world/objects/npc.cpp`
- [Physics simulation](https://github.com/try/opengothic/blob/master/common/physics/dynamicworld.cpp): `common/physics/dynamicworld.cpp`
- [World triggers](https://github.com/try/opengothic/blob/master/common/world/triggers/abstracttrigger.cpp): `common/world/triggers/abstracttrigger.cpp`

### Game presentation

- [World rendering](https://github.com/try/opengothic/blob/master/common/graphics/renderer.cpp): `common/graphics/renderer.cpp`
- [Meshes and animation](https://github.com/try/opengothic/blob/master/common/graphics/meshobjects.h): `common/graphics/meshobjects.h`
- [Graphics shaders](https://github.com/try/opengothic/blob/master/common/graphics/shaders.h): `common/graphics/shaders.h`
- [Game menus](https://github.com/try/opengothic/blob/master/common/ui/menuroot.h): `common/ui/menuroot.h`
- [Sound and music](https://github.com/try/opengothic/blob/master/common/sound/soundfx.cpp): `common/sound/soundfx.cpp`

### Content and persistence

- [Game resources](https://github.com/try/opengothic/blob/master/common/resources.h): `common/resources.h`
- [Save serialization](https://github.com/try/opengothic/blob/master/common/game/serialize.h): `common/game/serialize.h`
- [World save state](https://github.com/try/opengothic/blob/master/common/game/worldstatestorage.cpp): `common/game/worldstatestorage.cpp`
- **Original game data**

### Spacer editor

- [Spacer startup](https://github.com/try/opengothic/blob/master/spacer/main.cpp): `spacer/main.cpp`
- [Editor window](https://github.com/try/opengothic/blob/master/spacer/editorwindow.h): `spacer/editorwindow.h`
- [Project manager](https://github.com/try/opengothic/blob/master/spacer/project/projectmgr.h): `spacer/project/projectmgr.h`
- [World editing](https://github.com/try/opengothic/blob/master/spacer/objects/worldedit.h): `spacer/objects/worldedit.h`
- [Asset loader](https://github.com/try/opengothic/blob/master/spacer/workers/dataworker.cpp): `spacer/workers/dataworker.cpp`
- [Project items](https://github.com/try/opengothic/blob/master/spacer/project/projectitem.cpp): `spacer/project/projectitem.cpp`
- [Ray queries](https://github.com/try/opengothic/blob/master/spacer/objects/rayquery.cpp): `spacer/objects/rayquery.cpp`

### Other components

- **Player**

## Connections

- Player → Game startup: starts
- Game startup → Launch options: parses options (evidence: `game/main.cpp`)
- Game startup → Game window: creates window (evidence: `game/main.cpp`)
- Game window → Gothic runtime: uses runtime (evidence: `common/mainwindow.cpp`)
- Gothic runtime → Game session: manages session
- Gothic runtime → World simulation: accesses world
- World simulation → Game scripting: exposes scripts
- World simulation → Physics simulation: owns physics
- World simulation → World rendering: provides world view
- NPC behavior → Game scripting: uses scripts
- NPC behavior → Physics simulation: uses physics
- World triggers → Physics simulation: uses collision world
- World triggers → World rendering: creates particle effects
- World rendering → Meshes and animation: renders meshes
- Meshes and animation → Graphics shaders: uses shaders
- Game window → Game menus: hosts menus (evidence: `common/mainwindow.cpp`)
- Gothic runtime → Sound and music: provides sound
- Gothic runtime → Game resources: loads resources
- Game session → Save serialization: serializes state (evidence: `common/game/worldstatestorage.cpp`)
- World save state → World simulation: saves and loads (evidence: `common/game/worldstatestorage.cpp`)
- Save serialization → World save state: writes save data (evidence: `common/game/worldstatestorage.cpp`)
- Original game data → Gothic runtime: supplies game content
- Player → Spacer startup: launches editor
- Spacer startup → Editor window: creates editor (evidence: `spacer/main.cpp`)
- Spacer startup → Project manager: creates manager (evidence: `spacer/main.cpp`)
- Project manager → Project items: manages items
- World editing → Asset loader: loads previews (evidence: `spacer/workers/dataworker.cpp`)
- Asset loader → Project items: loads items (evidence: `spacer/workers/dataworker.cpp`)
- Ray queries → World editing: queries world (evidence: `spacer/objects/rayquery.cpp`)
