Game Events
Strongly typed game events
favorite15favorites
thumb_up13upvotes
hard_drive
0 MB
folder
19 files
build
Engine v17
history
Last update 698d ago
About This Package
About Game Events
Easily dispatch events in your scene when stuff happens.
Basics
Declare an event type implementing with all the properties you want to pass around.
public record DamagedEvent(
GameObject Attacker,
GameObject Victim,
int Damage ) : IGameEvent;Implement for your custom event type in a .
public sealed class MyComponent : Component,
IGameEventHandler<DamagedEvent>
{
public void OnGameEvent( DamagedEvent eventArgs )
{
Log.Info( $"{eventArgs.Victim.Name} says \"Ouch!\"" );
}
}Dispatch the event on a or the , which will notify any components in its descendants.
GameObject.Dispatch( new DamagedEvent( attacker, victim, 50 ) );Invocation order
You can control the order that handlers are invoked using attributes on the handler method.
* : run this first
* : run this last
* : run this before 's handler
* : run this after 's handler
[Early, After<SomeOtherComponent>]
public void OnGameEvent( DamagedEvent eventArgs )
{
Log.Info( $"{eventArgs.Victim.Name} says \"Ouch!\"" );
}
555
Total Users
1,382
Total Sessions
3.0 days
Total Playtime
Global Statistics
10.6K
kills
Package ID:
facepunch.libevents
Created:
2024-06-11 09:12 UTC
Updated:
2024-08-11 10:59 UTC
Type:
library
Public:
Yes
Version:
65480
files:
19
Size:
0.2 MB
Engine Version:
17
Asset Version ID:
65480
Version Created:
2024-08-11 10:59 UTC
Hash:
4045617937883951561
Manifest: Open manifest
Cs Proj Name:
Compiler:
Sandbox.Events, SANDBOX;ADDON;DEBUG, 1701;1702;1591;, 1, , 1, Array, Array, Array
Resources:
Code Package References:
65480
Aug 11, 2024
Changes on 2024-08-11
64781
Aug 8, 2024
Changes on 2024-08-08
64761
Aug 8, 2024
Changes on 2024-08-08
64727
Aug 8, 2024
Changes on 2024-08-08
60139
Jul 11, 2024
Changes on 2024-07-11
60137
Jul 11, 2024
Changes on 2024-07-11
60121
Jul 11, 2024
Changes on 2024-07-11
58385
Jun 13, 2024
Changes on 2024-06-13
58380
Jun 13, 2024
Changes on 2024-06-13
58357
Jun 12, 2024
Changes on 2024-06-12