# imcanida/propstealth architecture

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

- Interactive diagram: https://gitdiagram.com/imcanida/propstealth
- Repository: https://github.com/imcanida/propstealth

## Overview

##### Project Type and Purpose
- PropStealth is a Unity game mod/plugin that transforms the player into a prop when crouching.
- It uses the BepInEx mod loader and Harmony patching to hook into the game’s runtime.

##### File Structure
- Top-level solution and project (`PropStealth.sln`, `PropStealth/PropStealth.csproj`).
- `libraries/` folder with external dependencies (BepInEx, Unity debugging tools).
- `PropStealth/` contains subfolders:
- `Config` (configuration logic)
- `Hooks` (Harmony patches for runtime events)
- `Managers` (runtime managers, e.g., AssetManager)
- `Models` (data models for assets)
- `Utils` (helper classes)
- `AssetsEmbedded` (embedded asset bundles)
- `publish.ps1` script for packaging or deployment.

##### README
- Confirms the sole feature: “When you crouch you turn into a prop.”

##### Main Components
a. External Systems
- Unity Game Engine (host application)
- BepInEx Mod Loader
- Harmony Patching Library
b. PropStealth Plugin
- Entry Point (`Main.cs`)
- Configuration Module (`Config/AssetConfig.cs`)
- Hook Module (`Hooks/PlayerSetCrouch.cs`)
- Asset Management (`Managers/AssetManager.cs`)
- Data Models (`Models/AssetPrefabToLoad.cs`)
- Utility Helpers (`Utils/*.cs`)
- Embedded Assets (`AssetsEmbedded/propstealth`)
c. Build & Deployment
- `publish.ps1` and project files (`.csproj`, `packages.config`)

##### Relationships and Interactions
- On Unity startup, BepInEx Preloader loads Harmony and PropStealth plugin.
- `Main.cs` registers hooks via Harmony.
- When the player crouches, `PlayerSetCrouch` hook intercepts the event.
- Hook calls into `AssetManager` to select and load the correct prop prefab.
- `AssetManager` uses `AssetConfig` to determine which asset bundle to use.
- `Utils` classes handle JSON parsing, persistence, and Unity API calls.
- The selected prefab is instantiated via Unity’s API, replacing the player model.

##### Architectural Patterns
- Modular separation: Config, Hooks, Managers, Models, Utils.
- Observer/Hook pattern via Harmony for event interception.
- Asset bundle loading for dynamic content.

##### Technologies & Frameworks
- C#, .NET Framework (via `.csproj` and `app.config`)
- Unity Engine (runtime host)
- BepInEx (mod loader)
- Harmony (runtime method patching)

## Diagram (Mermaid)

```mermaid
flowchart BT
    %% Layer 1: Host Engine
    subgraph "Layer 1: Host Engine"
        UnityEngine["Unity Game Engine"]:::external
    end

    %% Layer 2: Mod Loader & Patching
    subgraph "Layer 2: Mod Loader & Patching"
        BepInEx["BepInEx Mod Loader"]:::external
        Harmony["Harmony Patching Library"]:::external
    end

    %% Layer 3: PropStealth Plugin
    subgraph "Layer 3: PropStealth Plugin"
        Main["Main.cs"]:::core
        subgraph "Config Module"
            AssetConfig["AssetConfig.cs"]:::data
        end
        subgraph "Hooks Module"
            CrouchHook["PlayerSetCrouch.cs"]:::core
        end
        subgraph "Managers"
            AssetManager["AssetManager.cs"]:::core
        end
        subgraph "Models"
            AssetModel["AssetPrefabToLoad.cs"]:::data
        end
        subgraph "Utils"
            ABLoad["AssetBundleToLoad.cs"]:::util
            GameHelpers["GameHelpers.cs"]:::util
            JsonExt["JsonExtension.cs"]:::util
            Persist["PersistanceHelper.cs"]:::util
            PrefabLoad["PrefabToLoad.cs"]:::util
            UnityHelpers["UnityHelpers.cs"]:::util
        end
    end

    %% Layer 4: Assets & Configuration
    subgraph "Layer 4: Assets & Configuration"
        BundleStorage["propstealth (Asset Bundle)"]:::data
        publish["publish.ps1"]:::build
        csproj["PropStealth.csproj"]:::build
        packages["packages.config"]:::build
        appconfig["app.config"]:::build
        solution["PropStealth.sln"]:::build
    end

    %% Connections
    UnityEngine --> BepInEx
    BepInEx --> Harmony
    Harmony -->|"RegisterHook"| Main
    Main -->|"uses"| AssetConfig
    Main -->|"registers"| CrouchHook
    CrouchHook -->|"calls"| AssetManager
    AssetManager -->|"lookup"| AssetConfig
    AssetManager -->|"reads model"| AssetModel
    AssetManager -->|"instantiates via Unity API"| UnityEngine
    AssetConfig -.->|"points to"| BundleStorage
    AssetModel -->|"defines data for"| BundleStorage
    JsonExt -.-> AssetConfig
    Persist -.-> AssetConfig
    GameHelpers -.-> UnityEngine
    UnityHelpers -.-> UnityEngine
    PrefabLoad -.-> AssetManager
    ABLoad -.-> AssetManager
    publish --> csproj
    publish --> packages
    publish --> appconfig
    csproj --> solution
    packages --> solution
    appconfig --> solution

    %% Click Events
    click UnityEngine "https://github.com/imcanida/propstealth/tree/main/libraries/Unity"
    click BepInEx "https://github.com/imcanida/propstealth/tree/main/libraries/BepInEx"
    click Harmony "https://github.com/imcanida/propstealth/blob/main/libraries/BepInEx/BepInEx.Harmony.xml"
    click Main "https://github.com/imcanida/propstealth/blob/main/PropStealth/Main.cs"
    click AssetConfig "https://github.com/imcanida/propstealth/blob/main/PropStealth/Config/AssetConfig.cs"
    click CrouchHook "https://github.com/imcanida/propstealth/blob/main/PropStealth/Hooks/PlayerSetCrouch.cs"
    click AssetManager "https://github.com/imcanida/propstealth/blob/main/PropStealth/Managers/AssetManager.cs"
    click AssetModel "https://github.com/imcanida/propstealth/blob/main/PropStealth/Models/AssetPrefabToLoad.cs"
    click ABLoad "https://github.com/imcanida/propstealth/blob/main/PropStealth/Utils/AssetBundleToLoad.cs"
    click GameHelpers "https://github.com/imcanida/propstealth/blob/main/PropStealth/Utils/GameHelpers.cs"
    click JsonExt "https://github.com/imcanida/propstealth/blob/main/PropStealth/Utils/JsonExtension.cs"
    click Persist "https://github.com/imcanida/propstealth/blob/main/PropStealth/Utils/PersistanceHelper.cs"
    click PrefabLoad "https://github.com/imcanida/propstealth/blob/main/PropStealth/Utils/PrefabToLoad.cs"
    click UnityHelpers "https://github.com/imcanida/propstealth/blob/main/PropStealth/Utils/UnityHelpers.cs"
    click BundleStorage "https://github.com/imcanida/propstealth/tree/main/PropStealth/AssetsEmbedded/propstealth"
    click publish "https://github.com/imcanida/propstealth/blob/main/publish.ps1"
    click csproj "https://github.com/imcanida/propstealth/blob/main/PropStealth/PropStealth.csproj"
    click packages "https://github.com/imcanida/propstealth/blob/main/PropStealth/packages.config"
    click appconfig "https://github.com/imcanida/propstealth/blob/main/PropStealth/app.config"
    click solution "https://github.com/imcanida/propstealth/blob/main/PropStealth.sln"

    %% Styles
    classDef external fill:#87CEFA,stroke:#000,stroke-width:1px
    classDef core fill:#98FB98,stroke:#000,stroke-width:1px
    classDef data fill:#FFD700,stroke:#000,stroke-width:1px
    classDef util fill:#FFFACD,stroke:#000,stroke-width:1px
    classDef build fill:#F0E68C,stroke:#000,stroke-width:1px
```
