Mod class
The base class of a mod's entry point. Lustral creates one instance of each mod and calls it on the game's main thread.
public abstract class ModRemarks
Info, Log, Harmony, Config, Events, Coroutines, Assets, Game and Mods are available from the constructor onward. Code outside the class, such as Harmony patches, can access them through a static reference to the instance, as in the project template.
Constructors
Mod()
protected Mod()Properties
Assets
public ModAssets Assets { get; }Loads Unity asset bundles shipped with the mod, on both Mono and IL2CPP: Assets.LoadBundle("Assets/ui.bundle"). Paths are relative to the mod's folder. Bundles can be loaded from OnGameReady onward.
Config
public ModConfig Config { get; }The mod's settings file, Lustral/config/<id>.toml: Config.Bind<Settings>().
Coroutines
public Coroutines Coroutines { get; }The mod's coroutines, which behave identically on Mono and IL2CPP: Coroutines.Start(Fade()). A coroutine is an iterator method that yields null, Wait values, other iterators or Unity yield instructions.
Events
public GameEvents Events { get; }Scene and frame events.
Game
public GameInfo Game { get; }The game's name, developer, version, Unity version, scripting backend and folder.
Harmony
public Harmony Harmony { get; }A Harmony instance identified by the mod's ID: Harmony.PatchAll(typeof(MyMod).Assembly). If the mod fails to load, Lustral removes the patches applied through this instance. Crash reports use it to identify the mod that patched each method.
Info
public ModInfo Info { get; }The mod's ID, name, version and folder, as declared in its manifest.
Log
public ILog Log { get; }The mod's log. Messages are tagged with the mod's ID and may contain Unity rich text tags (see ILog).
Mods
public LoadedMods Mods { get; }The mods loaded so far, in load order: Mods.IsLoaded("other.mod"). Dependencies and optional dependencies are loaded before the mods that depend on them, so an installed optional dependency is always in this list.
Methods
OnGameReady()
public virtual void OnGameReady();Called once, after the game's first scene has loaded. Unity APIs can be used from this point on.
OnLoad()
public virtual void OnLoad();Called once, before the game loads its first scene. Apply Harmony patches here. Unity APIs cannot be used yet.
OnShutdown()
public virtual void OnShutdown();Called once when the game quits. Limit the work to short tasks such as saving state and closing files.