Skip to content

PhysicsServiceCollectionExtensions Class

Definition

Namespace: Brine2D.Physics

Extension methods for registering Box2D physics services.

C#
public static class PhysicsServiceCollectionExtensions

Inheritance System.Object → PhysicsServiceCollectionExtensions

Methods
AddPhysics\(this IServiceCollection, Action<PhysicsOptions>\) Configures Box2D physics \(gravity, layers, thresholds, filters\). PhysicsWorld and the default physics systems are always registered by AddBrine2D \(see [AddPhysicsCore\(this IServiceCollection\)](AddPhysicsCore(thisIServiceCollection).md 'Brine2D.Physics.PhysicsServiceCollectionExtensions.AddPhysicsCore\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)')) — this call is purely about configuration, not existence.
AddPhysicsCore\(this IServiceCollection\) Registers Box2D physics services unconditionally so PhysicsWorld and the default Box2DPhysicsSystem are always resolvable, even when AddPhysics\(this IServiceCollection, Action<PhysicsOptions>\) is never called. Box2D ships as part of core Brine2D \(not a separate optional assembly\), so gating registration behind an opt-in call only protected against nothing while causing a DI-resolution crash the first time a scene's default systems tried to construct Box2DPhysicsSystem. Called unconditionally from AddBrine2D.
AddPhysicsLayers\(this IServiceCollection, Action<PhysicsLayerRegistry>\) Registers named physics layers in the PhysicsLayerRegistry singleton and freezes the registry. Call this once during startup after AddPhysics\(this IServiceCollection, Action<PhysicsOptions>\).