Class PhysicsEventRouter2D
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
worldIdB2WorldIdThe world to read events from.
entityResolverFunc<B2BodyId, Entity>Maps a body id to its entity; events with unresolved entities are dropped.
enableContactEventsboolWhether begin/end touch events are dispatched.
enableHitEventsboolWhether 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
worldIdB2WorldIdThe world to read events from.
entityResolverFunc<B2BodyId, Entity>Maps a body id to its entity; events with unresolved entities are dropped.
enableSensorEventsboolWhether sensor events are dispatched.
RegisterContactEventHandler(IContactEventHandler)
Registers a contact event handler; a handler is only registered once.
public void RegisterContactEventHandler(IContactEventHandler handler)
Parameters
handlerIContactEventHandlerThe handler to receive contact events.
RegisterSensorEventHandler(ISensorEventHandler)
Registers a sensor event handler; a handler is only registered once.
public void RegisterSensorEventHandler(ISensorEventHandler handler)
Parameters
handlerISensorEventHandlerThe handler to receive sensor events.
UnregisterContactEventHandler(IContactEventHandler)
Unregisters a contact event handler.
public void UnregisterContactEventHandler(IContactEventHandler handler)
Parameters
handlerIContactEventHandlerThe handler to remove.
UnregisterSensorEventHandler(ISensorEventHandler)
Unregisters a sensor event handler.
public void UnregisterSensorEventHandler(ISensorEventHandler handler)
Parameters
handlerISensorEventHandlerThe handler to remove.