Filtered InterfaceDelta Engine Documentation
Allows entities to be easily filtered so that only specific ones are updated. View code on GitHub

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

public interface Filtered

The Filtered type exposes the following members.

Properties

  NameDescription
Public propertyFilter
Top
Remarks

Tests: DeltaEngine.Tests.Entities.FilteredEntitiesTests
Examples

4 unit tests call DeltaEngine.Entities.Filtered
[Test]
public void SelectingEntityHandlerProcessesEntitiesThatPassTheSelectionCriteria()
{
    var entities = new MockEntitiesRunner(typeof(IncludeOnlyEntitiesWithPositiveFloats));
    var first = new MockEntity().Start<IncludeOnlyEntitiesWithPositiveFloats>().Add(3.0f);
    var excluded = new MockEntity().Start<IncludeOnlyEntitiesWithPositiveFloats>().Add(-1.0f);
    var second = new MockEntity().Start<IncludeOnlyEntitiesWithPositiveFloats>().Add(2.0f);
    entities.RunEntities();
    var start = first.Get<int>();
    Assert.IsFalse(excluded.Contains<int>());
    Assert.AreEqual(start + 1, second.Get<int>());
}
[Test]
public void SelectingEntitiesWithDifferentRenderLayer()
{
    var entities = new MockEntitiesRunner(typeof(SortByRenderLayer));
    var last = new MockDrawableEntity { RenderLayer = 13 };
    last.OnDraw<SortByRenderLayer>();
    var first = new MockDrawableEntity { RenderLayer = -1 };
    first.OnDraw<SortByRenderLayer>();
    var middle = new MockDrawableEntity { RenderLayer = 5 };
    middle.OnDraw<SortByRenderLayer>();
    SortedResult.Clear();
    entities.RunEntities();
    Assert.AreEqual(first, SortedResult[0]);
    Assert.AreEqual(middle, SortedResult[1]);
    Assert.AreEqual(last, SortedResult[2]);
}
[Test]
public void SelectingMultipleDifferentEntitiesWithDifferentRenderLayer()
{
    var entities = new MockEntitiesRunner(typeof(SortByRenderLayer),
        typeof(AnotherSortByRenderLayer));
    var last = new MockDrawableEntity();
    last.OnDraw<SortByRenderLayer>();
    last.RenderLayer = 13;
    var first = new MockDrawableEntity { RenderLayer = -1 };
    first.OnDraw<AnotherSortByRenderLayer>();
    var middle1 = new MockDrawableEntity { RenderLayer = 5 };
    middle1.OnDraw<SortByRenderLayer>();
    var middle2 = new MockDrawableEntity { RenderLayer = 5 };
    middle2.OnDraw<AnotherSortByRenderLayer>();
    SortedResult.Clear();
    entities.RunEntities();
    Assert.AreEqual(first, SortedResult[0]);
    Assert.AreEqual(middle1, SortedResult[1]);
    Assert.AreEqual(middle2, SortedResult[2]);
    Assert.AreEqual(last, SortedResult[3]);
}
See Also