Time ClassDelta Engine Documentation
Easily access the current update time step delta, which defaults to 0.05 (20 updates/sec). View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Time

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

public abstract class Time

The Time type exposes the following members.

Constructors

  NameDescription
Protected methodTime
Initializes a new instance of the Time class
Top
Methods

  NameDescription
Public methodStatic memberCheckEvery
Allows to check in huge intervals. Should only be used with interval values above Delta, otherwise it will always return true as the Total time is only updated once per Update tick. We subtract Delta since Total already includes this update tick's Delta. View code on GitHub
Top
Fields

  NameDescription
Public fieldStatic memberSpeedFactor
Top
Properties

  NameDescription
Public propertyStatic memberDelta
Public propertyStatic memberIsPaused
Public propertyStatic memberRapidUpdateDelta
Public propertyStatic memberTotal
Top
Remarks

Tests: DeltaEngine.Tests.Entities.TimeTests
Examples

3 unit tests call DeltaEngine.Entities.Time
[Test]
public void CheckEveryIsFalseIfItDidNotCrossTheIntervalThisFrame()
{
    Time.Total = 0.4f;
    Time.Delta = 0.2f;
    Assert.IsFalse(Time.CheckEvery(0.5f));
}
[Test]
public void CheckEveryIsTrueIfItDidCrossTheIntervalThisFrame()
{
    Time.Total = 0.6f;
    Time.Delta = 0.2f;
    Assert.IsTrue(Time.CheckEvery(0.5f));
}
[Test]
public void PauseTimeShouldNotUpdateAnyEntityAnymore()
{
    var entities = new MockEntitiesRunner(typeof(EntitiesRunnerTests.IncrementCounter));
    var entity = new MockEntity().Add(0).Start<EntitiesRunnerTests.IncrementCounter>();
    Assert.AreEqual(0, entity.Get<int>());
    entities.RunEntities();
    Assert.AreEqual(1, entity.Get<int>());
    Time.SpeedFactor = 0;
    entities.RunEntities();
    Assert.AreEqual(1, entity.Get<int>());
    Time.SpeedFactor = 1;
}
See Also