Class GameExtensions
- Namespace
- Stride.CommunityToolkit.Bepu
- Assembly
- Stride.CommunityToolkit.Bepu.dll
Provides extension methods for the Game class to simplify common game setup tasks for the Bepu Physics engine.
public static class GameExtensions
- Inheritance
-
GameExtensions
Methods
Add2DGround(Game, string?, Vector2?, bool)
Adds a 2D ground entity to the specified game with optional name, size, and collider settings.
public static Entity Add2DGround(this Game game, string? entityName = "Ground", Vector2? size = null, bool includeCollider = true)
Parameters
gameGameThe game instance to which the ground entity will be added.
entityNamestringThe name to assign to the ground entity. If null, a default name is used.
sizeVector2?The size of the ground entity in world units. If null, a default size is applied.
includeColliderboolSpecifies whether a collider should be included with the ground entity. Set to true to add a collider; otherwise, false.
Returns
- Entity
The newly created ground entity added to the game.
Remarks
The ground entity is created using a cube primitive model and is suitable for 2D gameplay scenarios. The default size and name are defined by Default2DGroundSize and DefaultGroundName, respectively.
Add3DGround(Game, string?, Vector2?, bool)
Adds a 3D ground entity to the game.
public static Entity Add3DGround(this Game game, string? entityName = "Ground", Vector2? size = null, bool includeCollider = true)
Parameters
gameGameGame instance.
entityNamestringOptional entity name; defaults to DefaultGroundName.
sizeVector2?Optional ground size; defaults to Default3DGroundSize.
includeColliderboolIf true, attaches a CompoundCollider.
Returns
Create2DPrimitive(IGame, Primitive2DModelType, Bepu2DPhysicsOptions?)
Creates a 2D primitive entity and attaches a Bepu physics component as defined by options.
public static Entity Create2DPrimitive(this IGame game, Primitive2DModelType type, Bepu2DPhysicsOptions? options = null)
Parameters
gameIGametypePrimitive2DModelTypeoptionsBepu2DPhysicsOptions
Returns
Create3DPrimitive(IGame, PrimitiveModelType, Bepu3DPhysicsOptions?)
Creates a 3D primitive entity and attaches a Bepu physics component as defined by options.
public static Entity Create3DPrimitive(this IGame game, PrimitiveModelType type, Bepu3DPhysicsOptions? options = null)
Parameters
gameIGameThe game instance.
typePrimitiveModelTypeWhich primitive shape to create.
optionsBepu3DPhysicsOptionsOptions for both the primitive geometry and physics. If
null, defaults will be used.
Returns
SetupBase2DScene(Game)
Sets up a default 2D scene for the game, similar to creating an empty project through the editor.
public static void SetupBase2DScene(this Game game)
Parameters
gameGame
SetupBase3DScene(Game)
Sets up a default 3D scene for the game, similar to creating an empty project through the editor.
public static void SetupBase3DScene(this Game game)
Parameters
gameGameThe Game instance for which the base 3D scene will be set up.
Remarks
This method performs the following setup operations in sequence:
- Adds a default GraphicsCompositor to the game's SceneSystem and applies a clean UI stage.
- Adds a camera to the game and sets it up with a MouseLookCamera component.
- Adds a directional light to the game scene.
- Adds ground geometry to the game scene.