Table of Contents

Class EntityExtensions

Namespace
Stride.CommunityToolkit.Engine
Assembly
Stride.CommunityToolkit.dll

Provides extension methods for the Entity class to simplify common operations, such as adding camera controllers, gizmos, and retrieving or manipulating components.

public static class EntityExtensions
Inheritance
EntityExtensions

Methods

Add2DCameraController(Entity, Keys, bool)

Adds a Basic2DCameraController script to the entity enabling panning and zooming interactions suitable for orthographic 2D scenes.

public static Basic2DCameraController Add2DCameraController(this Entity entity, Keys helpToggleKey = Keys.F2, bool helpCollapsed = true)

Parameters

entity Entity

The camera entity that will receive the controller script.

helpToggleKey Keys

The key that collapses and expands the camera's help.

helpCollapsed bool

Whether the help starts collapsed to a single reminder line. Collapsed by default.

Returns

Basic2DCameraController

The controller, already on the entity.

Add3DCameraController(Entity, Anchor?, Keys, bool, bool)

Adds an interactive camera script Basic3DCameraController to the specified entity, enabling camera movement and rotation through various input methods.

public static Basic3DCameraController Add3DCameraController(this Entity entity, Anchor? helpPosition = null, Keys helpToggleKey = Keys.F2, bool helpCollapsed = true, bool showHelp = true)

Parameters

entity Entity

The entity to which the interactive camera script will be added.

helpPosition Anchor?

Where the shared TextOverlay is drawn. null, the default, leaves the overlay's own position alone.

helpToggleKey Keys

The key that collapses and expands the camera's help.

helpCollapsed bool

Whether the help starts collapsed to a single reminder line. Collapsed by default.

showHelp bool

false keeps the controller but puts no key help on the overlay.

Returns

Basic3DCameraController

The controller, already on the entity.

Remarks

The camera entity can be moved using W, A, S, D, Q and E, arrow keys, a gamepad's left stick or by dragging/scaling using multitouch. Rotation is achieved using the Numpad, the mouse while holding the right mouse button, a gamepad's right stick, or by dragging using single-touch.

AddGizmo(Entity, GraphicsDevice, Color?, Color?, Color?, bool, bool)

Adds a TranslationGizmo to the specified entity with optional custom colors.

public static TranslationGizmo AddGizmo(this Entity entity, GraphicsDevice graphicsDevice, Color? redColor = null, Color? greenColor = null, Color? blueColor = null, bool showAxisName = false, bool rotateAxisNames = true)

Parameters

entity Entity

The entity to which the gizmo will be added.

graphicsDevice GraphicsDevice

The graphics device used for rendering the gizmo.

redColor Color?

Optional custom color for the X-axis of the gizmo. If not specified, a default color is used.

greenColor Color?

Optional custom color for the Y-axis of the gizmo. If not specified, a default color is used.

blueColor Color?

Optional custom color for the Z-axis of the gizmo. If not specified, a default color is used.

showAxisName bool

Optional flag to show axis names. Default is false.

rotateAxisNames bool

Optional flag to rotate axis names. Default is true.

Returns

TranslationGizmo

The gizmo, whose entity is already a child of entity.

Examples

This example shows how to add a gizmo to an entity with the default colors:

var entity = new Entity();
// Assume 'game' is an existing Game instance
entity.AddGizmo(game.GraphicsDevice);

AddLightDirectionalGizmo(Entity, GraphicsDevice, Color?)

Adds a gizmo that shows a directional light's direction at runtime.

public static LightDirectionalGizmo AddLightDirectionalGizmo(this Entity entity, GraphicsDevice graphicsDevice, Color? color = null)

Parameters

entity Entity

The entity to which the directional light gizmo will be added.

graphicsDevice GraphicsDevice

The graphics device used to render the gizmo.

color Color?

Optional color for the gizmo. If not specified, a default color is used.

Returns

LightDirectionalGizmo

The gizmo, whose entity is already a child of entity.

Examples

This example shows how to add a light directional gizmo to an entity with the default colors:

var entity = new Entity();
// Assume 'game' is an existing Game instance
entity.AddLightDirectionalGizmo(game.GraphicsDevice);

Remarks

This method is useful for visually representing the direction and orientation of a directional light in a scene. The gizmo can be used during runtime to provide a visual reference for the light's direction.

AddTo(Entity, Entity)

Adds the entity as a child of parent and returns it.

public static Entity AddTo(this Entity entity, Entity parent)

Parameters

entity Entity

The entity to add.

parent Entity

The parent; the same as parent.AddChild(entity).

Returns

Entity

The entity.

AddTo(Entity, Scene)

Adds the entity to scene and returns it, so creation, placement and adding read as one line.

public static Entity AddTo(this Entity entity, Scene scene)

Parameters

entity Entity

The entity to add.

scene Scene

The scene to add it to; the same as setting Scene.

Returns

Entity

The entity.

Examples

game.CreatePrimitive(Primitive3D.Cube()).AddTo(scene).Transform.Position = new Vector3(0, 8, 0);

FindEntity(Entity, string)

Finds an entity by name among the top-level entities of the scene this entity is in.

public static Entity? FindEntity(this Entity entity, string name)

Parameters

entity Entity

An entity in the scene to search; it is only the way to reach that scene.

name string

The name of the entity to find.

Returns

Entity

The first top-level entity with that name, or null if none has it. Children are not searched; see FindEntityRecursive(Entity, string).

Remarks

The same as FindEntity(Scene, string, bool) on entity.Scene; call that directly where the scene is at hand.

Exceptions

InvalidOperationException

The entity is not in a scene, so there is nothing to search.

FindEntityRecursive(Entity, string)

Finds an entity by name among the top-level entities of the scene this entity is in and all their descendants.

public static Entity? FindEntityRecursive(this Entity entity, string name)

Parameters

entity Entity

An entity in the scene to search; it is only the way to reach that scene.

name string

The name of the entity to find.

Returns

Entity

The first entity with that name, or null if none has it.

Remarks

The same as FindEntity(Scene, string, bool) with recursive: true on entity.Scene; call that directly where the scene is at hand.

Exceptions

InvalidOperationException

The entity is not in a scene, so there is nothing to search.

GetComponent<T>(Entity)

The first component of type T on the entity, or null: Stride's own Get<T>() under the name readers from other engines look for.

public static T? GetComponent<T>(this Entity entity) where T : EntityComponent

Parameters

entity Entity

The entity to look on.

Returns

T

The first component of that type, or null.

Type Parameters

T

The component type.

Remarks

Prefer entity.Get<T>() in new code; this forwarder may be removed in a later release.

GetComponents<T>(Entity)

Every component of type T on the entity: Stride's own GetAll<T>() under the name readers from other engines look for.

public static IEnumerable<T> GetComponents<T>(this Entity entity) where T : EntityComponent

Parameters

entity Entity

The entity to look on.

Returns

IEnumerable<T>

The components of that type, in the order they were added.

Type Parameters

T

The component type.

Remarks

Prefer entity.GetAll<T>() in new code; this forwarder may be removed in a later release.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10>(Entity)

Gets ten specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10)

A tuple containing the ten components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11>(Entity)

Gets eleven specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?, TComponent11?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent where TComponent11 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11)

A tuple containing the eleven components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

TComponent11

The type of the eleventh component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12>(Entity)

Gets twelve specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?, TComponent11?, TComponent12?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent where TComponent11 : EntityComponent where TComponent12 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12)

A tuple containing the twelve components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

TComponent11

The type of the eleventh component to retrieve.

TComponent12

The type of the twelfth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13>(Entity)

Gets thirteen specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?, TComponent11?, TComponent12?, TComponent13?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent where TComponent11 : EntityComponent where TComponent12 : EntityComponent where TComponent13 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13)

A tuple containing the thirteen components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

TComponent11

The type of the eleventh component to retrieve.

TComponent12

The type of the twelfth component to retrieve.

TComponent13

The type of the thirteenth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14>(Entity)

Gets fourteen specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?, TComponent11?, TComponent12?, TComponent13?, TComponent14?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent where TComponent11 : EntityComponent where TComponent12 : EntityComponent where TComponent13 : EntityComponent where TComponent14 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14)

A tuple containing the fourteen components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

TComponent11

The type of the eleventh component to retrieve.

TComponent12

The type of the twelfth component to retrieve.

TComponent13

The type of the thirteenth component to retrieve.

TComponent14

The type of the fourteenth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14, TComponent15>(Entity)

Gets fifteen specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?, TComponent11?, TComponent12?, TComponent13?, TComponent14?, TComponent15?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14, TComponent15>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent where TComponent11 : EntityComponent where TComponent12 : EntityComponent where TComponent13 : EntityComponent where TComponent14 : EntityComponent where TComponent15 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14, TComponent15)

A tuple containing the fifteen components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

TComponent11

The type of the eleventh component to retrieve.

TComponent12

The type of the twelfth component to retrieve.

TComponent13

The type of the thirteenth component to retrieve.

TComponent14

The type of the fourteenth component to retrieve.

TComponent15

The type of the fifteenth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14, TComponent15, TComponent16>(Entity)

Gets sixteen specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?, TComponent10?, TComponent11?, TComponent12?, TComponent13?, TComponent14?, TComponent15?, TComponent16?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14, TComponent15, TComponent16>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent where TComponent10 : EntityComponent where TComponent11 : EntityComponent where TComponent12 : EntityComponent where TComponent13 : EntityComponent where TComponent14 : EntityComponent where TComponent15 : EntityComponent where TComponent16 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14, TComponent15, TComponent16)

A tuple containing the sixteen components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

TComponent10

The type of the tenth component to retrieve.

TComponent11

The type of the eleventh component to retrieve.

TComponent12

The type of the twelfth component to retrieve.

TComponent13

The type of the thirteenth component to retrieve.

TComponent14

The type of the fourteenth component to retrieve.

TComponent15

The type of the fifteenth component to retrieve.

TComponent16

The type of the sixteenth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2>(Entity)

Gets two specified components from the entity.

public static (TComponent1?, TComponent2?) Get<TComponent1, TComponent2>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2)

A tuple containing the two components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3>(Entity)

Gets three specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?) Get<TComponent1, TComponent2, TComponent3>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3)

A tuple containing the three components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4>(Entity)

Gets four specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?) Get<TComponent1, TComponent2, TComponent3, TComponent4>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4)

A tuple containing the four components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5>(Entity)

Gets five specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5)

A tuple containing the five components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6>(Entity)

Gets six specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6)

A tuple containing the six components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7>(Entity)

Gets seven specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7)

A tuple containing the seven components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8>(Entity)

Gets eight specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8)

A tuple containing the eight components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9>(Entity)

Gets nine specified components from the entity.

public static (TComponent1?, TComponent2?, TComponent3?, TComponent4?, TComponent5?, TComponent6?, TComponent7?, TComponent8?, TComponent9?) Get<TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9>(this Entity entity) where TComponent1 : EntityComponent where TComponent2 : EntityComponent where TComponent3 : EntityComponent where TComponent4 : EntityComponent where TComponent5 : EntityComponent where TComponent6 : EntityComponent where TComponent7 : EntityComponent where TComponent8 : EntityComponent where TComponent9 : EntityComponent

Parameters

entity Entity

The Entity from which the components are retrieved.

Returns

(TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9)

A tuple containing the nine components, which may be null if they do not exist.

Type Parameters

TComponent1

The type of the first component to retrieve.

TComponent2

The type of the second component to retrieve.

TComponent3

The type of the third component to retrieve.

TComponent4

The type of the fourth component to retrieve.

TComponent5

The type of the fifth component to retrieve.

TComponent6

The type of the sixth component to retrieve.

TComponent7

The type of the seventh component to retrieve.

TComponent8

The type of the eighth component to retrieve.

TComponent9

The type of the ninth component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

Remove(Entity)

Removes the entity from its current scene by setting its Scene property to null.

public static void Remove(this Entity entity)

Parameters

entity Entity

The entity to be removed from its current scene.

TryGetComponent<T>(Entity, out T)

The first component of type T on the entity, as a Try method: for when a missing component is expected rather than a bug.

public static bool TryGetComponent<T>(this Entity entity, out T result) where T : EntityComponent

Parameters

entity Entity

The entity to look on.

result T

The first component of that type, or null when there is none.

Returns

bool

true when the entity has such a component.

Type Parameters

T

The component type.

WorldPosition(Entity, bool)

Retrieves the world position of the entity. This is a convenience method to get the TranslationVector from the WorldMatrix.

public static Vector3 WorldPosition(this Entity entity, bool updateTransforms = true)

Parameters

entity Entity

The Entity to get the world position from.

updateTransforms bool

If true, it will update the world matrix to the current frame's world matrix.

Returns

Vector3

The Vector3 representing the world position of the Entity.