EntitiesRunner ClassDelta Engine Documentation
Keeps a list of all active entities and manages all behaviors for entities. Updating is done at a fixed time step (e.g. 0.1). Drawing has read-only access, it runs as quickly as possible (60fps+). Details: http://gafferongames.com/game-physics/fix-your-timestep/ View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Entities EntitiesRunner
    DeltaEngine.Mocks MockEntitiesRunner

Namespace: DeltaEngine.Entities
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class EntitiesRunner : IDisposable

The EntitiesRunner type exposes the following members.

Constructors

  NameDescription
Public methodEntitiesRunner
Initializes a new instance of the EntitiesRunner class
Top
Methods

  NameDescription
Public methodChangeUpdateTimeStep
Changes how many times UpdateBehaviors and Updateables are called each second. By default this setting is initialized at the beginning from Settings (20 UpdatesPerSecond = 0.05). View code on GitHub
Public methodDispose
Releases all resources used by the EntitiesRunner
Public methodGetAllEntities
Public methodGetDrawBehavior T 
Public methodGetEntitiesOfType T 
Public methodGetEntitiesWithTag
Public methodGetUpdateBehavior T 
Protected methodGetWhetherAppIsPaused
Public methodRemoveAll
Public methodUpdateAndDrawAllEntities
Top
Properties

  NameDescription
Public propertyStatic memberCurrent
Public propertyNumberOfEntities
Public propertyState
Protected propertyUpdateTimeStep
Top
Remarks

Tests: DeltaEngine.Tests.Entities.EntitiesRunnerTests
Examples

37 unit tests call DeltaEngine.Entities.EntitiesRunner
[Test]
public void EntityIsCreatedActiveAndAutomaticallyAddedToEntitySystem()
{
    var entity = new MockEntity();
    Assert.IsTrue(entity.IsActive);
    Assert.AreEqual(1, EntitiesRunner.Current.NumberOfEntities);
}
[Test]
public void TestExceptions()
{
    var settings = new MockSettings { UpdatesPerSecond = 0 };
    Assert.Throws<EntitiesRunner.InvalidUpdatePerSecondSettings>(
        () => new EntitiesRunner(new MockBehaviorResolver(), settings));
    Assert.Throws<EntitiesRunner.InvalidUpdatePerSecondSettings>(
        () => EntitiesRunner.Current.ChangeUpdateTimeStep(0));
    Assert.Throws<EntitiesRunner.YouAreNotAllowedToDrawOutsideOfTheDrawLoop>(
        () => EntitiesRunner.Current.CheckIfInDrawState());
    Assert.Throws<EntitiesRunner.UnableToResolveBehavior>(
        () => EntitiesRunner.Current.GetDrawBehavior<DrawBehavior>());
}
[Test]
public void MockBehaviorResolversUpdateAndDrawAreNull()
{
    Assert.AreEqual(null,
        new MockBehaviorResolver().ResolveUpdateBehavior(typeof(DerivedBehavior)));
    Assert.AreEqual(null,
        new MockBehaviorResolver().ResolveDrawBehavior(typeof(DerivedBehavior)));
}
See Also