---
title: "Game Events - s&box library"
description: "Strongly typed game events"
canonical: "https://sbox.watch/libraries/facepunch/libevents/"
generated_at: "2026-07-22T23:14:22.744Z"
---

# Game Events

Strongly typed game events

- Type: library
- Ident: facepunch.libevents
- Creator: Facepunch
- Canonical: https://sbox.watch/libraries/facepunch/libevents/
- Markdown: https://sbox.watch/libraries/facepunch/libevents.md
- sbox.game: https://sbox.game/facepunch/libevents/
- Generated: 2026-07-22T23:14:22.744Z

## Stats

- 24h momentum: +0
- Terry score: 83%
- Favorites: 15
- Upvotes: 13
- Downvotes: 0
- Updated: Aug 11, 2024
- Created: Jun 11, 2024
- Size: 156.8 KB
- Files: 19
- Tags: event, events, fsm

## Description

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!\\"" );
}



## More by Facepunch

| Package | Ident | Players | Favorites | Upvotes | Score | Markdown |
| --- | --- | --- | --- | --- | --- | --- |
| Player Controller | facepunch.playercontroller | 0 | 98 | 74 | 96% | https://sbox.watch/libraries/facepunch/playercontroller.md |
| SDF Mesh Library | facepunch.libsdf | 0 | 29 | 25 | 90% | https://sbox.watch/libraries/facepunch/libsdf.md |
| Sprite Tools (OBSOLETE) | facepunch.spritetools | 0 | 18 | 22 | 83% | https://sbox.watch/libraries/facepunch/spritetools.md |
| Spline Tools | facepunch.splinetools | 0 | 12 | 17 | 86% | https://sbox.watch/libraries/facepunch/splinetools.md |
| State Machines | facepunch.libstates | 0 | 12 | 15 | 85% | https://sbox.watch/libraries/facepunch/libstates.md |
| Movie Maker (Preview) | facepunch.moviemaker | 0 | 8 | 13 | 74% | https://sbox.watch/libraries/facepunch/moviemaker.md |
