Skip to content

Adding your hack

Jan Bureš edited this page Jan 24, 2024 · 7 revisions

To add your hack, please make a pull request to the dev branch with your changes and an updated README.md with your hack description and attribution.

Hack class format

To make a new hack, put your class into the KerbalLifeHacks.Hack.<YourHackName> namespace and corresponding folder. You have to extend the provided convenience base class KerbalLifeHacks.Hack.BaseHack, which allows you to utilize MonoBehavior life cycle methods like Update(), etc. The base class also provides a Harmony instance HarmonyInstance, a Logger instance and the BindConfigValue method to easily add configuration. Your hack class needs to have the KerbalLifeHacks.Hack.HackAttribute attribute which contains a user-readable name/short description of the fix, and an optional second parameter indicating whether the hack should be enabled by default, for example:

[Hack("My first hack", isEnabledByDefault: false)]
public class MyFirstHack: BaseHack
{ ... }

When extending the BaseHack class, a default empty implementation of the OnInitialized() method is provided which you can override.

If your hack utilizes Harmony patches, you can register them in your OnInitialized() override method like this:

public override void OnInitialized()
{
    HarmonyInstance.PatchAll(typeof(MyHarmonyPatchClass));
}

An on/off toggle setting is automatically defined for your hack in Main Menu->Settings->Mods->Kerbal Life Hacks.

Clone this wiki locally