javisar / ONI-Modloader

A modloader for Oxygen Not Included
MIT License
72 stars 25 forks source link

ONI-Modloader

A simple mod loader for Oxygen Not Included based in Harmony

Forums in Klei

Disclaimers

This project uses source code of and is based on: Harmony, ModLoader Installer, Besiege Modloader, OnionPatcher

NOTE: Tested on LU-361684

Report Bugs for ONI-Modloader here: https://github.com/javisar/ONI-Modloader/issues

Mods based in Harmony

For Mod Request to the Community post them in Klei Forums For ONI-Modloader feature request post them in ModLoader GitHub.

Quick Start

ONI-Modloader

  1. Download the Latest Version
  2. Copy ModLoader.dll to ONI Managed folder:
    • Windows: \OxygenNotIncluded\OxygenNotIncluded_Data\Managed\
    • Mac: /OxygenNotIncluded/OxygenNotIncluded.app/Contents/Resources/Data/Managed/
  3. Move your mods to the Mods folder:
    • Windows: \OxygenNotIncluded\Mods\
    • Mac: /OxygenNotIncluded/OxygenNotIncluded.app/Contents/Resources/Mods/
  4. Start your game and check for logs in output_log.txt or Player.log.

ONI builtin Modloader (Steam)

  1. If you want to use instead the ONI builtin modloader (used for Steam), you have to remove 'ModLoader.dll' from 'Managed' folder. If ONI detects a modloader, it bypasses Steam mods.
  2. Move your mods to the Mods folder. Be sure that you put each mod in its own folder:
    • Windows: %USERPROFILE%\Documents\Klei\OxygenNotIncluded\mods\dev\
    • Mac: ???
  3. Start your game and check for logs in output_log.txt or Player.log.

How it works

Installation

ONI-Modloader

  1. Prerequisites:
    • Make SURE you're using the latest version from Github main branch.
    • Make SURE you're using a fresh install of ONI. Check Verify Integrity Files function in Steam in the ONI game Properties>LocalFiles tab.
    • Make sure you deleted all previous modloader file in:
      • Windows: \OxygenNotIncluded\OxygenNotIncluded_Data\Managed\
      • Mac: /OxygenNotIncluded/OxygenNotIncluded.app/Contents/Resources/Data/Managed/
  2. Click "Clone or Download" and "Download ZIP" for the current version as the releases may not be up to date.
  3. Copy the contents of the "Managed" folder to the folder:
    • Windows: \OxygenNotIncluded\OxygenNotIncluded_Data\Managed\
    • Mac: /OxygenNotIncluded/OxygenNotIncluded.app/Contents/Resources/Data/Managed/
  4. Create "Mods" folder in the ONI main directory.
    • Windows: \OxygenNotIncluded\Mods\
    • Mac: /OxygenNotIncluded/OxygenNotIncluded.app/Contents/Resources/Mods/
  5. Check for error logs in:
    • \OxygenNotIncluded\OxygenNotIncluded_Data\Managed\Mod_Log.txt

Uninstallation

Remove ModLoader.dll from \OxygenNotIncluded\OxygenNotIncluded_Data\Managed\ folder.

Mods Installation

Requirements

Creating a Mod

  1. Feel free to mess with any of the mods from https://github.com/javisar/ONI-Modloader-Mods
  2. 'Clone or download' the project from the mod repo.
  3. Copy the following files from ONI Managed folder '\OxygenNotIncluded\OxygenNotIncluded_Data\Managed' to the mod solution folder '\Source\lib\'
    • UnityEngine.dll
    • UnityEngine.CoreModule.dll
    • Any needed unity UnityEngine.*.dll
    • Any needed ONI Assembly-CSharp-*.dll
  4. Open the solution with Visual Studio.
  5. Create a new class project.
    • To create a Project from scratch the right one is: Visual C#-Class Library (.NET Framework).
    • If you don't find it like when you have installed Visual Studio with Unity you need to tools-add tools or features and install: .NET Desktop Development.
    • It's available a Visual Studio Project Template
      • Copy the .zip file to ~\Documents\Visual Studio 2019\Templates\ProjectTemplates\Visual C# to access the template in VS
  6. Add the previous libs as references of the project.
  7. Compile it to generate the mod dll file.
  8. Test your mod. Move you mod folder to: a. ONI-Modloader
    • Windows: %PROGRAMFILES(X86)%\Steam\steamapps\common\OxygenNotIncluded\Mods\
    • Mac: /OxygenNotIncluded/OxygenNotIncluded.app/Contents/Resources/Mods/ b. ONI Builtin Modloader (Steam)
    • Windows: %USERPROFILE%\Documents\Klei\OxygenNotIncluded\mods\local\
    • Mac: ???
  9. Check the tutorials at the end of the page.
    • Harmony is a code injector which will help you to inject your .dll with the help of the modloader.
  10. If you want to go into the ONI code you need to peek with a decompiler like JetBrains dotPeek or ILSpy.
  11. If you need more help please ask at The Discord Server in the Modding Channel

Note: Dlls will be recognized by the mod loader if they reside in the main mod directory and subfolders.

How to debug mods

SIMPLE (recommended) The easier way to debug a mod is to use the Unity debug logs:

ADVANCED

Tutorials

Downloads

Choose 'Clone or Download'.