Class EntityExtensions
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
entityEntityThe camera entity that will receive the controller script.
helpToggleKeyKeysThe key that collapses and expands the camera's help.
helpCollapsedboolWhether 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
entityEntityThe entity to which the interactive camera script will be added.
helpPositionAnchor?Where the shared TextOverlay is drawn. null, the default, leaves the overlay's own position alone.
helpToggleKeyKeysThe key that collapses and expands the camera's help.
helpCollapsedboolWhether the help starts collapsed to a single reminder line. Collapsed by default.
showHelpboolfalse 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
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.
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
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.
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
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
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
entityEntityAn entity in the scene to search; it is only the way to reach that scene.
namestringThe 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
entityEntityAn entity in the scene to search; it is only the way to reach that scene.
namestringThe name of the entity to find.
Returns
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
entityEntityThe entity to look on.
Returns
- T
The first component of that type, or null.
Type Parameters
TThe 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
entityEntityThe entity to look on.
Returns
- IEnumerable<T>
The components of that type, in the order they were added.
Type Parameters
TThe 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
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)
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
entityEntityThe entity to look on.
resultTThe first component of that type, or null when there is none.
Returns
Type Parameters
TThe 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
entityEntityThe Entity to get the world position from.
updateTransformsboolIf true, it will update the world matrix to the current frame's world matrix.