Table of Contents

Interface IMod

Namespace
GrindFest
Assembly
GrindFest.dll

Entry point for native C# mods (D12). The game compiles every mod's Scripts/*.cs into an in-memory assembly, then instantiates each IMod implementation and calls OnLoad(ModDefinition) once, in mod load order, before the story/world is generated.

Mod code references the whole game assembly and runs in the same process — a mod has the game's full power (scripts are vetted by the security scan / trust store before compilation). An entry point that throws is logged and skipped; it never takes the boot down with it.

public interface IMod

Examples

using GrindFest;

public class MyMod : IMod
{
    public void OnLoad(ModDefinition mod)
    {
        UnityEngine.Debug.Log($"Hello from {mod.Name} {mod.Version}");
    }

    // Optional: both lifecycle methods have empty defaults.
    public void OnContentLoaded() { /* every package merged — resolve cross-mod ids here */ }
    public void OnUnload() { /* unsubscribed: release what OnLoad/OnContentLoaded acquired */ }
}

Methods

OnContentLoaded()

Called after every successful content load — the boot load and each hot reload alike. This is the moment content is guaranteed merged: resolve cross-mod definitions here (ContentDB.Get, NeedsBake, patch expectations), because OnLoad(ModDefinition) may run before packages merge. Optional — the default implementation does nothing.

OnLoad(ModDefinition)

Called once during boot: all mods are discovered, scripts are compiled and content packages are registered, but the world has not been generated yet — the right moment to subscribe to events and register anything world generation must see.

OnUnload()

Called when this mod disappears from the active set (unsubscribed / folder removed) while the game is running. Release what OnLoad(ModDefinition)/OnContentLoaded() acquired. An unsubscribed mod's assembly cannot be unloaded — code already scheduled elsewhere keeps running until the next boot; this hook is the cooperative half of that limitation. Optional — the default does nothing.