Skip to documentation
LITHIUM
Guide 05Experimental

Connect addons through named boundaries.

Lithium's experimental event API discovers callable endpoints and listeners in the active scene without direct references between packages.

Experimental surface

Event is usable but remains an experimental contract. Names and signatures must match at runtime, so keep event names centralized and cover cross-addon calls with tests.

Emit and listen

Listener marks a Component instance method or static method. Emit invokes every matching listener and returns the number that completed successfully.

InventoryEvents.cs
using Lithium.Core;

public sealed class InventorySignals : Component
{
    [Event.Listener("inventory.changed")]
    private void OnInventoryChanged(int slotCount)
    {
        Log.Info($"Inventory now has {slotCount} slots");
    }

    public void Notify(int slotCount)
    {
        Event.Emit("inventory.changed", slotCount);
    }
}

Call a named endpoint

Callable exposes one endpoint by name. Call<T> returns the first match and casts the result; TryCall lets the caller handle a missing endpoint without an exception.

EconomyEndpoint.cs
using Lithium.Core;

public static class EconomyEndpoint
{
    [Event.Callable("economy.balance")]
    public static int GetBalance(string playerId)
    {
        return 250;
    }
}

var balance = Event.Call<int>(
    "economy.balance",
    playerId
);