swiftlys2/docs/api/ai/
API Reference GameEvents

IGameEventService

Interface
Namespace: SwiftlyS2.Shared.GameEvents · Assembly: SwiftlyS2.CS2.dll
public interface IGameEventService

Plugin-scoped service for managing game events.

View source

Methods

Fire<T>()

Fires an event to all players. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
void Fire<T>() where T : IGameEvent<T>

Fire<T>(Action<T>)

Fires an event to all players with a configured event. Thread unsafe, use async variant instead for non-main thread context. The action to configure the event.

[ThreadUnsafe]
void Fire<T>(Action<T> configureEvent) where T : IGameEvent<T>
Parameters

FireAsync<T>()

Fires an event to all players asynchronously.

Task FireAsync<T>() where T : IGameEvent<T>
Returns

FireAsync<T>(Action<T>)

Fires an event to all players with a configured event asynchronously.

Task FireAsync<T>(Action<T> configureEvent) where T : IGameEvent<T>
Parameters
Returns

FireToPlayer<T>(int)

Fires an event to a player. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
void FireToPlayer<T>(int slot) where T : IGameEvent<T>
Parameters
  • slotintThe player slot.

FireToPlayer<T>(int, Action<T>)

Fires an event to a player with a configured event. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
void FireToPlayer<T>(int slot, Action<T> configureEvent) where T : IGameEvent<T>
Parameters
  • slotintThe player slot.
  • configureEventAction<T>The action to configure the event.

FireToPlayerAsync<T>(int)

Fires an event to a player asynchronously.

Task FireToPlayerAsync<T>(int slot) where T : IGameEvent<T>
Parameters
  • slotintThe player slot.
Returns

FireToPlayerAsync<T>(int, Action<T>)

Fires an event to a player with a configured event asynchronously.

Task FireToPlayerAsync<T>(int slot, Action<T> configureEvent) where T : IGameEvent<T>
Parameters
  • slotintThe player slot.
  • configureEventAction<T>The action to configure the event.
Returns

FireToServer<T>()

Fires an event to the server. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
void FireToServer<T>() where T : IGameEvent<T>

FireToServer<T>(Action<T>)

Fires an event to the server with a configured event. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
void FireToServer<T>(Action<T> configureEvent) where T : IGameEvent<T>
Parameters
  • configureEventAction<T>The action to configure the event.

FireToServerAsync<T>()

Fires an event to the server asynchronously.

Task FireToServerAsync<T>() where T : IGameEvent<T>
Returns

FireToServerAsync<T>(Action<T>)

Fires an event to the server with a configured event asynchronously.

Task FireToServerAsync<T>(Action<T> configureEvent) where T : IGameEvent<T>
Parameters
  • configureEventAction<T>The action to configure the event.
Returns

HookPost<T>(GameEventHandler<T>)

Hooks a post-event callback.

Guid HookPost<T>(IGameEventService.GameEventHandler<T> callback) where T : IGameEvent<T>
Parameters
Returns
A GUID representing the hook. You can use this to unhook the callback later.

HookPre<T>(GameEventHandler<T>)

Hooks a pre-event callback.

Guid HookPre<T>(IGameEventService.GameEventHandler<T> callback) where T : IGameEvent<T>
Parameters
Returns
A GUID representing the hook. You can use this to unhook the callback later.

IsListeningToEvent(int, string)

Check if the player is Listening this event.

bool IsListeningToEvent(int slot, string eventName)
Parameters
  • slotintThe player slot.
  • eventNamestringThe event name.
Returns

IsListeningToEvent<T>(int)

Check if the player is Listening this event.

bool IsListeningToEvent<T>(int slot) where T : IGameEvent<T>
Parameters
  • slotintThe player slot.
Returns

Unhook(Guid)

Unhooks a callback.

void Unhook(Guid guid)
Parameters
  • guidGuidThe GUID of the hook to unhook.

UnhookPost<T>()

Unhooks all post-event callbacks.

void UnhookPost<T>() where T : IGameEvent<T>

UnhookPre<T>()

Unhooks all pre-event callbacks.

void UnhookPre<T>() where T : IGameEvent<T>