Class GameExtensions
- Namespace
- Stride.CommunityToolkit.Bullet
- Assembly
- Stride.CommunityToolkit.Bullet.dll
Provides extension methods for the Game class to simplify common game setup tasks for the Bullet Physics engine.
public static class GameExtensions
- Inheritance
-
GameExtensions
Methods
Add2DGround(Game, string?, Vector2?)
public static Entity Add2DGround(this Game game, string? entityName = "Ground", Vector2? size = null)
Parameters
Returns
Add3DGround(Game, string?, Vector2?, bool)
Adds a 3D ground entity to the game with a default size of 10x10 units. The ground is created as a plane, and a collider can be optionally added.
public static Entity Add3DGround(this Game game, string? entityName = "Ground", Vector2? size = null, bool includeCollider = true)
Parameters
game
GameThe Game instance to which the ground entity will be added.
entityName
stringThe optional name for the ground entity. If not provided, it defaults to "Ground".
size
Vector2?The size of the ground, specified as a 2D vector. If not provided, it defaults to (10, 10) units.
includeCollider
boolSpecifies whether to add a collider to the ground. Defaults to true.
Returns
- Entity
The created Entity object representing the 3D ground.
AddInfinite3DGround(Game, string?, Vector2?, bool)
Adds an infinite 3D ground entity to the game. The visible part of the ground is defined by the size
parameter,
while the collider is infinite and extends beyond the visible ground.
public static Entity AddInfinite3DGround(this Game game, string? entityName = "Ground", Vector2? size = null, bool includeCollider = true)
Parameters
game
GameThe Game instance to which the infinite ground entity will be added.
entityName
stringThe optional name for the ground entity. If not provided, it defaults to "Ground".
size
Vector2?Defines the visible part of the ground, specified as a 2D vector. If not provided, it defaults to (10, 10) units.
includeCollider
boolSpecifies whether to add a collider to the ground. The collider is infinite, extending beyond the visible part. Defaults to true.
Returns
- Entity
The created Entity object representing the infinite 3D ground.
Create2DPrimitive(IGame, Primitive2DModelType, Primitive2DCreationOptions?)
public static Entity Create2DPrimitive(this IGame game, Primitive2DModelType type, Primitive2DCreationOptions? options = null)
Parameters
game
IGametype
Primitive2DModelTypeoptions
Primitive2DCreationOptions
Returns
Create3DPrimitive(IGame, PrimitiveModelType, Primitive3DCreationOptions?)
Creates a primitive 3D model entity of the specified type with optional customizations.
public static Entity Create3DPrimitive(this IGame game, PrimitiveModelType type, Primitive3DCreationOptions? options = null)
Parameters
game
IGameThe game instance.
type
PrimitiveModelTypeThe type of primitive model to create.
options
Primitive3DCreationOptionsThe options for creating the primitive model. If null, default options are used.
Returns
- Entity
A new entity representing the specified primitive model.
Remarks
The options
parameter allows specifying various settings such as entity name, material,
collider inclusion, size, render group, and 2D flag. Dimensions in the Vector3 for size are used in the order X, Y, Z.
If size is null, default dimensions are used for the model. If no collider is included, the entity is returned without it.
SetupBase2DScene(Game)
public static void SetupBase2DScene(this Game game)
Parameters
game
Game
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
game
GameThe 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.