# rwmoddingch/randombuff architecture

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

- Interactive diagram: https://gitdiagram.com/rwmoddingch/randombuff
- Repository: https://github.com/rwmoddingch/randombuff

## Overview

##### Project Type and Purpose
- This is a Unity-based game mod (Random Buff) composed of multiple C# class-library projects that are injected into the host game via a mod-loader (Harmony patches). Its goal is to add roguelike-style “buff” cards, menus, quests and UI to the game.
- The solution also includes auxiliary modules (BombExpand, BuildInBuff, ExpeditionExtend, LobotomyCorporationPack) each implementing sets of buffs and missions, plus a WinForms tool (MultiLayerHelper) for generating code or configuration.

##### File‐Structure Analysis
Top‐level projects and folders:
- RandomBuff.sln – main solution
- RandomBuff/RandomBuff.csproj – core mod plugin
- RandomBuffUtils/RandomBuffUtils.csproj – utility library used by core and modules
- BombExpand, BuildInBuff, ExpeditionExtend, LobotomyCorporationPack – extension-module projects, each exposing new Buff classes and mission hooks
- MultiLayerHelper – WinForms app for generating code or configuration artifacts
- buffinfos – JSON metadata (buff definitions, quests, templates) read by the mod at startup
- – SDKConfig.json and publicized assemblies listing for hooking
- tools – Lua/batch scripts to automate code/data generation

##### README Insights
- Points to template repo, API docs and Wiki for details on adding new buffs

A. Main Components
1. Host Game Engine (Unity)
2. Mod Loader / Harmony Patch Engine
3. RandomBuff Core Plugin
– Entry point (BuffEntry)
– Buff registration (BuffRegister, BuffBuilder)
– Hook orchestrator (CoreHooks, InGameCoreHooks)
4. RandomBuffUtils Library
– Helpers for scene hooking, asset loading, particle systems, game‐object extension
5. Extension Modules
– BombExpand
– BuildInBuff
– ExpeditionExtend
– LobotomyCorporationPack
(Each module contains C# “Buff” classes and Mission hooks)
6. Data Stores
– buffinfos JSON files (buff definitions, quest configs, templates)
7. UI Subsystems
– BuffMenu (in‐game menu pages)
– Cardpedia (information browser)
– HUD (BuffHud, NotificationManager)
8. Tools
– MultiLayerHelper (WinForms app reading SDKConfig.json & publicized assemblies to generate stubs)
– Lua scripts / generate.bat for scaffolding

B. Relationships and Data Flows
- At game launch, the Mod Loader injects RandomBuff Core via Harmony.
- RandomBuffCore reads SDKConfig.json and publicized assemblies list (include/) to know which modules to load.
- Core plugin loads each module assembly (BombExpand.dll, BuildInBuff.dll, etc.).
- Core reads buffinfos/*.json and buffassets asset bundles to populate BuffStaticData.
- Modules register their Buff classes and Mission hooks via BuffRegister/MissionRegister.
- Core builds all Buff objects (BuffBuilder) and registers timers, events, UI hooks.
- UI Subsystems (BuffMenu, Cardpedia, HUD) subscribe to Core’s events to render menus/cards.

C. Architectural Patterns & Principles
- Plugin‐based modular architecture: core + extension assemblies
- Event‐driven / observer pattern for in‐game hooks
- Factory/Builder pattern for Buff object creation
- Separation of concerns: Core logic vs. UI rendering vs. Data loading vs. Module implementations
- Utility library (RandomBuffUtils) for cross‐cutting concerns (asset loading, patch helpers)

D. Key Technologies & Frameworks
- C# / .NET (class libraries, WinForms)
- Unity AssetBundle system (buffassets)
- JSON configuration files (buffinfos)
- Harmony (runtime method‐patching, include/publicized_assemblies)
- Lua & batch scripts for code/data generation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Game & Loader
    subgraph "Game & Loader"
        GameEngine["Unity Game Engine"]:::engine
        ModLoader["Mod Loader / Harmony Patch Engine"]:::engine
    end

    %% Core Plugin
    subgraph "RandomBuff Core Plugin"
        RandomBuffCore["RandomBuff Core"]:::core
        BuffEntry["BuffEntry"]:::core
        BuffRegister["BuffRegister"]:::core
        BuffBuilder["BuffBuilder"]:::core
        CoreHooks["CoreHooks"]:::core
        InGameCoreHooks["InGameCoreHooks"]:::core
    end

    %% Utils Library
    RandomBuffUtils["RandomBuffUtils Library"]:::utils

    %% Extension Modules
    subgraph "Extension Modules"
        BombExpand["BombExpand"]:::module
        BuildInBuff["BuildInBuff"]:::module
        ExpeditionExtend["ExpeditionExtend"]:::module
        LobotomyPack["LobotomyCorporationPack"]:::module
    end

    %% Data Stores
    subgraph "Data Stores"
        JSONMetadata["buffinfos JSON Metadata"]:::data
        AssetBundles["buffassets AssetBundles"]:::data
    end

    %% UI Subsystems
    subgraph "UI Subsystems"
        BuffMenu["BuffMenu"]:::ui
        Cardpedia["Cardpedia"]:::ui
        BuffHud["BuffHud"]:::ui
        NotificationManager["NotificationManager"]:::ui
    end

    %% Tools
    subgraph "Tools"
        MultiLayerHelper["MultiLayerHelper (WinForms)"]:::tool
        AutomationScripts["Automation Scripts"]:::tool
    end

    %% Connections
    GameEngine -->|injects| ModLoader
    ModLoader -->|loads| RandomBuffCore
    RandomBuffCore --> BuffEntry
    RandomBuffCore --> BuffRegister
    RandomBuffCore --> BuffBuilder
    RandomBuffCore --> CoreHooks
    RandomBuffCore --> InGameCoreHooks
    RandomBuffCore -->|uses| RandomBuffUtils
    RandomBuffCore -->|loads assemblies| BombExpand
    RandomBuffCore -->|loads assemblies| BuildInBuff
    RandomBuffCore -->|loads assemblies| ExpeditionExtend
    RandomBuffCore -->|loads assemblies| LobotomyPack
    RandomBuffCore -->|reads| JSONMetadata
    RandomBuffCore -->|reads| AssetBundles
    RandomBuffCore -->|triggers| BuffMenu
    RandomBuffCore -->|triggers| Cardpedia
    RandomBuffCore -->|triggers| BuffHud
    RandomBuffCore -->|triggers| NotificationManager
    MultiLayerHelper -->|reads| include/SDKConfig.json
    MultiLayerHelper -->|reads| include/publicized_assemblies
    AutomationScripts -->|generates| RandomBuffUtils

    %% Click Events
    click ModLoader "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/include/SDKConfig.json"
    click RandomBuffCore "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/RandomBuff.csproj"
    click BuffEntry "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Core/Entry/BuffEntry.cs"
    click BuffRegister "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Core/Entry/BuffRegister.cs"
    click BuffBuilder "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Core/Buff/BuffBuilder.cs"
    click CoreHooks "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Core/Hooks/CoreHooks.cs"
    click InGameCoreHooks "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Core/Hooks/InGameCoreHooks.cs"
    click RandomBuffUtils "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuffUtils/RandomBuffUtils.csproj"
    click BombExpand "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/BombExpand/BombExpand.csproj"
    click BuildInBuff "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/BuildInBuff/BuiltinBuffs.csproj"
    click ExpeditionExtend "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/ExpeditionExtend/ExpeditionExtend.csproj"
    click LobotomyPack "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/LobotomyCorporationPack/LobotomyCorporationPack.csproj"
    click JSONMetadata "https://github.com/rwmoddingch/randombuff/tree/V1.1-(1.10)/buffinfos/"
    click AssetBundles "https://github.com/rwmoddingch/randombuff/tree/V1.1-(1.10)/buffassets/"
    click BuffMenu "https://github.com/rwmoddingch/randombuff/tree/V1.1-(1.10)/RandomBuff/Core/BuffMenu/"
    click Cardpedia "https://github.com/rwmoddingch/randombuff/tree/V1.1-(1.10)/RandomBuff/Cardpedia/"
    click BuffHud "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Core/Game/BuffHud.cs"
    click NotificationManager "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/RandomBuff/Render/UI/Notification/NotificationManager.cs"
    click MultiLayerHelper "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/MultiLayerHelper/MultiLayerHelper.csproj"
    click AutomationScripts "https://github.com/rwmoddingch/randombuff/blob/V1.1-(1.10)/tools/generate.bat"

    %% Styles
    classDef engine fill:#ddd,stroke:#333,stroke-width:1px
    classDef core fill:#bbf,stroke:#333,stroke-width:1px
    classDef utils fill:#eef,stroke:#333,stroke-width:1px
    classDef module fill:#bfb,stroke:#333,stroke-width:1px
    classDef data fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef ui fill:#ffc080,stroke:#333,stroke-width:1px
    classDef tool fill:#e5ccff,stroke:#333,stroke-width:1px
```
