---
title: "Game Events - s&box library"
description: "Strongly typed game events"
canonical: "https://sbox.watch/fr/libraries/facepunch/libevents/"
generated_at: "2026-10-09T11:28:15.584Z"
---

# Game Events

Strongly typed game events

- Type: bibliothèque
- Identifiant: facepunch.libevents
- Créateur: Facepunch
- URL canonique: https://sbox.watch/fr/libraries/facepunch/libevents/
- Markdown: https://sbox.watch/fr/libraries/facepunch/libevents/index.md
- sbox.game: https://sbox.game/facepunch/libevents/
- Généré: 2026-10-09T11:28:15.584Z

## Statistiques

- dynamique sur 24 h: +0
- Terry Score: 83%
- Favoris: 15
- Votes positifs: 13
- Votes négatifs: 0
- Mis à jour: 11 août 2024
- Créé: 11 juin 2024
- Taille: 156.8 KB
- Fichiers: 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 | Identifiant | Joueurs | Favoris | Votes positifs | Score | Markdown |
| --- | --- | --- | --- | --- | --- | --- |
| Player Controller | facepunch.playercontroller | 0 | 98 | 74 | 96% | https://sbox.watch/fr/libraries/facepunch/playercontroller/index.md |
| SDF Mesh Library | facepunch.libsdf | 0 | 30 | 25 | 90% | https://sbox.watch/fr/libraries/facepunch/libsdf/index.md |
| Sprite Tools (OBSOLETE) | facepunch.spritetools | 0 | 18 | 22 | 83% | https://sbox.watch/fr/libraries/facepunch/spritetools/index.md |
| State Machines | facepunch.libstates | 0 | 13 | 17 | 86% | https://sbox.watch/fr/libraries/facepunch/libstates/index.md |
| Spline Tools | facepunch.splinetools | 0 | 12 | 17 | 86% | https://sbox.watch/fr/libraries/facepunch/splinetools/index.md |
| Movie Maker (Preview) | facepunch.moviemaker | 0 | 8 | 13 | 74% | https://sbox.watch/fr/libraries/facepunch/moviemaker/index.md |
