How daxcess/lcvr works
Project Type and Purpose
• This is a game mod designed to provide VR support (hand movement, motion-based controls, etc.) for Lethal Company.
• It leverages BepInEx as the mod loader and uses Unity’s OpenXR plugin so that it works with various VR headsets and controllers.
• It must interact seamlessly with the vanilla game (even supporting multiplayer with non-VR players) and includes code for input handling, patching various game components, networking, and UI.
Key Components
a. BepInEx Mod Loader Environment:
– Represent BepInEx as the entry point for the mod. Indicate its role in loading both “LCVR.dll” (the main mod assembly) and “LCVR.Preload.dll” (located in the Preloader folder) at startup.
– Show BepInEx’s internal “plugins” and “patchers” directories where these assemblies and runtime dependencies are placed.
b. Preloader Component:
– This is found under the Preloader directory and is critical for early initialization. It sets up environment configurations (like patching or loading runtime-necessary DLLs such as openxr_loader.dll and UnityOpenXR.dll).
c. Core Mod Components (Inside the “Source” Directory):
– Group the different namespaces/modules as independent components. For example:
• Input: Contains various scripts for handling VR input (e.g., actions, key remapping, finger curler, turning providers).
• Networking: Manages multiplayer compatibility (modules like Channel, NetworkSystem, etc.).
• Patches: A large group containing multiple subcomponents (BuildingPatches, CameraPatches, CarPatches, etc.) that modify the base game’s behavior through Harmony patching.
• Items: Custom VR items (VRBeltBagItem, VRKnife, etc.) with each file handling behavior for specific items.
• UI: Contains classes for VR UI elements (MainMenu, VRHUD, Keyboard, Settings, etc.).
• Physics: Manages interactions within the game world (e.g., Car interactions, Door, ElevatorButton, etc.).
• Other Utility Modules: Logger, Compatibility, Experiments, and ThirdParty integrations (like the MRTK support scripts).
d. External Dependencies and Runtime Libraries:
– Make note of external DLLs that are essential for VR functionality (UnityEngine.SpatialTracking.dll, Unity.XR.CoreUtils.dll, etc.).
e. Asset Bundle:
– Represent the asset bundle (named “lethalcompanyvr”) that supplies game assets essential for the mod’s functionality.
Showing Relationships and Data Flow
– Begin with the BepInEx mod loader, which then loads the Preloader.
– The Preloader initializes the runtime environment (load runtime DLLs, set up OpenXR) and then passes control to the main mod code (LCVR.dll).
Architectural Patterns and Design Principles
• Modularity: The code is highly modular with specialized folders for distinct functionalities (input, patches, items, UI).
• Patching and AOP: The widespread use of patch files (grouped in Source/Patches) implies an aspect-oriented approach to modify the game on the fly.
• Dependency on External Systems: There is a clear dependency on Unity’s OpenXR and BepInEx, which is important to highlight for understanding integration points.