# coremaze/cwsdk architecture

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

- Interactive diagram: https://gitdiagram.com/coremaze/cwsdk
- Repository: https://github.com/coremaze/cwsdk

## Overview

CWSDK is a C++ interface and runtime support library for Cube World mods. The primary workflow is that a mod includes `cwsdk.h`, exports `MakeMod`, and is loaded by the Cube World Mod Launcher; after initialization, the game invokes mod-overridable callbacks for events such as chat, ticks, input, rendering, and gameplay calculations. The repository also exposes game, graphics, UI, and Steam types. README documents the callback contract; sampled source is mostly type/layout declarations, so internal wiring beyond that contract is not inferred.

Main entry points: [`cwsdk.h`](https://github.com/coremaze/cwsdk/blob/master/cwsdk.h) (GenericMod callbacks), [`cwsdk.cpp`](https://github.com/coremaze/cwsdk/blob/master/cwsdk.cpp) (SDK runtime), [`steam/steam_api.h`](https://github.com/coremaze/cwsdk/blob/master/steam/steam_api.h) (Steam interfaces), [`cube/Game.h`](https://github.com/coremaze/cwsdk/blob/master/cube/Game.h) (Gameplay state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mod_api["Mod API"]
  node_mod_api["GenericMod callbacks<br/>[cwsdk.h]"]
  node_sdk_runtime["SDK runtime<br/>[cwsdk.cpp]"]
end

subgraph group_game_types["Game Model"]
  node_gameplay["Gameplay state<br/>[Game.h]"]
  node_world["World and zones<br/>[World.h]"]
  node_creatures["Creature stats<br/>[Creature.h]"]
  node_items["Items and inventory<br/>[Item.h]"]
  node_game_ui["Game UI widgets<br/>[GUI.h]"]
end

subgraph group_runtime["Runtime Interfaces"]
  node_graphics["Graphics and chunks<br/>[Graphics.h]"]
  node_plasma_ui["Plasma UI engine<br/>[Engine.h]"]
  node_math_types["Math primitives<br/>[Vector3.h]"]
  node_controls["Game controls<br/>[Controls.h]"]
  node_audio["Audio and music<br/>[XAudio2Engine.h]"]
end

subgraph group_platform["Platform SDKs"]
  node_steam_api["Steam interfaces<br/>[steam_api.h]"]
  node_steam_network["Steam networking<br/>[ISteamNetworking.h]"]
end

node_mod_author(("Mod author"))
node_launcher["Mod Launcher"]
node_game["Cube World"]

node_mod_author -->|"implements"| node_mod_api
node_mod_author -->|"exports mod"| node_launcher
node_launcher -->|"loads mod"| node_sdk_runtime
node_sdk_runtime -->|"initializes"| node_mod_api
node_game -->|"dispatches events"| node_mod_api
node_game -->|"exposes state"| node_gameplay
node_game -->|"generates zones"| node_world
node_game -->|"calculates stats"| node_creatures
node_game -->|"checks inventory"| node_items
node_game -->|"runs UI"| node_game_ui
node_game -->|"renders"| node_graphics
node_game -->|"uses engine"| node_plasma_ui
node_game -->|"reads input"| node_controls
node_game -->|"plays audio"| node_audio
node_game -.->|"uses interfaces"| node_steam_api
node_steam_api -->|"exposes networking"| node_steam_network

click node_mod_api "https://github.com/coremaze/cwsdk/blob/master/cwsdk.h"
click node_sdk_runtime "https://github.com/coremaze/cwsdk/blob/master/cwsdk.cpp"
click node_gameplay "https://github.com/coremaze/cwsdk/blob/master/cube/Game.h"
click node_world "https://github.com/coremaze/cwsdk/blob/master/cube/World.h"
click node_creatures "https://github.com/coremaze/cwsdk/blob/master/cube/Creature.h"
click node_items "https://github.com/coremaze/cwsdk/blob/master/cube/Item.h"
click node_game_ui "https://github.com/coremaze/cwsdk/blob/master/cube/GUI.h"
click node_graphics "https://github.com/coremaze/cwsdk/blob/master/gfx/Graphics.h"
click node_plasma_ui "https://github.com/coremaze/cwsdk/blob/master/plasma/Engine.h"
click node_math_types "https://github.com/coremaze/cwsdk/blob/master/common/Vector3.h"
click node_controls "https://github.com/coremaze/cwsdk/blob/master/cube/Controls.h"
click node_audio "https://github.com/coremaze/cwsdk/blob/master/cube/XAudio2Engine.h"
click node_steam_api "https://github.com/coremaze/cwsdk/blob/master/steam/steam_api.h"
click node_steam_network "https://github.com/coremaze/cwsdk/blob/master/steam/ISteamNetworking.h"

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_mod_api,node_sdk_runtime toneBlue
class node_gameplay,node_world,node_creatures,node_items,node_game_ui toneAmber
class node_graphics,node_plasma_ui,node_math_types,node_controls,node_audio toneMint
class node_steam_api,node_steam_network toneRose
class node_mod_author,node_launcher,node_game toneIndigo
```

## Components

### Mod API

- [GenericMod callbacks](https://github.com/coremaze/cwsdk/blob/master/cwsdk.h): `cwsdk.h`
- [SDK runtime](https://github.com/coremaze/cwsdk/blob/master/cwsdk.cpp): `cwsdk.cpp`

### Game Model

- [Gameplay state](https://github.com/coremaze/cwsdk/blob/master/cube/Game.h): `cube/Game.h`
- [World and zones](https://github.com/coremaze/cwsdk/blob/master/cube/World.h): `cube/World.h`
- [Creature stats](https://github.com/coremaze/cwsdk/blob/master/cube/Creature.h): `cube/Creature.h`
- [Items and inventory](https://github.com/coremaze/cwsdk/blob/master/cube/Item.h): `cube/Item.h`
- [Game UI widgets](https://github.com/coremaze/cwsdk/blob/master/cube/GUI.h): `cube/GUI.h`

### Runtime Interfaces

- [Graphics and chunks](https://github.com/coremaze/cwsdk/blob/master/gfx/Graphics.h): `gfx/Graphics.h`
- [Plasma UI engine](https://github.com/coremaze/cwsdk/blob/master/plasma/Engine.h): `plasma/Engine.h`
- [Math primitives](https://github.com/coremaze/cwsdk/blob/master/common/Vector3.h): `common/Vector3.h`
- [Game controls](https://github.com/coremaze/cwsdk/blob/master/cube/Controls.h): `cube/Controls.h`
- [Audio and music](https://github.com/coremaze/cwsdk/blob/master/cube/XAudio2Engine.h): `cube/XAudio2Engine.h`

### Platform SDKs

- [Steam interfaces](https://github.com/coremaze/cwsdk/blob/master/steam/steam_api.h): `steam/steam_api.h`
- [Steam networking](https://github.com/coremaze/cwsdk/blob/master/steam/ISteamNetworking.h): `steam/ISteamNetworking.h`

### Other components

- **Mod author**
- **Mod Launcher**
- **Cube World**

## Connections

- Mod author → GenericMod callbacks: implements
- Mod author → Mod Launcher: exports mod
- Mod Launcher → SDK runtime: loads mod
- SDK runtime → GenericMod callbacks: initializes
- Cube World → GenericMod callbacks: dispatches events
- Cube World → Gameplay state: exposes state
- Cube World → World and zones: generates zones
- Cube World → Creature stats: calculates stats
- Cube World → Items and inventory: checks inventory
- Cube World → Game UI widgets: runs UI
- Cube World → Graphics and chunks: renders
- Cube World → Plasma UI engine: uses engine
- Cube World → Game controls: reads input
- Cube World → Audio and music: plays audio
- Cube World → Steam interfaces: uses interfaces
- Steam interfaces → Steam networking: exposes networking
