How k073l/localmultiplayer works
Project type and purpose
• This is a game-mod plugin project (“Local Multiplayer”) built on MelonLoader. It injects networking and UI/audio patches into an existing game (“Schedule I”) to enable local multiplayer (host/join) on a single machine.
File structure
• Top-level:
• LocalMultiplayer.sln – Visual Studio solution
• LocalMultiplayer/LocalMultiplayer.csproj – C# project for the mod
• LocalMultiplayer/Plugin.cs – entry point (IMelonMod)
• LocalMultiplayer/AudioComponent.cs & MenuComponent.cs – feature modules
• LocalMultiplayer/Patches/*.cs – Harmony/Melon patches into game methods
• build/ – MSBuild props, targets, pre/post-build scripts for IL2CPP vs Mono branches
• libs/ – any third-party DLLs if provided
• Build uses custom .props and .targets to pick the right MelonLoader runtime (Mono or IL2CPP).
Extract insights from the README
• Core functionality:
• Hosts or joins a game over port 7777
• Flags for window adjustments and offsets
• Auto-selection of last played or first save for hosting/joining
Main components
a. Game Process Instances
– Two separate “Schedule I.exe” processes (Host & Join)
b. MelonLoader Runtime
– .NET trampoline for injecting the plugin into each game instance
c. LocalMultiplayer Plugin
– Plugin.cs (initialization, command-line flag parsing)
– Patches (MultipassInitializePatch, SettingsApplyDisplaySettingsPatch)
– Components (MenuComponent, AudioComponent)
– Networking layer (host server or join client using TCP/UDP on port 7777)
d. External Dependencies
– MelonLoader (Mono or IL2CPP)
– Game engine (unmodified Schedule I code)
– OS windowing for window size/position adjustments
e. Build System
– MSBuild solution, build targets, pre/post-build events
Relationships and interactions
• At startup, Schedule I.exe launches under MelonLoader → plugin is loaded → Plugin.OnInitialize() reads CLI flags → applies patches to game methods.
• Host instance opens a listening socket on port 7777 → waits for client.
• Join instance attempts connection to localhost:7777 → on success, synchronizes game state via patched game loops.
• MenuComponent displays host/join UI overlay, AudioComponent routes audio events between instances.
• Settings patches adjust window position/size per flag.
Architectural patterns & design principles
• Plugin/injection architecture: decouples mod from game internals via MelonLoader hooks
• Separation of concerns:
• Plugin.cs for life-cycle and flag parsing
• Patch classes for IL weaving (method interception)
• Component classes for UI/audio feature logic
• Build scripts abstract platform differences (IL2CPP vs Mono)
• Event-driven communication: networking code responds to game events patched at key points.
Elements
• Clear labels for each block (e.g., “MelonLoader Runtime,” “MultipassInitializePatch,” “Networking”)
• From Initialization → Patch injection → Game engine
• Between Host and Join through the TCP/UDP socket
• From CLI flags → Plugin initialization
• Blue = Plugin core
• Green = Patches
• Orange = Feature components (UI/Audio)
• Gray = External systems (Game, MelonLoader, OS, Network)