EntityManager Class
Namespace: Stride.EngineAssembly: Stride.Engine.dll
Manage a collection of entities.
public abstract class EntityManager : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder, IReadOnlySet<Entity>, IReadOnlyCollection<Entity>, IEnumerable<Entity>, IEnumerable
Name | Description | |
---|---|---|
Constructors | ||
EntityManager(IServiceRegistry) | Initializes a new instance of the EntityManager class. |
|
Properties | ||
ComponentTypes | Gets the list of component types from the entities.. |
|
Count | ||
ExecutionMode | ||
Processors | Gets the entity Processors. |
|
Services | Gets the services. |
|
Methods | ||
Contains(Entity) | Determines whether this instance contains the specified entity. |
|
Draw(RenderContext) | Calls Draw(RenderContext) on all enabled entity processors. |
|
GetEnumerator() | Gets the Entity enumerator of this instance. |
|
GetProcessor<TProcessor>() | Gets the first processor of the type TProcessor. |
|
OnComponentChanged(Entity, Int32, EntityComponent, EntityComponent) | ||
OnComponentTypeAdded(TypeInfo) | ||
OnEntityAdded(Entity) | ||
OnEntityRemoved(Entity) | ||
Remove(Entity) | Removes the entity from the EntityManager.
It works weither entity has a parent or not.
In conjonction with |
|
Reset() | Removes all entities from the EntityManager. |
|
Update(GameTime) | ||
Events | ||
ComponentChanged | Occurs when a component changed for an entity (Added or removed) |
|
ComponentTypeAdded | Occurs when a new component type is added. |
|
EntityAdded | Occurs when an entity is added. |
|
EntityRemoved | Occurs when an entity is removed. |
|
HierarchyChanged | Occurs when an entity is removed. |
|
Explicit Interface Implementations | ||
IEnumerable<Entity>.GetEnumerator() | ||
IEnumerable.GetEnumerator() |
Constructors
EntityManager(IServiceRegistry)
Initializes a new instance of the EntityManager class.
protected EntityManager(IServiceRegistry registry)
Parameters
Type | Name | Description |
---|---|---|
IServiceRegistry | registry | The registry. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | registry |
Properties
ComponentTypes
Gets the list of component types from the entities..
public IEnumerable<TypeInfo> ComponentTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.TypeInfo> | The registered component types. |
Count
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ExecutionMode
public ExecutionMode ExecutionMode { get; protected set; }
Property Value
Type | Description |
---|---|
ExecutionMode |
Processors
Gets the entity Processors.
public EntityProcessorCollection Processors { get; }
Property Value
Type | Description |
---|---|
EntityProcessorCollection |
Services
Gets the services.
public IServiceRegistry Services { get; }
Property Value
Type | Description |
---|---|
IServiceRegistry | The services. |
Methods
Contains(Entity)
Determines whether this instance contains the specified entity.
public bool Contains(Entity item)
Parameters
Type | Name | Description |
---|---|---|
Entity | item | The item. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Draw(RenderContext)
Calls Draw(RenderContext) on all enabled entity processors.
public virtual void Draw(RenderContext context)
Parameters
Type | Name | Description |
---|---|---|
RenderContext | context | The render context. |
GetEnumerator()
Gets the Entity enumerator of this instance.
public HashSet<Entity>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.HashSet.Enumerator<> | The entity enumerator |
GetProcessor<TProcessor>()
Gets the first processor of the type TProcessor.
public TProcessor GetProcessor<TProcessor>()
where TProcessor : EntityProcessor
Returns
Type | Description |
---|---|
TProcessor | The first processor of type T or |
Type Parameters
Name | Description |
---|---|
TProcessor | Type of the processor |
OnComponentChanged(Entity, Int32, EntityComponent, EntityComponent)
protected virtual void OnComponentChanged(Entity entity, int index, EntityComponent previousComponent, EntityComponent newComponent)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | |
System.Int32 | index | |
EntityComponent | previousComponent | |
EntityComponent | newComponent |
OnComponentTypeAdded(TypeInfo)
protected virtual void OnComponentTypeAdded(TypeInfo obj)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | obj |
OnEntityAdded(Entity)
protected virtual void OnEntityAdded(Entity e)
Parameters
Type | Name | Description |
---|---|---|
Entity | e |
OnEntityRemoved(Entity)
protected virtual void OnEntityRemoved(Entity e)
Parameters
Type | Name | Description |
---|---|---|
Entity | e |
Remove(Entity)
Removes the entity from the EntityManager.
It works weither entity has a parent or not.
In conjonction with
public void Remove(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity. |
Reset()
Removes all entities from the EntityManager.
protected virtual void Reset()
Update(GameTime)
public virtual void Update(GameTime gameTime)
Parameters
Type | Name | Description |
---|---|---|
GameTime | gameTime |
Events
ComponentChanged
Occurs when a component changed for an entity (Added or removed)
public event EventHandler<EntityComponentEventArgs> ComponentChanged
Event Type
Type | Description |
---|---|
System.EventHandler<EntityComponentEventArgs> |
ComponentTypeAdded
Occurs when a new component type is added.
public event EventHandler<TypeInfo> ComponentTypeAdded
Event Type
Type | Description |
---|---|
System.EventHandler<System.Reflection.TypeInfo> |
EntityAdded
Occurs when an entity is added.
public event EventHandler<Entity> EntityAdded
Event Type
Type | Description |
---|---|
System.EventHandler<Entity> |
EntityRemoved
Occurs when an entity is removed.
public event EventHandler<Entity> EntityRemoved
Event Type
Type | Description |
---|---|
System.EventHandler<Entity> |
HierarchyChanged
Occurs when an entity is removed.
public event EventHandler<Entity> HierarchyChanged
Event Type
Type | Description |
---|---|
System.EventHandler<Entity> |
Explicit Interface Implementations
IEnumerable<Entity>.GetEnumerator()
IEnumerator<Entity> IEnumerable<Entity>.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<Entity> |
IEnumerable.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |