How pcrain/gungeoncraft works
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: Main.cs Main · Cwaff-Misc Systems · CwaffPatches.cs Core patches · Resources Runtime assets
Components 23
Runtime mod
Bootstrap, shared state, patching, and runtime services.
- Main · BepInEx plugin bootstrap and mod initialization.
src/Main.cs - Common · Shared startup helpers and global mod utilities.
src/Common.cs - Config · Mod configuration and tunables.
src/CwaffConfig.cs - Debug · Debug logging, developer hooks, and runtime inspection.
src/CwaffDebug.cs - Databases · Central registries and lookup tables for mod content.
src/Databases.cs - Core patches · Primary Harmony/Detour patches that alter base game behavior.
src/Cwaff-Misc/CwaffPatches.cs - Compat patches · 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 · Per-weapon definitions, firing logic, reload behavior, and visuals.
src/Cwaff-Guns - Passives · Passive item effects that modify combat, economy, or player state.
src/Cwaff-Passives - Actives · Active items and consumables with triggered behaviors.
src/Cwaff-Actives - Characters · Custom playable characters and their associated behaviors.
src/Cwaff-Characters - Bosses · Custom bosses, attack sets, and boss-specific patches.
src/Cwaff-Enemies/Bosses - NPCs · Standalone NPC definitions and dialogue-driven interactables.
src/Cwaff-NPCs - Flows · Custom dungeon flows and room placement wiring.
src/Cwaff-Flows - Rooms · Custom room logic and room-type behaviors.
src/Cwaff-Rooms
Shared systems
Reusable helpers and cross-cutting gameplay infrastructure.
- Systems · Reusable item, projectile, UI, VFX, and gameplay service code.
src/Cwaff-Misc
Persistence
Save, unlock, and long-term progression tracking.
- Save API · Custom save, unlock, stats, and hunt-quest tracking.
src/GungoSaveAPI
Assets
Authoring inputs and runtime-consumed packaged resources.
- Raw assets · Source sprites, sounds, JSON animation data, and room art.
RawResources - Runtime assets · Shipped resources consumed by the mod at runtime.
Resources
Dependencies
External modding and game runtime boundaries.
- BepInEx · Plugin runtime and configuration host for the mod.
- Harmony/Detour · Runtime method patching and detour infrastructure.
- Gungeon/Unity · Enter the Gungeon and Unity engine assemblies the mod extends.
- Mod APIs · Third-party modding APIs used to register content and integrate with game systems.
Connections 28
- 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.