Table of Contents

Class EntityManager

Namespace
Stride.Engine
Assembly
Stride.Engine.dll

Manage a collection of entities.

public abstract class EntityManager : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder, IReadOnlySet<Entity>, IReadOnlyCollection<Entity>, IEnumerable<Entity>, IEnumerable
Inheritance
EntityManager
Implements
Derived
Inherited Members
Extension Methods

Constructors

EntityManager(IServiceRegistry)

Initializes a new instance of the EntityManager class.

protected EntityManager(IServiceRegistry registry)

Parameters

registry IServiceRegistry

The registry.

Exceptions

ArgumentNullException

registry

Properties

ComponentTypes

Gets the list of component types from the entities..

public IEnumerable<TypeInfo> ComponentTypes { get; }

Property Value

IEnumerable<TypeInfo>

The registered component types.

Count

Gets the number of elements in the collection.

public int Count { get; }

Property Value

int

The number of elements in the collection.

ExecutionMode

public ExecutionMode ExecutionMode { get; protected set; }

Property Value

ExecutionMode

Processors

Gets the entity Processors.

public EntityProcessorCollection Processors { get; }

Property Value

EntityProcessorCollection

Services

Gets the services.

public IServiceRegistry Services { get; }

Property Value

IServiceRegistry

The services.

Methods

Contains(Entity)

Determines whether this instance contains the specified entity.

public bool Contains(Entity item)

Parameters

item Entity

The item.

Returns

bool

true if this instance contains the specified entity; otherwise, false.

Draw(RenderContext)

Calls Draw(RenderContext) on all enabled entity processors.

public virtual void Draw(RenderContext context)

Parameters

context RenderContext

The render context.

GetEnumerator()

Gets the Entity enumerator of this instance.

public HashSet<Entity>.Enumerator GetEnumerator()

Returns

HashSet<Entity>.Enumerator

The entity enumerator

GetProcessor<TProcessor>()

Gets the first processor of the type TProcessor.

public TProcessor GetProcessor<TProcessor>() where TProcessor : EntityProcessor

Returns

TProcessor

The first processor of type T or null if not found.

Type Parameters

TProcessor

Type of the processor

OnComponentChanged(Entity, int, EntityComponent, EntityComponent)

protected virtual void OnComponentChanged(Entity entity, int index, EntityComponent previousComponent, EntityComponent newComponent)

Parameters

entity Entity
index int
previousComponent EntityComponent
newComponent EntityComponent

OnComponentTypeAdded(TypeInfo)

protected virtual void OnComponentTypeAdded(TypeInfo obj)

Parameters

obj TypeInfo

OnEntityAdded(Entity)

protected virtual void OnEntityAdded(Entity e)

Parameters

e Entity

OnEntityRemoved(Entity)

protected virtual void OnEntityRemoved(Entity e)

Parameters

e Entity

Remove(Entity)

Removes the entity from the EntityManager. It works either entity has a parent or not. In conjonction with EntityProcessor, it will remove child entities as well.

public void Remove(Entity entity)

Parameters

entity Entity

The entity.

Reset()

Removes all entities from the EntityManager.

protected virtual void Reset()

Update(GameTime)

public virtual void Update(GameTime gameTime)

Parameters

gameTime GameTime

Events

ComponentChanged

Occurs when a component changed for an entity (Added or removed)

public event EventHandler<EntityComponentEventArgs> ComponentChanged

Event Type

EventHandler<EntityComponentEventArgs>

ComponentTypeAdded

Occurs when a new component type is added.

public event EventHandler<TypeInfo> ComponentTypeAdded

Event Type

EventHandler<TypeInfo>

EntityAdded

Occurs when an entity is added.

public event EventHandler<Entity> EntityAdded

Event Type

EventHandler<Entity>

EntityRemoved

Occurs when an entity is removed.

public event EventHandler<Entity> EntityRemoved

Event Type

EventHandler<Entity>

HierarchyChanged

Occurs when an entity is removed.

public event EventHandler<Entity> HierarchyChanged

Event Type

EventHandler<Entity>