예제 #1
0
        public void AddComponentsWithSharedComponentsWorks()
        {
            var archetype = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(EcsTestSharedComp));
            var entity    = m_Manager.CreateEntity(archetype);

            var sharedComponentValue = new EcsTestSharedComp(1337);

            m_Manager.SetSharedComponentData(entity, sharedComponentValue);

            var typesToAdd = new ComponentTypes(typeof(EcsTestData3), typeof(EcsTestSharedComp2), typeof(EcsTestData2));

            m_Manager.AddComponents(entity, typesToAdd);

            Assert.AreEqual(m_Manager.GetSharedComponentData <EcsTestSharedComp>(entity), sharedComponentValue);

            var expectedTotalTypes = new ComponentTypes(typeof(EcsTestData), typeof(EcsTestData2),
                                                        typeof(EcsTestData3), typeof(EcsTestSharedComp), typeof(EcsTestSharedComp2));

            var actualTotalTypes = m_Manager.GetComponentTypes(entity);

            Assert.AreEqual(expectedTotalTypes.Length, actualTotalTypes.Length);
            for (var i = 0; i < expectedTotalTypes.Length; ++i)
            {
                Assert.AreEqual(expectedTotalTypes.GetTypeIndex(i), actualTotalTypes[i].TypeIndex);
            }

            actualTotalTypes.Dispose();
        }
예제 #2
0
	    public void AddComponentsWithTypeIndicesWorks()
	    {
	        var archetype = m_Manager.CreateArchetype(typeof(EcsTestData));
	        var entity = m_Manager.CreateEntity(archetype);

	        var typesToAdd = new ComponentTypes(typeof(EcsTestData3), typeof(EcsTestData2));

	        m_Manager.AddComponents(entity, typesToAdd);

	        var expectedTotalTypes = new ComponentTypes(typeof(EcsTestData2), typeof(EcsTestData3), typeof(EcsTestData));

	        var actualTotalTypes = m_Manager.GetComponentTypes(entity);

	        Assert.AreEqual(expectedTotalTypes.Length, actualTotalTypes.Length);
	        for (var i = 0; i < expectedTotalTypes.Length; ++i)
	            Assert.AreEqual(expectedTotalTypes.GetTypeIndex(i), actualTotalTypes[i].TypeIndex);
	        
	        actualTotalTypes.Dispose();
	    }
예제 #3
0
	    public void AddComponentsWorks()
	    {
	        var archetype = m_Manager.CreateArchetype(typeof(EcsTestData));
	        var entity = m_Manager.CreateEntity(archetype);

	        // Create dummy archetype with unrelated type to override the internal cache in the entity manager
	        // This exposed a bug in AddComponent
            m_Manager.CreateArchetype(typeof(EcsTestData4));

            var typesToAdd = new ComponentTypes(new ComponentType[] {typeof(EcsTestData3), typeof(EcsTestData2)});
	        m_Manager.AddComponents(entity, typesToAdd);

	        var expectedTotalTypes = new ComponentTypes(new ComponentType[] {typeof(EcsTestData2), typeof(EcsTestData3), typeof(EcsTestData)});
	        var actualTotalTypes = m_Manager.GetComponentTypes(entity);

	        Assert.AreEqual(expectedTotalTypes.Length, actualTotalTypes.Length);
	        for (var i = 0; i < expectedTotalTypes.Length; ++i)
	            Assert.AreEqual(expectedTotalTypes.GetTypeIndex(i), actualTotalTypes[i].TypeIndex);
	        
	        actualTotalTypes.Dispose();
	    }