Entity Class
Namespace: Stride.EngineAssembly: Stride.Engine.dll
Game entity. It usually aggregates multiple EntityComponent
[ContentSerializer(typeof(Entity.EntityContentSerializer))]
[DataSerializer(typeof(Entity.EntitySerializer))]
[DataStyle(DataStyle.Normal)]
[DataContract("Entity")]
public sealed class Entity : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder, IEnumerable<EntityComponent>, IEnumerable, IIdentifiable
              | Name | Description | |
|---|---|---|
| Constructors | ||
| Entity() | Create a new Entity instance.  | 
                          |
| Entity(Vector3, String) | Create a new Entity instance having the provided name and initial position.  | 
                          |
| Entity(String) | Create a new Entity instance having the provided name.  | 
                          |
| Properties | ||
| Components | The components stored in this entity.  | 
                          |
| EntityManager | The entity manager which processes this entity.  | 
                          |
| Id | ||
| Name | ||
| Scene | The scene this entity is in.   | 
                          |
| Transform | Gets or sets the Transform associated to this entity. Added for convenience over usual Get/Set method.  | 
                          |
| Methods | ||
| Add(EntityComponent) | Adds the specified component using the   | 
                          |
| Get<T>() | Gets the first component of the specified type.  | 
                          |
| Get<T>(Int32) | Gets the index'th component of the specified type. See remarks.  | 
                          |
| GetAll<T>() | Gets all components of the specified type.  | 
                          |
| GetEnumerator() | Gets the enumerator of EntityComponent  | 
                          |
| GetOrCreate<T>() | Gets or create a component with the specified key.  | 
                          |
| Remove(EntityComponent) | Removes the specified component.  | 
                          |
| Remove<T>() | Removes the first component of the specified type or derived type.  | 
                          |
| RemoveAll<T>() | Removes all components of the specified type or derived type.  | 
                          |
| ToString() | ||
| Explicit Interface Implementations | ||
| IEnumerable<EntityComponent>.GetEnumerator() | ||
| IEnumerable.GetEnumerator() | ||
Constructors
Entity()
Create a new Entity instance.
public Entity()
              Entity(Vector3, String)
Create a new Entity instance having the provided name and initial position.
public Entity(Vector3 position, string name = null)
              Parameters
| Type | Name | Description | 
|---|---|---|
| Vector3 | position | The initial position of the entity  | 
                  
| System.String | name | The name to give to the entity  | 
                  
Entity(String)
Create a new Entity instance having the provided name.
public Entity(string name)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | The name to give to the entity  | 
                  
Properties
Components
The components stored in this entity.
[DataMember(100, DataMemberMode.Content)]
public EntityComponentCollection Components { get; }
              Property Value
| Type | Description | 
|---|---|
| EntityComponentCollection | 
EntityManager
The entity manager which processes this entity.
public EntityManager EntityManager { get; }
              Property Value
| Type | Description | 
|---|---|
| EntityManager | 
Id
[DataMember(-10)]
[Display(null, null, Browsable = false)]
public Guid Id { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Guid | 
Name
[DataMember(0)]
public override string Name { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.String | 
Overrides
Scene
The scene this entity is in. 
Setting this to null will remove the entity from the scene and detach it from its parent if it has one.
public Scene Scene { get; set; }
              Property Value
| Type | Description | 
|---|---|
| Scene | 
Transform
Gets or sets the Transform associated to this entity. Added for convenience over usual Get/Set method.
public TransformComponent Transform { get; }
              Property Value
| Type | Description | 
|---|---|
| TransformComponent | 
Methods
Add(EntityComponent)
Adds the specified component using the 
public void Add(EntityComponent component)
              Parameters
| Type | Name | Description | 
|---|---|---|
| EntityComponent | component | The component.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | component  | 
                  
Get<T>()
Gets the first component of the specified type.
public T Get<T>()
    where T : EntityComponent
              Returns
| Type | Description | 
|---|---|
| T | The component or null if does no exist  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Type of the component  | 
                  
Get<T>(Int32)
Gets the index'th component of the specified type. See remarks.
public T Get<T>(int index)
    where T : EntityComponent
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | index | The index'th component to select.  | 
                  
Returns
| Type | Description | 
|---|---|
| T | The component or null if does no exist  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Type of the component  | 
                  
Remarks
- If index > 0, it will take the index'th component of the specified 
T. - An index == 0 is equivalent to calling Get<T>()
 - if index < 0, it will start from the end of the list to the beginning. A value of -1 means the first last component.
 
GetAll<T>()
Gets all components of the specified type.
public IEnumerable<T> GetAll<T>()
    where T : EntityComponent
              Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<T> | The component or null if does no exist  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Type of the component  | 
                  
GetEnumerator()
Gets the enumerator of EntityComponent
public FastCollection<EntityComponent>.Enumerator GetEnumerator()
              Returns
| Type | Description | 
|---|---|
| FastCollection.Enumerator<> | 
GetOrCreate<T>()
Gets or create a component with the specified key.
public T GetOrCreate<T>()
    where T : EntityComponent, new()
              Returns
| Type | Description | 
|---|---|
| T | A new or existing instance of {T}  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Type of the entity component  | 
                  
Remove(EntityComponent)
Removes the specified component.
public void Remove(EntityComponent component)
              Parameters
| Type | Name | Description | 
|---|---|---|
| EntityComponent | component | 
Remove<T>()
Removes the first component of the specified type or derived type.
public void Remove<T>()
    where T : EntityComponent
              Type Parameters
| Name | Description | 
|---|---|
| T | Type of the component  | 
                  
RemoveAll<T>()
Removes all components of the specified type or derived type.
public void RemoveAll<T>()
    where T : EntityComponent
              Type Parameters
| Name | Description | 
|---|---|
| T | Type of the component  | 
                  
ToString()
public override string ToString()
              Returns
| Type | Description | 
|---|---|
| System.String | 
Overrides
| Improve this Doc View SourceExplicit Interface Implementations
IEnumerable<EntityComponent>.GetEnumerator()
IEnumerator<EntityComponent> IEnumerable<EntityComponent>.GetEnumerator()
              Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerator<EntityComponent> | 
IEnumerable.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
              Returns
| Type | Description | 
|---|---|
| System.Collections.IEnumerator |