Allows entities to be easily filtered so that only specific ones are updated.
View code on GitHub
Namespace: DeltaEngine.EntitiesAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Filtered type exposes the following members.
Properties
Name | Description | |
---|---|---|
Filter |
Remarks
Examples
[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