Class DeathLinkManager
Hierarchy
- EventBasedManager<DeathEvents>
- DeathLinkManager (View Summary)
Accessors
enabled
-
get enabled(): boolean
Returns
trueif this client is participating in the DeathLink mechanic.Returns boolean
Methods
disableDeathLink
-
Toggles the DeathLink mechanic off for this client, if enabled, by removing the DeathLink tag.
Returns void
enableDeathLink
-
Toggles the DeathLink mechanic on for this client, if disabled, by adding the DeathLink tag.
Returns void
off
-
off<Event extends "deathReceived">(
event: Event,
listener: (...args: DeathEvents[Event]) => void,
): thisRemoves an existing event listener.
Type Parameters
- Event extends "deathReceived"
Parameters
- event: Event
The event name associated with this listener to remove.
- listener: (...args: DeathEvents[Event]) => void
The callback function to remove.
Returns this
This object.
on
-
on<Event extends "deathReceived">(
event: Event,
listener: (...args: DeathEvents[Event]) => void,
): thisAdd an event listener for a specific event.
Type Parameters
- Event extends "deathReceived"
Parameters
- event: Event
The event name to listen for.
- listener: (...args: DeathEvents[Event]) => void
The callback function to fire when this event is received.
Returns this
This object.
sendDeathLink
-
If DeathLink is enabled, sends a DeathLink to all DeathLink enabled players, otherwise this method does nothing.
Parameters
- source: string
The name of the player who died. Can be a slot name, but could also be a name from within a multiplayer game.
Optionalcause: stringOptional text explaining the cause of death. When provided, this should include the player's name. (e.g.,
Phar drowned in a vat of kittens.)
Returns void
Throws
UnauthenticatedError if attempting to send a death link before authenticating to the server.
Remarks
DeathLinks sent from this client will not fire a DeathEvents.deathReceived event to avoid an infinite feedback loop of deaths.
- source: string
wait
-
wait<Event extends "deathReceived">(
event: Event,
clearPredicate?: (...args: DeathEvents[Event]) => boolean,
): Promise<DeathEvents[Event]>Returns a promise that waits for a single specified event to be received. Resolves with the list of arguments dispatched with the event.
Type Parameters
- Event extends "deathReceived"
Parameters
- event: Event
The event name to listen for.
- clearPredicate: (...args: DeathEvents[Event]) => boolean = ...
An optional predicate to check on incoming events to validate if the correct event has been received. If omitted, will return immediately on next event type received.
Returns Promise<DeathEvents[Event]>
Manages DeathLink mechanics for clients that choose to opt in to the mechanic.