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)

public static void Add2DCameraController(this Entity entity)

Parameters

entity Entity

Add3DCameraController(Entity)

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

public static void Add3DCameraController(this Entity entity)

Parameters

entity Entity

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

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 multi-touch. 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 void 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.

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 directional light gizmo to the specified entity for visual representation and manipulation in the editor or during runtime.

public static void 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.

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.

FindEntity(Entity, string)

Searches for an entity by name within the top-level entities of the current scene.

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

Parameters

entity Entity

The reference entity used to access the scene.

name string

The name of the entity to find.

Returns

Entity

The first entity matching the specified name, or null if no match is found. This search does not include child entities.

FindEntityRecursive(Entity, string)

Searches for an entity by name within the top-level entities of the current scene.

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

Parameters

parent Entity

The reference entity used to access the scene.

name string

The name of the entity to find.

Returns

Entity

The first entity matching the specified name, or null if no match is found. This search does not include child entities.

GetComponentInChildren<T>(Entity)

Recursively searches the entity's children and their descendants using a depth-first search (DFS) for the first component of the specified type.

public static T? GetComponentInChildren<T>(this Entity entity)

Parameters

entity Entity

The Entity from which to start the search.

Returns

T

The first component of the specified type found in the entity's children or descendants, or null if no such component exists.

Type Parameters

T

The type of component to retrieve.

Exceptions

ArgumentNullException

Thrown when the entity is null.

GetComponent<T>(Entity)

Retrieves the first component of the specified type from the entity.

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

Parameters

entity Entity

Returns

T

The first component of the specified type, or null if no such component exists.

Type Parameters

T

The type of component to retrieve.

GetComponents<T>(Entity)

Retrieves all components of the specified type from the entity.

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

Parameters

entity Entity

Returns

IEnumerable<T>

An IEnumerable<T> of components of the specified type.

Type Parameters

T

The type of components to retrieve.

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)

Tries to retrieve a component of type T from the given entity.

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

Parameters

entity Entity

The entity from which to retrieve the component.

result T

When this method returns, contains the first component of type

Returns

bool

true if a component of type T is found in the entity; otherwise, false.

Type Parameters

T

The type of component to retrieve.

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.