Table of Contents

Class PhysicsEventRouter2D

Namespace
Stride.CommunityToolkit.Box2D.Events
Assembly
Stride.CommunityToolkit.Box2D.dll

Routes Box2D contact and sensor events to registered handlers. Delegates resolution of bodies to Stride entities via a provided callback so it remains agnostic of the mapping implementation.

public sealed class PhysicsEventRouter2D
Inheritance
PhysicsEventRouter2D

Methods

ProcessContacts(B2WorldId, Func<B2BodyId, Entity?>, bool, bool)

Reads this step's contact events from the world and dispatches them to registered handlers.

public void ProcessContacts(B2WorldId worldId, Func<B2BodyId, Entity?> entityResolver, bool enableContactEvents, bool enableHitEvents)

Parameters

worldId B2WorldId

The world to read events from.

entityResolver Func<B2BodyId, Entity>

Maps a body id to its entity; events with unresolved entities are dropped.

enableContactEvents bool

Whether begin/end touch events are dispatched.

enableHitEvents bool

Whether hit (impact) events are dispatched.

ProcessSensors(B2WorldId, Func<B2BodyId, Entity?>, bool)

Reads this step's sensor events from the world and dispatches them to registered handlers.

public void ProcessSensors(B2WorldId worldId, Func<B2BodyId, Entity?> entityResolver, bool enableSensorEvents)

Parameters

worldId B2WorldId

The world to read events from.

entityResolver Func<B2BodyId, Entity>

Maps a body id to its entity; events with unresolved entities are dropped.

enableSensorEvents bool

Whether sensor events are dispatched.

RegisterContactEventHandler(IContactEventHandler)

Registers a contact event handler; a handler is only registered once.

public void RegisterContactEventHandler(IContactEventHandler handler)

Parameters

handler IContactEventHandler

The handler to receive contact events.

RegisterSensorEventHandler(ISensorEventHandler)

Registers a sensor event handler; a handler is only registered once.

public void RegisterSensorEventHandler(ISensorEventHandler handler)

Parameters

handler ISensorEventHandler

The handler to receive sensor events.

UnregisterContactEventHandler(IContactEventHandler)

Unregisters a contact event handler.

public void UnregisterContactEventHandler(IContactEventHandler handler)

Parameters

handler IContactEventHandler

The handler to remove.

UnregisterSensorEventHandler(ISensorEventHandler)

Unregisters a sensor event handler.

public void UnregisterSensorEventHandler(ISensorEventHandler handler)

Parameters

handler ISensorEventHandler

The handler to remove.