# pcrain/gungeoncraft architecture

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

- Interactive diagram: https://gitdiagram.com/pcrain/gungeoncraft
- Repository: https://github.com/pcrain/gungeoncraft

## Overview

GungeonCraft is a C# game mod for Enter the Gungeon, built as a BepInEx plugin with Harmony/MonoMod-style runtime patching. The repo is organized around one bootstrap entrypoint and a large set of feature modules that register content into the game at startup.

1. **Top-level runtime boundary**
   - `src/Main.cs` is the likely plugin entrypoint that initializes the mod.
   - `src/Common.cs`, `src/CwaffConfig.cs`, `src/CwaffDebug.cs`, and `src/Databases.cs` act as shared bootstrap/support code.
   - The mod depends on `BepInEx`, `HarmonyX`, `MonoMod.RuntimeDetour`, `EtG.ModTheGungeonAPI`, `EtG.Alexandria`, `EtG.GameLibs`, and Unity/Enter the Gungeon assemblies, so most behavior is injected into the base game rather than running as a standalone app.

2. **Primary architecture pattern: content registration + runtime patching**
   - Most feature code is “define new thing, register it, patch the game where needed.”
   - New items, guns, NPCs, bosses, rooms, and flows are split into focused classes under `src/`.
   - `src/Cwaff-Misc/CwaffPatches.cs`, `src/Cwaff-Misc/CompatibilityPatches.cs`, and various feature-specific `*Patches.cs` files indicate heavy use of hooks to alter existing game systems.

3. **Major gameplay content domains**
   - `src/Cwaff-Guns/` contains the bulk of the mod: one file per weapon, each encapsulating a weapon’s stats, firing/reload behavior, visuals, and unique mechanics.
   - `src/Cwaff-Passives/` contains passive items with effects that modify player, gun, combat, or economy behavior.
   - `src/Cwaff-Actives/` contains active items and consumables that trigger special actions.
   - This separation is important for diagramming: content is grouped by item type, not by feature.

4. **Characters and character-specific behavior**
   - `src/Cwaff-Characters/` defines custom playable characters, including `Rancher` and `Rogo`.
   - Character-specific support code such as `SlimyboiManager`, `SlimyboiBehaviors`, and `SlimyboiPatches` suggests the character layer also owns companion/summon logic and runtime modifications tied to that character.
   - `src/CwaffCharactersCore.cs` appears to centralize common character registration/state.

5. **Enemies, bosses, and boss-specific systems**
   - `src/Cwaff-Enemies/Bosses/` contains two major bosses: `Armistice` and `Sans`.
   - Each boss has its own split between core logic, attack definitions, NPC/state handling, and patches.
   - Shared helper code under `src/Cwaff-Enemies/Helpers/` supports bullet scripting and pathable projectiles, showing that boss attacks are built on top of custom bullet behavior rather than only standard enemy AI.

6. **Dungeon flows and room injection**
   - `src/Cwaff-Flows/` defines custom dungeon flows and the wiring needed to place them into the game.
   - `ArmisticeDungeon.cs`, `SansDungeon.cs`, and `OneOffDebugDungeonFlow.cs` suggest both permanent content and debug/test flows.
   - `src/Cwaff-Rooms/` contains room logic for custom room types like puzzle rooms, while `Resources/Rooms/*.newroom` stores the actual room definitions.
   - This is a clear data flow: room assets are authored in resources, then loaded/registered through the flow code.

7. **NPCs, shops, and hub interactions**
   - `src/Cwaff-NPCs/` contains standalone NPC definitions such as `Bart`, `Cammy`, `Don`, and `Kevlar`.
   - `src/Cwaff-Misc/FancyShopBuilder.cs`, `ModdedShopItemAdder.cs`, `MiniInteractable.cs`, and related helpers indicate the mod adds custom shops and interactable objects in the Breach or dungeon.
   - The README’s Companion Shop, Barter Shop, Insurance Shop, and hat room likely map to this interaction layer.

8. **Shared systems and cross-cutting gameplay services**
   - `src/Cwaff-Misc/` is the largest support layer and contains reusable systems used by many items:
     - item, projectile, and trail helpers
     - shaders/VFX helpers
     - run data and event tracking
     - custom UI/reticle/rope/mesh utilities
     - mastery/synergy/shrine/override frameworks
   - Files like `CwaffRunData.cs`, `CwaffEvents.cs`, `CwaffMasteries.cs`, `CwaffSynergies.cs`, and `CwaffOverrides.cs` imply the mod maintains its own lightweight game-state layer for tracking unlocks, effects, and run progression.

9. **Custom save/unlock API integration**
   - `src/GungoSaveAPI/` is a dedicated subsystem for persistence and unlock tracking.
   - It defines custom tracked stats, dungeon flags, maximums, hunt quests, and save management.
   - This layer is likely the bridge between gameplay events and persistent unlocks, so it is important in any diagram as the “state saved outside a single run” boundary.

10. **Asset organization and content pipeline**
    - `RawResources/` contains source art/audio/animation data: sprites, ASEprite files, WAVs, weapon animation JSON, and themed asset folders.
    - `Resources/` contains packaged runtime resources, including shaders and authored room files.
    - The many `RawResources/WeaponCollection/*.json` files and `RawResources/Sounds/*.wav` files show the mod uses per-weapon animation/audio data heavily, with content-specific assets tightly coupled to each weapon class.
    - `RawResources` is the authoring/input layer; `Resources` is the runtime-consumed layer.

11. **Audio and VFX are first-class content**
    - There are extensive custom sound banks in `RawResources/Sounds/`, plus `gen-gungeon-audio-bank.py` to build the final audio bank.
    - `src/VFXToolbox.cs` and `src/Cwaff-Misc/CwaffShaders.cs` indicate custom visual effects and shader support.
    - Many weapons appear to depend on their own bespoke audio and animated firing effects, so the item layer is not just logic; it is visual/audio-rich content.

12. **Build and generation tooling**
    - The repo includes scripts such as `gen-changelog.py`, `gen-itemtips.py`, and `gen-wiki.py` for release notes, item descriptions, and wiki/export generation.
    - `genproject` and the `.csproj` indicate a standard C# build with bundled packages under `packages/`.
    - This means the development workflow is partly code-driven and partly content/metadata generation-driven.

13. **Dependencies and packaging boundaries**
    - `packages/` vendors the game-modding dependencies and Unity references, so the repo is largely self-contained for build-time dependencies.
    - The presence of separate package versions for `EtG.*`, BepInEx, HarmonyX, MonoMod, and Cecil suggests the mod targets the existing game runtime and relies on those libraries for patching and content registration.

14. **How data flows through the mod**
    - Authoring starts in `RawResources` and `src/` feature classes.
    - Startup code registers content, applies patches, and wires systems together.
    - Gameplay events trigger item/boss/NPC logic and update shared systems like run data and save data.
    - Those systems may persist unlocks through `GungoSaveAPI`, or drive downstream presentation through shaders, VFX, sounds, and UI helpers.

15. **What to show in an architecture diagram**
    - A central mod bootstrap node.
    - Branches for guns, passives, actives, characters, bosses, NPCs, rooms/flows, and shared systems.
    - A separate persistence/save subsystem.
    - A resource pipeline from raw assets to runtime resources.
    - External dependencies on the base game, Unity, BepInEx, and Harmony-based patching.

Main entry points: [`src/Main.cs`](https://github.com/pcrain/gungeoncraft/blob/master/src/Main.cs) (Main), [`src/Cwaff-Misc`](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Misc) (Systems), [`src/Cwaff-Misc/CwaffPatches.cs`](https://github.com/pcrain/gungeoncraft/blob/master/src/Cwaff-Misc/CwaffPatches.cs) (Core patches), [`Resources`](https://github.com/pcrain/gungeoncraft/tree/master/Resources) (Runtime assets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime mod"]
  node_main["Main<br/>plugin entrypoint<br/>[Main.cs]"]
  node_common["Common<br/>shared bootstrap<br/>[Common.cs]"]
  node_config["Config<br/>settings<br/>[CwaffConfig.cs]"]
  node_debug["Debug<br/>diagnostics<br/>[CwaffDebug.cs]"]
  node_databases["Databases<br/>content registry<br/>[Databases.cs]"]
  node_patches["Core patches<br/>runtime patching<br/>[CwaffPatches.cs]"]
  node_compat["Compat patches<br/>compatibility patching"]
end

subgraph group_content["Gameplay content"]
  node_guns["Guns<br/>weapon modules"]
  node_passives["Passives<br/>item modules"]
  node_actives["Actives<br/>item modules"]
  node_characters["Characters<br/>playable content"]
  node_bosses["Bosses<br/>enemy content"]
  node_npcs["NPCs"]
  node_flows["Flows<br/>dungeon wiring"]
  node_rooms["Rooms<br/>room logic"]
end

subgraph group_systems["Shared systems"]
  node_misc["Systems<br/>shared gameplay helpers"]
end

subgraph group_persistence["Persistence"]
  node_saveapi[("Save API<br/>persistence subsystem")]
end

subgraph group_assets["Assets"]
  node_raw["Raw assets<br/>authoring assets"]
  node_resources["Runtime assets<br/>packaged assets"]
end

subgraph group_deps["Dependencies"]
  node_bepinex["BepInEx<br/>mod loader"]
  node_harmony["Harmony/Detour<br/>patching libs"]
  node_game["Gungeon/Unity<br/>game runtime"]
  node_apils["Mod APIs<br/>content APIs"]
end

node_bepinex -->|"loads"| node_main
node_main -->|"boots"| node_common
node_main -->|"reads"| node_config
node_main -->|"enables"| node_debug
node_main -->|"registers"| node_databases
node_main -->|"applies"| node_patches
node_patches -->|"extends"| node_compat
node_main -->|"registers"| node_guns
node_main -->|"registers"| node_passives
node_main -->|"registers"| node_actives
node_main -->|"registers"| node_characters
node_main -->|"registers"| node_bosses
node_main -->|"registers"| node_npcs
node_main -->|"wires"| node_flows
node_flows -->|"places"| node_rooms
node_characters -->|"uses"| node_misc
node_bosses -->|"uses"| node_misc
node_guns -->|"uses"| node_misc
node_passives -->|"uses"| node_misc
node_actives -->|"uses"| node_misc
node_misc -->|"persists"| node_saveapi
node_raw -->|"builds into"| node_resources
node_resources -->|"feeds"| node_flows
node_resources -->|"feeds"| node_misc
node_harmony -->|"powers"| node_patches
node_game -->|"targets"| node_patches
node_apils -->|"supports"| node_databases
node_apils -->|"supports"| node_saveapi

click node_main "https://github.com/pcrain/gungeoncraft/blob/master/src/Main.cs"
click node_common "https://github.com/pcrain/gungeoncraft/blob/master/src/Common.cs"
click node_config "https://github.com/pcrain/gungeoncraft/blob/master/src/CwaffConfig.cs"
click node_debug "https://github.com/pcrain/gungeoncraft/blob/master/src/CwaffDebug.cs"
click node_databases "https://github.com/pcrain/gungeoncraft/blob/master/src/Databases.cs"
click node_patches "https://github.com/pcrain/gungeoncraft/blob/master/src/Cwaff-Misc/CwaffPatches.cs"
click node_compat "https://github.com/pcrain/gungeoncraft/blob/master/src/Cwaff-Misc/CompatibilityPatches.cs"
click node_guns "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Guns"
click node_passives "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Passives"
click node_actives "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Actives"
click node_characters "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Characters"
click node_bosses "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Enemies/Bosses"
click node_npcs "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-NPCs"
click node_flows "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Flows"
click node_rooms "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Rooms"
click node_misc "https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Misc"
click node_saveapi "https://github.com/pcrain/gungeoncraft/tree/master/src/GungoSaveAPI"
click node_raw "https://github.com/pcrain/gungeoncraft/tree/master/RawResources"
click node_resources "https://github.com/pcrain/gungeoncraft/tree/master/Resources"

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_main,node_common,node_config,node_debug,node_databases,node_patches,node_compat toneBlue
class node_guns,node_passives,node_actives,node_characters,node_bosses,node_npcs,node_flows,node_rooms toneAmber
class node_misc toneMint
class node_saveapi toneRose
class node_raw,node_resources toneIndigo
class node_bepinex,node_harmony,node_game,node_apils toneTeal
```

## Components

### Runtime mod

Bootstrap, shared state, patching, and runtime services.

- [Main](https://github.com/pcrain/gungeoncraft/blob/master/src/Main.cs): plugin entrypoint · BepInEx plugin bootstrap and mod initialization. · `src/Main.cs`
- [Common](https://github.com/pcrain/gungeoncraft/blob/master/src/Common.cs): shared bootstrap · Shared startup helpers and global mod utilities. · `src/Common.cs`
- [Config](https://github.com/pcrain/gungeoncraft/blob/master/src/CwaffConfig.cs): settings · Mod configuration and tunables. · `src/CwaffConfig.cs`
- [Debug](https://github.com/pcrain/gungeoncraft/blob/master/src/CwaffDebug.cs): diagnostics · Debug logging, developer hooks, and runtime inspection. · `src/CwaffDebug.cs`
- [Databases](https://github.com/pcrain/gungeoncraft/blob/master/src/Databases.cs): content registry · Central registries and lookup tables for mod content. · `src/Databases.cs`
- [Core patches](https://github.com/pcrain/gungeoncraft/blob/master/src/Cwaff-Misc/CwaffPatches.cs): runtime patching · Primary Harmony/Detour patches that alter base game behavior. · `src/Cwaff-Misc/CwaffPatches.cs`
- [Compat patches](https://github.com/pcrain/gungeoncraft/blob/master/src/Cwaff-Misc/CompatibilityPatches.cs): compatibility patching · Targeted fixes for interactions with other mods or game states. · `src/Cwaff-Misc/CompatibilityPatches.cs`

### Gameplay content

Item, character, enemy, NPC, and room feature modules.

- [Guns](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Guns): weapon modules · Per-weapon definitions, firing logic, reload behavior, and visuals. · `src/Cwaff-Guns`
- [Passives](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Passives): item modules · Passive item effects that modify combat, economy, or player state. · `src/Cwaff-Passives`
- [Actives](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Actives): item modules · Active items and consumables with triggered behaviors. · `src/Cwaff-Actives`
- [Characters](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Characters): playable content · Custom playable characters and their associated behaviors. · `src/Cwaff-Characters`
- [Bosses](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Enemies/Bosses): enemy content · Custom bosses, attack sets, and boss-specific patches. · `src/Cwaff-Enemies/Bosses`
- [NPCs](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-NPCs): hub/dungeon npcs · Standalone NPC definitions and dialogue-driven interactables. · `src/Cwaff-NPCs`
- [Flows](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Flows): dungeon wiring · Custom dungeon flows and room placement wiring. · `src/Cwaff-Flows`
- [Rooms](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Rooms): room logic · Custom room logic and room-type behaviors. · `src/Cwaff-Rooms`

### Shared systems

Reusable helpers and cross-cutting gameplay infrastructure.

- [Systems](https://github.com/pcrain/gungeoncraft/tree/master/src/Cwaff-Misc): shared gameplay helpers · Reusable item, projectile, UI, VFX, and gameplay service code. · `src/Cwaff-Misc`

### Persistence

Save, unlock, and long-term progression tracking.

- [Save API](https://github.com/pcrain/gungeoncraft/tree/master/src/GungoSaveAPI): persistence subsystem · Custom save, unlock, stats, and hunt-quest tracking. · `src/GungoSaveAPI`

### Assets

Authoring inputs and runtime-consumed packaged resources.

- [Raw assets](https://github.com/pcrain/gungeoncraft/tree/master/RawResources): authoring assets · Source sprites, sounds, JSON animation data, and room art. · `RawResources`
- [Runtime assets](https://github.com/pcrain/gungeoncraft/tree/master/Resources): packaged assets · Shipped resources consumed by the mod at runtime. · `Resources`

### Dependencies

External modding and game runtime boundaries.

- **BepInEx**: mod loader · Plugin runtime and configuration host for the mod.
- **Harmony/Detour**: patching libs · Runtime method patching and detour infrastructure.
- **Gungeon/Unity**: game runtime · Enter the Gungeon and Unity engine assemblies the mod extends.
- **Mod APIs**: content APIs · Third-party modding APIs used to register content and integrate with game systems.

## Connections

- BepInEx → Main: loads · BepInEx discovers and runs the plugin entrypoint.
- Main → Common: boots · Startup code delegates to shared initialization helpers.
- Main → Config: reads · Initialization uses mod configuration.
- Main → Debug: enables · Debug utilities are wired during startup.
- Main → Databases: registers · Content registries are populated at startup.
- Main → Core patches: applies · Core runtime patches are installed during bootstrap.
- Core patches → Compat patches: extends · Compatibility fixes layer on top of core patching.
- Main → Guns: registers · Weapon modules self-register into the mod.
- Main → Passives: registers · Passive items are added during startup.
- Main → Actives: registers · Active items and consumables are added during startup.
- Main → Characters: registers · Playable characters are initialized and registered.
- Main → Bosses: registers · Boss content and attacks are wired into the game.
- Main → NPCs: registers · NPCs and breach interactions are added.
- Main → Flows: wires · Dungeon flow definitions are installed.
- Flows → Rooms: places · Flows reference custom room logic and authored room layouts.
- Characters → Systems: uses · Character state and companion logic reuse shared systems.
- Bosses → Systems: uses · Boss attacks and bullet scripting reuse shared helpers.
- Guns → Systems: uses · Weapons depend on shared item, projectile, VFX, and UI helpers.
- Passives → Systems: uses · Passive effects reuse the common gameplay framework.
- Actives → Systems: uses · Active items reuse shared item and effect helpers.
- Systems → Save API: persists · Run events and gameplay state are bridged into long-term save data.
- Raw assets → Runtime assets: builds into · Authoring assets are transformed into packaged runtime resources.
- Runtime assets → Flows: feeds · Authored room files are loaded by flow/room registration code.
- Runtime assets → Systems: feeds · Shaders and other packaged assets support shared systems.
- Harmony/Detour → Core patches: powers · Method patching infrastructure underpins runtime hooks.
- Gungeon/Unity → Core patches: targets · The mod patches Enter the Gungeon and Unity runtime behavior.
- Mod APIs → Databases: supports · External APIs are used for content registration and integration.
- Mod APIs → Save API: supports · Save and progression integration builds on modding APIs.
