LethalLevelLoader
Overview
LethalLevelLoader is a custom API mod to support the development, loading and integration of custom content for the Unity game Lethal Company, created by Zeekerss. The project utilizes Harmony X to patch the games assemblies at runtime in order to manipulate and modify the codebase to support the seamless injection of custom community content at runtime.
Development of the project started in December 2023 and was initially released in early January. As of March the project is now the predominant custom level loading API for the game, sitting at over three million downloads with over thirty publicly released projects utilizing the API.
Intent
As someone coming from a background in game design, The overall goal of LethalLevelLoader was to create an API that loads and integrates custom content in streamlined, documented and unrestricted process that would satisfy the needs of developers creating and iterating on custom content without them having to unnecessarily create custom code in order to load their creations. A streamlined API like this also allows all custom content to be loaded in consistent manor, improving overall stability and compatibility with other mods.
Utilizing Unity's AssetBundle system, Content creation with LethalLevelLoader is done by decompiling the game with a third party tool that imports the contents of the game into a fresh Unity Project in a playable state. From there authors can create new levels (moons and dungeons) with the exact same setup the base-game content was made with, including the same scripts, prefab and scene formatting, all within Unity. The ability to create custom content in a near identical way was a core design goal of LethalLevelLoader to improve long term compatibility with base-game updates and to allow authors to use base-game content as a direct learning resource for how they can create their own content.
Implementation
In order to create an API like this, I had to gain an understanding of how the base-game codebase functions and to identify the best places in the systems to inject my custom code in to make quick, clean and compatible changes to the game. This was primarily done by decompiling the base-game with DNSpy, Which provided me with a readable copy of the code which I constantly studied. For more intricate aspects of the game, I created rough diagrams in draw.io to visualize the order of execution of certain events, to gain a stronger understanding of what is affecting certain systems at various points. These were particularly critical in ensuring the integration of custom content would be correctly synced over the network when relevant.
The actual manipulation of the base-game's code is done utilising Harmony X. This allows me to target functions in specific classes in the game and run custom C# code before or after the execution of said function in the form of Prefix and Postfix patches. This can additionally manipulate data that is going to be passed into the original function and data that the original function intends to return, as well as prevent the original function from running all together. When necessary, I utilise a Transpiler in order to manipulate the contents of base-game function directly, via modifying aspects of the compiled IL Code.
Release
The initial release of the project created a large influx of authors and players using the project, Which created a massive amount of feedback that I needed to prioritize, respond to, document, consider and implement in future updates. A lot of these suggestions required a lot of back and forth communication in order to understand the root of the issues, so I could provide the best possible solution available. My time spent implementing said feedback also had to be prioritized between catering to the authors creating content with my API, as well as features and issues affecting the users playing the content made using my API.
In order to document, organize and update all the feedback I was receiving, I used Trello to create categorized tickets, using levels of priority and separating issues with pre-existing features and suggestions for new features. This was essential in keeping track of user needs and visualizing what the upcoming release included while also being simple and lightweight to actively manage.
Shortly after release, I have also been in active development of a companion tool, LethalToolkit, This is a editor tool package for the Unity Engine with the intent of improving the development pipeline for custom content, providing validation tools and custom AssetBundle building options tailor made for making content for Lethal Company. These tools are made using the IMGUI systems Unity provides, in the form of In-Scene Gizmos and Editor Windows.
.
Overall I'm extremely satisfied with how the project has been since release and the amount I have learned while working on it. The amount of positive feedback I've received has been quite overwhelming and has really pushed me to keep improving the project to support the amount of authors and users who are utilizing my work. Working on top of a pre-existing codebase while also ensuring my work is compatible with other peoples mods has truly pushed me into ensuring my code is readable, concise, safe and executed at the right time and communicating with developers utilizing my API as well as developers who are not to ensure the modded experience is as polished as possible while also catering to everyone's needs has been a massive undertaking that has massively improved my communication, organisation, adaptability and overall development skills.
Credits
Zeekerss (For creating the fantastic game this mod is built for)
Evaisa (This Mod is directly based from LethalLib's codebase and could have been made without it's pre-existing foundations.)
SkullCrusher (This Mod is directly based from SkullCrusher's LethalLib' Fork and could have been made without it's pre-existing foundations.)
HolographicWings (This Mod was inspired by LethalExpansion and could not have been made without HolographicWing's support and research.)
KayNetsua (This Mod was internally tested using KayNetsua's "E Gypt" Custom Level and KayNetsua assisted in testing LethalLevelLoader's usage)
Badhamknibbs (This Mod was internally tested using Badhamknibb's "SCP Foundation" Custom Dungeon and Badhamknibb's assisted in testing LethalLevelLoader's usage)
Scoopy (This Mod was internally tested using Scoopy's "LethalExtension Castle" Custom Dungeon and Scoopy assisted in testing LethalLevelLoader's usage)
Xilo (Xilo provided multiple instances of Bepinex & Unity.Netcode related support during the development of this Mod.)
Lordfirespeed (Lordfirespeed provided multiple instances of Bepinex & Unity.Netcode related support during the development of this Mod.)
onionymous (Onionymous provided a preview build of their Networked Scene Patcher API, allowing for dynamic, networked scene injection)
Game-Icons.net (For the artwork used for the mod's logo)