# illusionmods/hsplugins architecture

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

- Interactive diagram: https://gitdiagram.com/illusionmods/hsplugins
- Repository: https://github.com/illusionmods/hsplugins

## Overview

1. **Repository purpose**
   - This repo is a **suite of BepInEx game-studio plugins** for Illusion titles.
   - It is not one app; it is a **multi-plugin monorepo** with shared code and per-game builds.
   - The main product boundary is: **game runtime on one side, plugin DLLs loaded into BepInEx on the other**.

2. **Top-level architecture**
   - The codebase is split into:
     - **shared cores** (`*.Core`, `ToolBox`, `UIUtility`, `BonesFramework`, etc.)
     - **plugin frontends / game-specific projects** (`HSPE`, `HS2PE`, `KKPE`, `KKSPE`, `Timeline.*`, `VideoExport.*`, etc.)
     - **supporting tools** in `Other/`
   - Most features are implemented once in a shared core, then exposed through **per-game wrapper projects**.

3. **Game-specific plugin variants**
   - Many folders are separate builds for different games:
     - `HS`, `HS2`, `KK`, `KKS`, `AI`
   - These variants usually share the same feature code but differ in:
     - game-specific types and APIs
     - resource bundles
     - compatibility patches
     - packaging into distinct DLLs and release zips
   - This is the repo’s main partitioning axis.

4. **Shared feature cores**
   - Several subsystems are written as reusable “core” assemblies:
     - `Core.PoseEditor`
     - `Timeline.Core`
     - `UsefulStuff.Core`
     - `VideoExport.Core`
     - `NodesConstraints.Core`
     - `CollidersDebug.Core`
     - `ToolBox`, `UIUtility`, `BonesFramework`
   - These cores contain the bulk of the business logic and UI behavior.
   - Per-game projects mostly bind these cores to a specific game’s runtime and class names.

5. **Plugin families and their responsibilities**
   - **Pose editing / studio control**: `HSPE`, `HS2PE`, `KKPE`, `KKSPE`, `AIPE`, `Core.PoseEditor`
   - **Timeline/animation editing**: `Timeline.*`
   - **Video/screenshot export**: `VideoExport.*`
   - **Lighting and rendering tools**: `LightingEditor`, `RendererEditor`, `HSLRE`, `HSIBL`, `FogEditor`, `CameraEditor`
   - **Accessory and wardrobe extensions**: `MoreAccessories*`
   - **Utility/quality-of-life**: `UsefulStuff.Core`, `HSExtSave`, `NodesConstraints.*`, `CollidersDebug.*`, `HSStandard`, `HSSuimono`
   - Each family is a separate architectural boundary with its own config, resources, and compatibility patches.

6. **Runtime integration pattern**
   - The plugins are loaded through **BepInEx** and interact with the game via:
     - **Harmony patches** for runtime interception
     - direct calls into game/editor APIs
     - custom Unity UI components and windows
   - The code frequently reacts to **studio events, camera events, and character/pose state changes**.
   - A common flow is: **game state change → patch/event hook → core logic updates models/UI → Unity scene changes**.

7. **UI and interaction layer**
   - `UIUtility` and `ToolBox` provide reusable building blocks for:
     - movable windows
     - context menus
     - looped list views
     - drag/scroll/pointer handlers
     - localization/translation helpers
   - Many plugins depend on these shared UI abstractions instead of duplicating UI code.
   - This layer is a key diagram boundary between **plugin logic** and **in-game Unity UI**.

8. **Data and configuration flow**
   - The fork moved configuration to **BepInEx config** rather than custom XML files.
   - Several plugins also load embedded **Unity asset bundles** from `Resources/*.unity3d`.
   - User-facing content is stored under **`UserData`** according to the README.
   - So the typical data path is:
     - packaged plugin DLL + embedded resources
     - runtime config from BepInEx
     - user content/assets from UserData
     - game state from the running studio/game.

9. **External/runtime dependencies that matter**
   - The architecture depends materially on:
     - **BepInEx 5** for plugin loading
     - **Harmony** for patching
     - **Unity** runtime/editor APIs
     - in some plugins, external media tools bundled in repo, such as **ffmpeg** and **gifski** under `VideoExport.Core`
   - `ILMerge`/MSBuild packaging support is part of the build architecture, indicating that some projects are merged or packaged into release-ready assemblies.

10. **Build and packaging structure**
   - The repository uses multiple `.sln`, `.csproj`, `.shproj`, and `.projitems` files to share code across projects.
   - `Directory.Build.props`, `ILMerge.*`, and `packages.config` files show a centralized build setup for shared dependencies.
   - Release artifacts are assembled per game, and the README points to **CI-built nightly artifacts** and per-game release zips.
   - The repo therefore has a clear separation between **source composition** and **distribution packaging**.

11. **Support tooling and auxiliary apps**
   - `Other/KKImageConverter` and `Other/PackPlugins` are standalone tools rather than studio plugins.
   - They support the ecosystem by converting image assets and packaging releases/profiles.
   - These tools are adjacent to, but architecturally separate from, the runtime plugins.

12. **How to draw the diagram**
   - At the center, place the **running game / studio** and **BepInEx + Harmony** as the host boundary.
   - Around that, show **shared cores** feeding multiple **game-specific plugin assemblies**.
   - From the cores, branch to feature families like pose editing, timeline, rendering, accessories, export, and utility.
   - Add side inputs for **Unity resource bundles**, **BepInEx config**, and **UserData**.
   - Add build/package outputs as **per-game DLL sets and release zips** produced by CI.

Main entry points: [`Directory.Build.props`](https://github.com/illusionmods/hsplugins/blob/main/Directory.Build.props) (Build system), [`Core.PoseEditor`](https://github.com/illusionmods/hsplugins/blob/main/Core.PoseEditor) (Pose core), [`Timeline.Core`](https://github.com/illusionmods/hsplugins/blob/main/Timeline.Core) (Timeline core), [`VideoExport.Core`](https://github.com/illusionmods/hsplugins/blob/main/VideoExport.Core) (Video core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Runtime host"]
  node_game(("Game studio<br/>Unity runtime"))
  node_bepinex["BepInEx<br/>plugin host"]
  node_harmony["Harmony<br/>patching"]
end

subgraph group_shared["Shared cores"]
  node_core_pose["Pose core<br/>feature core<br/>[Core.PoseEditor]"]
  node_timeline_core["Timeline core<br/>feature core<br/>[Timeline.Core]"]
  node_useful_core["UsefulStuff core<br/>feature core<br/>[UsefulStuff.Core]"]
  node_video_core["Video core<br/>feature core<br/>[VideoExport.Core]"]
  node_nodes_core["Node constraints<br/>feature core"]
  node_colliders_core["Colliders debug<br/>feature core"]
end

subgraph group_plugins["Game plugins"]
  node_hspe["HSPE<br/>HS pose plugin"]
  node_multi_pose["Other pose builds<br/>game variants"]
  node_timeline_builds["Timeline builds<br/>game variants"]
  node_video_builds["Video builds<br/>game variants"]
  node_utility_plugins["Utility plugins<br/>plugin family"]
  node_more_accessories["MoreAccessories<br/>accessory plugin"]
end

subgraph group_ui["UI layer"]
  node_toolbox["ToolBox<br/>support lib"]
  node_uiutility["UIUtility<br/>ui lib"]
end

subgraph group_tools["Tools"]
  node_pack_tools["Pack tools<br/>release tools"]
end

subgraph group_build["Build & packaging"]
  node_build_system["Build system<br/>msbuild/merge"]
end

subgraph group_deps["External deps"]
  node_resources[("Bundles & config<br/>runtime assets")]
  node_third_party["ffmpeg/gifski<br/>media tools<br/>[ffmpeg]"]
end

node_game -->|"hosts"| node_bepinex
node_bepinex -->|"enables"| node_harmony
node_bepinex -->|"loads"| node_core_pose
node_bepinex -->|"loads"| node_timeline_core
node_bepinex -->|"loads"| node_useful_core
node_bepinex -->|"loads"| node_video_core
node_bepinex -->|"loads"| node_nodes_core
node_bepinex -->|"loads"| node_colliders_core
node_toolbox -->|"supports"| node_core_pose
node_toolbox -->|"supports"| node_timeline_core
node_uiutility -->|"ui"| node_core_pose
node_uiutility -->|"ui"| node_timeline_core
node_uiutility -->|"ui"| node_utility_plugins
node_core_pose -->|"frontend"| node_hspe
node_core_pose -->|"variants"| node_multi_pose
node_timeline_core -->|"variants"| node_timeline_builds
node_video_core -->|"variants"| node_video_builds
node_useful_core -->|"powers"| node_utility_plugins
node_more_accessories -->|"family"| node_utility_plugins
node_resources -.->|"bundles"| node_hspe
node_resources -.->|"bundles"| node_core_pose
node_resources -.->|"assets"| node_video_core
node_third_party -->|"encodes"| node_video_core
node_build_system -->|"builds"| node_hspe
node_build_system -->|"builds"| node_multi_pose
node_build_system -->|"builds"| node_timeline_builds
node_build_system -->|"builds"| node_video_builds
node_build_system -->|"packages"| node_pack_tools
node_pack_tools -->|"consumes"| node_build_system

click node_core_pose "https://github.com/illusionmods/hsplugins/blob/main/Core.PoseEditor"
click node_timeline_core "https://github.com/illusionmods/hsplugins/blob/main/Timeline.Core"
click node_useful_core "https://github.com/illusionmods/hsplugins/blob/main/UsefulStuff.Core"
click node_video_core "https://github.com/illusionmods/hsplugins/blob/main/VideoExport.Core"
click node_nodes_core "https://github.com/illusionmods/hsplugins/blob/main/NodesConstraints.Core"
click node_colliders_core "https://github.com/illusionmods/hsplugins/blob/main/CollidersDebug.Core"
click node_toolbox "https://github.com/illusionmods/hsplugins/tree/main/ToolBox"
click node_uiutility "https://github.com/illusionmods/hsplugins/tree/main/UIUtility"
click node_hspe "https://github.com/illusionmods/hsplugins/tree/main/HSPE"
click node_more_accessories "https://github.com/illusionmods/hsplugins/tree/main/MoreAccessories"
click node_pack_tools "https://github.com/illusionmods/hsplugins/tree/main/Other/KKImageConverter"
click node_build_system "https://github.com/illusionmods/hsplugins/blob/main/Directory.Build.props"
click node_third_party "https://github.com/illusionmods/hsplugins/blob/main/VideoExport.Core/ffmpeg"

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,node_bepinex,node_harmony,node_resources,node_third_party toneBlue
class node_core_pose,node_timeline_core,node_useful_core,node_video_core,node_nodes_core,node_colliders_core toneAmber
class node_hspe,node_multi_pose,node_timeline_builds,node_video_builds,node_utility_plugins,node_more_accessories toneMint
class node_toolbox,node_uiutility toneRose
class node_pack_tools toneIndigo
class node_build_system toneTeal
```

## Components

### Runtime host

Game studio runtime, BepInEx loading, and Harmony patching boundary

- **Game studio**: Unity runtime · Running Illusion title / studio process that hosts plugins
- **BepInEx**: plugin host · Loads plugin DLLs and configuration at runtime
- **Harmony**: patching · Runtime interception layer used by many plugins

### Shared cores

Reusable assemblies and cross-game feature cores

- [Pose core](https://github.com/illusionmods/hsplugins/blob/main/Core.PoseEditor): feature core · Shared pose editor logic, controllers, and modules · `Core.PoseEditor`
- [Timeline core](https://github.com/illusionmods/hsplugins/blob/main/Timeline.Core): feature core · Shared animation/timeline model and interpolation engine · `Timeline.Core`
- [UsefulStuff core](https://github.com/illusionmods/hsplugins/blob/main/UsefulStuff.Core): feature core · Reusable quality-of-life features and studio helpers · `UsefulStuff.Core`
- [Video core](https://github.com/illusionmods/hsplugins/blob/main/VideoExport.Core): feature core · Screenshot and video export pipeline with encoders · `VideoExport.Core`
- [Node constraints](https://github.com/illusionmods/hsplugins/blob/main/NodesConstraints.Core): feature core · Constraint and camera-event shared core · `NodesConstraints.Core`
- [Colliders debug](https://github.com/illusionmods/hsplugins/blob/main/CollidersDebug.Core): feature core · Shared colliders debugging logic · `CollidersDebug.Core`

### Game plugins

Per-game plugin frontends and compatibility variants

- [HSPE](https://github.com/illusionmods/hsplugins/tree/main/HSPE): HS pose plugin · High-School studio pose editor frontend · `HSPE`
- **Other pose builds**: game variants · HS2PE, KKPE, KKSPE, AIPE per-game pose editor builds
- **Timeline builds**: game variants · Per-game Timeline frontends for HS2, KK, and KKS
- **Video builds**: game variants · Per-game VideoExport frontends for AI, HS2, KK, and KKS
- **Utility plugins**: plugin family · Lighting, rendering, accessories, export, and studio QoL plugins
- [MoreAccessories](https://github.com/illusionmods/hsplugins/tree/main/MoreAccessories): accessory plugin · Accessory extension family with per-game variants and patches · `MoreAccessories`

### UI layer

Shared UI utilities used by many plugins

- [ToolBox](https://github.com/illusionmods/hsplugins/tree/main/ToolBox): support lib · Common extensions, config, translation, and plugin helpers · `ToolBox`
- [UIUtility](https://github.com/illusionmods/hsplugins/tree/main/UIUtility): ui lib · Movable windows, context menus, loop lists, and handlers · `UIUtility`

### Tools

Standalone support applications

- [Pack tools](https://github.com/illusionmods/hsplugins/tree/main/Other/KKImageConverter): release tools · Standalone tools for asset conversion and release packaging · `Other/KKImageConverter`

### Build & packaging

Shared build setup, merge tasks, and release assembly

- [Build system](https://github.com/illusionmods/hsplugins/blob/main/Directory.Build.props): msbuild/merge · Shared props, ILMerge task, CI workflow, and release scripts · `Directory.Build.props`

### External deps

Bundled third-party runtime tools and assets

- **Bundles & config**: runtime assets · Embedded Unity bundles, BepInEx config, and UserData content
- [ffmpeg/gifski](https://github.com/illusionmods/hsplugins/blob/main/VideoExport.Core/ffmpeg): media tools · Bundled external encoders used by video export · `VideoExport.Core/ffmpeg`

## Connections

- Game studio → BepInEx: hosts · Game runtime loads BepInEx plugins
- BepInEx → Harmony: enables · Plugins patch game behavior through Harmony
- BepInEx → Pose core: loads · BepInEx loads shared pose core into the runtime
- BepInEx → Timeline core: loads · Timeline features attach to the runtime through BepInEx
- BepInEx → UsefulStuff core: loads · QoL features are injected as plugins
- BepInEx → Video core: loads · Video export runtime is plugin-driven
- BepInEx → Node constraints: loads · Constraint features run inside the game process
- BepInEx → Colliders debug: loads · Debug tools load as runtime plugins
- ToolBox → Pose core: supports · Shared helpers underpin pose editor implementation
- ToolBox → Timeline core: supports · Common config and translation helpers
- UIUtility → Pose core: ui · Windowing and list widgets used by pose editor
- UIUtility → Timeline core: ui · Shared UI controls for timeline editing
- UIUtility → Utility plugins: ui · Common interaction layer for many frontends
- Pose core → HSPE: frontend · HSPE is the HS-specific wrapper around the shared core
- Pose core → Other pose builds: variants · Shared pose editor core is wrapped for HS2, KK, KKS, and AI
- Timeline core → Timeline builds: variants · Timeline core is packaged for multiple games
- Video core → Video builds: variants · Video export core is wrapped per game
- UsefulStuff core → Utility plugins: powers · Shared QoL feature core feeds studio plugins
- MoreAccessories → Utility plugins: family · Accessory extension family sits beside other utility plugins
- Bundles & config → HSPE: bundles · Plugin-specific Unity bundles and config are loaded at runtime
- Bundles & config → Pose core: bundles · Shared pose editor resources are embedded per game
- Bundles & config → Video core: assets · Runtime uses packaged resources and user content
- ffmpeg/gifski → Video core: encodes · ffmpeg and gifski support export formats
- Build system → HSPE: builds · Centralized props and merge settings produce release DLLs
- Build system → Other pose builds: builds · Shared build setup emits per-game variants
- Build system → Timeline builds: builds · Per-game timeline assemblies are produced from shared sources
- Build system → Video builds: builds · Per-game video export assemblies are packaged
- Build system → Pack tools: packages · CI and packaging utilities assemble release zips
- Pack tools → Build system: consumes · Standalone packer consumes release profiles and archives
