How dual-iron/rwmodloader works
Purpose and deployment
Realm is a Rain World mod loader and in-game mod manager. It installs a BepInEx-based bootstrap into the game, then provides runtime loading, browser-based installation, and in-game reload support. The bundled deployment payload is under RwBep/, including BepInEx and Doorstop configuration (RwBep/BepInEx/, RwBep/doorstop_config.ini).
Executable entry points
Two C# applications form the system:
• Installer/backend CLI: Backend/Program.cs orchestrates installation, extraction, patching, downloads, and self-update behavior; its project is Backend/Backend.csproj.
• In-game Realm plugin/runtime: Realm/Program.cs and Realm/EntryPoint.cs initialize Realm inside Rain World through BepInEx. Realm/BackendProcess.cs bridges runtime UI actions to backend work.
Installation and game integration
The backend installs Realm assets, manipulates the game environment, and patches assemblies needed for compatibility:
• Archive/file installation pipeline: Backend/IO/RealmInstaller.cs, Backend/IO/Extractor.cs, Backend/IO/Wrapper.cs.
• Assembly transformation and metadata resolution: Backend/Patching/AssemblyPatcher.cs, Backend/Patching/LegacyReferenceTransformer.cs, Backend/Patching/RwMetadataResolver.cs.
• BepInEx/Unity process bootstrap is external infrastructure bundled at RwBep/BepInEx/; Realm itself is injected into the game process rather than serving HTTP.
Mod ingestion, persistence, and reload
Realm/ModLoading/ModLoader.cs is the central mod lifecycle coordinator. It discovers locally supplied .zip, .dll, or directory-based mods, reads Realm mod metadata, applies preferences, and refreshes mod state. Key boundaries are:
• Realm mod formats and headers: Realm/ModLoading/RwmodFile.cs, Realm/ModLoading/RwmodFileHeader.cs.
• Shared archive implementation: Global/IO/RwmodIO.cs, Global/IO/RwmodHeader.cs.
• Reload safety and game fixes: Realm/AssemblyLoading/ReloadFixes.cs, Realm/ModLoading/VanillaFixes.cs.
Dynamic assembly loading
Realm owns a custom assembly lifecycle rather than relying solely on default .NET loading. Assembly descriptors and pools track candidate, loaded, and reloadable mod assemblies:
Realm/AssemblyLoading/AssemblyPool.cs, Realm/AssemblyLoading/LoadedAssemblyPool.cs, and Realm/AssemblyLoading/LoadedModAssembly.cs.
This layer isolates mod code from the loader’s state management and enables in-game activation/reload, with known compatibility limitations for some mods.
In-game management UI
The runtime injects menus into Rain World for local mod management and remote browsing. Realm/Gui/Gui.cs provides UI coordination; menu hooks attach to the game through Realm/Gui/Menus/ModMenuHooks.cs. Primary surfaces are local mods (Realm/Gui/Menus/LocalMods.cs) and the browser (Realm/Gui/Menus/Browser.cs), with progress/warning presentation handled by Realm/Logging/Progressable.cs and Realm/Gui/Warnings/.
Remote release and browser services
The backend/runtime can retrieve release and mod-browser data over the network. The web boundary consists of download/cache/release/update concerns in Backend/Web/Downloader.cs, Backend/Web/Cache.cs, Backend/Web/Release.cs, and Backend/Web/SelfUpdater.cs. Browser UI downloads are asynchronous via Realm/Gui/AsyncDownload.cs; submitted browser content is associated externally with the rdb-client ecosystem mentioned in the README.
Shared runtime primitives
Global/ contains cross-project contracts for results, semantic versions, temporary resources, and archive streams (Global/Result.cs, Global/SemVer.cs, Global/IO/SpliceStream.cs). Realm also supplies custom background job abstractions for non-blocking UI/download/loading work in Realm/Threading/BackgroundThread.cs, Realm/Threading/Job.cs, and Realm/Threading/Task.cs. VirtualEnums/ is a separate extension library for safely expanding game enum-like behavior (VirtualEnums/EnumExtender.cs, VirtualEnums/VirtualEnums.Impl.cs).
Main entry points: EntryPoint.cs Realm plugin entry · ModLoader.cs Mod loader · Program.cs Backend CLI · Gui.cs In-game UI
Components 21
Installer backend
CLI installation and release operations.
- Backend CLI · Orchestrates install, patch, download, and self-update actions.
Backend/Program.cs - Install pipeline · Installs, extracts, and wraps Realm assets.
Backend/IO/RealmInstaller.cs - Assembly patcher · Patches game assemblies with legacy-reference and metadata support.
Backend/Patching/AssemblyPatcher.cs - Release services · Downloads, caches, resolves releases, and self-updates.
Backend/Web/Downloader.cs
Realm runtime
In-game plugin, loading lifecycle, and UI.
- Realm plugin entry · Initializes Realm inside the Rain World process.
Realm/EntryPoint.cs - Backend process bridge · Connects in-game actions to backend work.
Realm/BackendProcess.cs - Mod loader · Discovers mods, applies preferences, and refreshes state.
Realm/ModLoading/ModLoader.cs - Realm mod formats · Defines Realm mod files and headers.
Realm/ModLoading/RwmodFile.cs - Assembly lifecycle · Tracks candidate, loaded, and reloadable mod assemblies.
Realm/AssemblyLoading/AssemblyPool.cs - Reload safety · Applies reload and vanilla-game fixes.
Realm/AssemblyLoading/ReloadFixes.cs - In-game UI · Coordinates Realm management menus.
Realm/Gui/Gui.cs - Menu hooks · Attaches Realm menus to Rain World.
Realm/Gui/Menus/ModMenuHooks.cs - Local mods UI
Realm/Gui/Menus/LocalMods.cs - Browser UI
Realm/Gui/Menus/Browser.cs - Async downloads · Keeps browser downloads non-blocking.
Realm/Gui/AsyncDownload.cs - Background jobs · Runs loading and download work off the UI path.
Realm/Threading/BackgroundThread.cs
Shared libraries
Cross-project primitives and extensions.
- Archive I/O · Implements shared rwmod archive and header handling.
Global/IO/RwmodIO.cs - Shared primitives · Provides results, versions, temporary resources, and streams.
Global/Result.cs - Virtual enums · Safely expands game enum-like behavior.
VirtualEnums/EnumExtender.cs
Game bootstrap
Bundled and host-process integration boundary.
- BepInEx bootstrap · Bootstraps Realm injection into the Unity game process.
- Rain World
Connections 26
- Backend CLI → Install pipeline: runs
- Backend CLI → Assembly patcher: invokes
- Backend CLI → Release services: uses
- Install pipeline → BepInEx bootstrap: installs payload
- Assembly patcher → Rain World: patches assemblies
- BepInEx bootstrap → Rain World: bootstraps
- BepInEx bootstrap → Realm plugin entry: loads
- Realm plugin entry → Mod loader: initializes
- Realm plugin entry → In-game UI: initializes
- Realm plugin entry → Backend process bridge: uses
- Mod loader → Realm mod formats: reads metadata
- Realm mod formats → Archive I/O: uses
- Mod loader → Assembly lifecycle: activates and reloads
- Mod loader → Reload safety: applies fixes
- Mod loader → Background jobs: schedules work
- In-game UI → Menu hooks: injects through
- Menu hooks → Rain World: attaches menus
- In-game UI → Local mods UI: hosts
- In-game UI → Browser UI: hosts
- Browser UI → Async downloads: starts
- Async downloads → Background jobs: runs on
- Async downloads → Release services: retrieves content
- Backend process bridge → Backend CLI: delegates actions
- Realm plugin entry → Virtual enums: uses
- Backend CLI → Shared primitives: uses
- Realm plugin entry → Shared primitives: uses