public void should_get_specific_components_for_entity() { var expectedSize = 10; var fakeEntityId = 1; var otherEntityId = 2; var fakeComponent1 = new TestComponentOne(); var fakeComponentTypes = new Dictionary <Type, int> { { typeof(TestComponentOne), 0 }, { typeof(TestComponentTwo), 1 }, { typeof(TestComponentThree), 2 } }; var mockComponentLookup = Substitute.For <IComponentTypeLookup>(); mockComponentLookup.GetAllComponentTypes().Returns(fakeComponentTypes); var database = new ComponentDatabase(mockComponentLookup, expectedSize); database.Add(0, fakeEntityId, fakeComponent1); database.Add(0, otherEntityId, new TestComponentOne()); var component = database.Get(0, fakeEntityId); Assert.Equal(fakeComponent1, component); }
public IComponent GetComponent(int componentTypeId) { var allocationIndex = InternalComponentAllocations[componentTypeId]; return(ComponentDatabase.Get(allocationIndex, componentTypeId)); }