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)
Adds a Basic2DCameraController script to the entity enabling panning and zooming interactions suitable for orthographic 2D scenes.
public static void Add2DCameraController(this Entity entity)
Parameters
entityEntityThe camera entity that will receive the controller script.
Add3DCameraController(Entity, DisplayPosition)
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, DisplayPosition displayPosition = DisplayPosition.TopRight)
Parameters
entityEntityThe entity to which the interactive camera script will be added.
displayPositionDisplayPositionThe position on the screen where the camera controls will be displayed. Defaults to TopRight.
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
entityEntityThe entity to which the gizmo will be added.
graphicsDeviceGraphicsDeviceThe graphics device used for rendering the gizmo.
redColorColor?Optional custom color for the X-axis of the gizmo. If not specified, a default color is used.
greenColorColor?Optional custom color for the Y-axis of the gizmo. If not specified, a default color is used.
blueColorColor?Optional custom color for the Z-axis of the gizmo. If not specified, a default color is used.
showAxisNameboolOptional flag to show axis names. Default is false.
rotateAxisNamesboolOptional 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
entityEntityThe entity to which the directional light gizmo will be added.
graphicsDeviceGraphicsDeviceThe graphics device used to render the gizmo.
colorColor?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
entityEntityThe reference entity used to access the scene.
namestringThe 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
parentEntityThe reference entity used to access the scene.
namestringThe 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
Returns
- T
The first component of the specified type found in the entity's children or descendants, or
nullif no such component exists.
Type Parameters
TThe type of component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
GetComponent<T>(Entity)
Retrieves the first component of the specified type from the entity.
public static T? GetComponent<T>(this Entity entity)
Parameters
entityEntity
Returns
- T
The first component of the specified type, or null if no such component exists.
Type Parameters
TThe 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
entityEntity
Returns
- IEnumerable<T>
An IEnumerable<T> of components of the specified type.
Type Parameters
TThe 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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10)
A tuple containing the ten components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11)
A tuple containing the eleven components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
TComponent11The type of the eleventh component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12)
A tuple containing the twelve components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
TComponent11The type of the eleventh component to retrieve.
TComponent12The type of the twelfth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13)
A tuple containing the thirteen components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
TComponent11The type of the eleventh component to retrieve.
TComponent12The type of the twelfth component to retrieve.
TComponent13The type of the thirteenth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9, TComponent10, TComponent11, TComponent12, TComponent13, TComponent14)
A tuple containing the fourteen components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
TComponent11The type of the eleventh component to retrieve.
TComponent12The type of the twelfth component to retrieve.
TComponent13The type of the thirteenth component to retrieve.
TComponent14The type of the fourteenth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
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
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
TComponent11The type of the eleventh component to retrieve.
TComponent12The type of the twelfth component to retrieve.
TComponent13The type of the thirteenth component to retrieve.
TComponent14The type of the fourteenth component to retrieve.
TComponent15The type of the fifteenth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
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
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
TComponent10The type of the tenth component to retrieve.
TComponent11The type of the eleventh component to retrieve.
TComponent12The type of the twelfth component to retrieve.
TComponent13The type of the thirteenth component to retrieve.
TComponent14The type of the fourteenth component to retrieve.
TComponent15The type of the fifteenth component to retrieve.
TComponent16The type of the sixteenth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2)
A tuple containing the two components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3)
A tuple containing the three components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4)
A tuple containing the four components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5)
A tuple containing the five components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6)
A tuple containing the six components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7)
A tuple containing the seven components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8)
A tuple containing the eight components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
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
Returns
- (TComponent1, TComponent2, TComponent3, TComponent4, TComponent5, TComponent6, TComponent7, TComponent8, TComponent9)
A tuple containing the nine components, which may be
nullif they do not exist.
Type Parameters
TComponent1The type of the first component to retrieve.
TComponent2The type of the second component to retrieve.
TComponent3The type of the third component to retrieve.
TComponent4The type of the fourth component to retrieve.
TComponent5The type of the fifth component to retrieve.
TComponent6The type of the sixth component to retrieve.
TComponent7The type of the seventh component to retrieve.
TComponent8The type of the eighth component to retrieve.
TComponent9The type of the ninth component to retrieve.
Exceptions
- ArgumentNullException
Thrown when the
entityisnull.
Remove(Entity)
Removes the entity from its current scene by setting its Scene property to null.
public static void Remove(this Entity entity)
Parameters
entityEntityThe 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
entityEntityThe entity from which to retrieve the component.
resultTWhen this method returns, contains the first component of type
Returns
- bool
trueif a component of typeTis found in the entity; otherwise,false.
Type Parameters
TThe 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
entityEntityThe Entity to get the world position from.
updateTransformsboolIf true, it will update the world matrix to the current frame's world matrix.