Skip to content

Events

Used to listen to various events in the game

Unity lifecycle-related events

Fires the given action on the next Update stage of the lifecycle.

public class MyCoolMod : ModBehaviour {
    public void Start() {
        ModHelper.Events.Unity.FireOnNextUpdate(() => {
            ModHelper.Console.WriteLine("This logs 1 update later!");
        });
    }
}

Fires the given action after N Updates have passed

public class MyCoolMod : ModBehaviour {
    public void Start() {
        ModHelper.Events.Unity.FireInNUpdates(() => {
            ModHelper.Console.WriteLine("This logs 10 updates later!");
        }, 10);
    }
}

Keeps checking the given predicate and fires the given action when the predicate is true.

public class MyCoolMod : ModBehaviour {

    public bool Check() {
        return EntitlementsManager.IsDlcOwned() != EntitlementsManager.AsyncOwnershipStatus.NotReady;
    }

    public void Start() {
        ModHelper.Events.Unity.RunWhen(Check, () => {
            var ownsDLC = EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned? "does" : "doesn't";
            ModHelper.Console.WriteLine($"The player {ownsDLC} own the DLC!");
        });
    }
}