Skip to documentation
LITHIUM
Guide 15Experimental

Lithium.Core.Event

Provides named calls and events between addons. Instance handlers are limited to components in the target scene. Static handlers are discovered through Sandbox.Internal.TypeLibrary.

This page is generated from the public C# symbols in src/game/sandbox/Code.

Event

Status: Experimental

Signature

C#
public static class Event

Description

Provides named calls and events between addons. Instance handlers are limited to components in the target scene. Static handlers are discovered through Sandbox.Internal.TypeLibrary.

Example

C#
var result = Event.Call<ExampleType>("name", args);

View source

Members

Call (overload 1 of 2)

Status: Experimental

Signature

C#
public static T? Call<T>(string name, params object[] args)

Description

Calls the first matching endpoint in the active scene and casts its result to T.

Example

C#
var result = Event.Call<ExampleType>("name", args);

View source

Call (overload 2 of 2)

Status: Experimental

Signature

C#
public static T? Call<T>(Scene scene, string name, params object[] args)

Description

Calls the first matching endpoint in scene and casts its result to T.

Example

C#
var result = Event.Call<ExampleType>(scene, "name", args);

View source

TryCall (overload 1 of 2)

Status: Experimental

Signature

C#
public static bool TryCall(string name, out object? result, params object[] args)

Description

Attempts to call the first matching endpoint in the active scene.

Example

C#
var succeeded = Event.TryCall("name", out var result, args);

View source

TryCall (overload 2 of 2)

Status: Experimental

Signature

C#
public static bool TryCall(Scene scene, string name, out object? result, params object[] args)

Description

Attempts to call the first matching endpoint in scene. Component endpoints are considered before static endpoints.

Example

C#
var succeeded = Event.TryCall(scene, "name", out var result, args);

View source

Emit (overload 1 of 2)

Status: Experimental

Signature

C#
public static int Emit(string name, params object[] args)

Description

Emits an event to every matching listener in the active scene. Returns the number of listeners that completed successfully.

Example

C#
var result = Event.Emit("name", args);

View source

Emit (overload 2 of 2)

Status: Experimental

Signature

C#
public static int Emit(Scene scene, string name, params object[] args)

Description

Emits an event to every matching listener in scene. Returns the number of listeners that completed successfully.

Example

C#
var result = Event.Emit(scene, "name", args);

View source

Cette page vous a-t-elle aidé ?

N’indiquez aucune donnée personnelle dans votre commentaire.

0/1000