public void DIS_FindDisabledIfRequestedInChunkIterator()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(EcsTestData));
            var archetype1 = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(Disabled));

            var entity0 = m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.CreateEntity(archetype1);
            var entity2 = m_Manager.CreateEntity(archetype1);

            var query = new EntityArchetypeQuery
            {
                Any  = Array.Empty <ComponentType>(),
                None = Array.Empty <ComponentType>(),
                All  = new ComponentType[] { typeof(EcsTestData), typeof(Disabled) }
            };
            var chunks = m_Manager.CreateArchetypeChunkArray(query, Allocator.TempJob);
            var count  = ArchetypeChunkArray.CalculateEntityCount(chunks);

            chunks.Dispose();

            Assert.AreEqual(2, count);

            m_Manager.DestroyEntity(entity0);
            m_Manager.DestroyEntity(entity1);
            m_Manager.DestroyEntity(entity2);
        }
Beispiel #2
0
        public void SIZ_TagCannotGetNativeArrayFromArchetypeChunk()
        {
            var entity0 = m_Manager.CreateEntity(typeof(EcsTestTag));
            var chunks  = m_Manager.CreateArchetypeChunkArray(
                new EntityArchetypeQuery
            {
                Any  = Array.Empty <ComponentType>(),
                None = Array.Empty <ComponentType>(),
                All  = new ComponentType[] { typeof(EcsTestTag) },
            }, Allocator.TempJob);

            var tagType = m_Manager.GetArchetypeChunkComponentType <EcsTestTag>(false);

            Assert.AreEqual(1, ArchetypeChunkArray.CalculateEntityCount(chunks));

            for (int i = 0; i < chunks.Length; i++)
            {
                var chunk = chunks[i];
                Assert.IsTrue(chunk.Has(tagType));
                Assert.Throws <ArgumentException>(() =>
                {
                    var tags = chunk.GetNativeArray(tagType);
                });
            }

            chunks.Dispose();
        }
        public void PFB_InstantiatedWithoutPrefab()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(Prefab));

            var entity0 = m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.Instantiate(entity0);

            Assert.AreEqual(true, m_Manager.HasComponent <Prefab>(entity0));
            Assert.AreEqual(false, m_Manager.HasComponent <Prefab>(entity1));

            var query = new EntityArchetypeQuery
            {
                Any  = Array.Empty <ComponentType>(),
                None = Array.Empty <ComponentType>(),
                All  = new ComponentType[] { typeof(EcsTestData) }
            };
            var chunks = m_Manager.CreateArchetypeChunkArray(query, Allocator.TempJob);
            var count  = ArchetypeChunkArray.CalculateEntityCount(chunks);

            chunks.Dispose();

            Assert.AreEqual(1, count);

            m_Manager.DestroyEntity(entity0);
            m_Manager.DestroyEntity(entity1);
        }
Beispiel #4
0
        public void SCG_DoesNotMatchRemovedSharedComponentInChunkQuery()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(SharedData1), typeof(EcsTestData));
            var archetype1 = m_Manager.CreateArchetype(typeof(SharedData1), typeof(EcsTestData), typeof(SharedData2));

            var group0 = m_Manager.CreateEntityQuery(ComponentType.ReadWrite <SharedData1>());
            var group1 = m_Manager.CreateEntityQuery(ComponentType.ReadWrite <SharedData2>());

            m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.CreateEntity(archetype1);

            var preChunks0 = group0.CreateArchetypeChunkArray(Allocator.TempJob);
            var preChunks1 = group1.CreateArchetypeChunkArray(Allocator.TempJob);

            Assert.AreEqual(2, ArchetypeChunkArray.CalculateEntityCount(preChunks0));
            Assert.AreEqual(1, ArchetypeChunkArray.CalculateEntityCount(preChunks1));

            m_Manager.RemoveComponent <SharedData2>(entity1);

            var postChunks0 = group0.CreateArchetypeChunkArray(Allocator.TempJob);
            var postChunks1 = group1.CreateArchetypeChunkArray(Allocator.TempJob);

            Assert.AreEqual(2, ArchetypeChunkArray.CalculateEntityCount(postChunks0));
            Assert.AreEqual(0, ArchetypeChunkArray.CalculateEntityCount(postChunks1));

            group0.Dispose();
            group1.Dispose();
            preChunks0.Dispose();
            preChunks1.Dispose();
            postChunks0.Dispose();
            postChunks1.Dispose();
        }
        void VerifyQueryCount(ComponentGroup group, int expectedCount)
        {
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            Assert.AreEqual(expectedCount, ArchetypeChunkArray.CalculateEntityCount(chunks));
            chunks.Dispose();
        }
        void VerifyQueryCount(EntityArchetypeQuery query, int expectedCount)
        {
            var chunks = m_Manager.CreateArchetypeChunkArray(query, Allocator.TempJob);

            Assert.AreEqual(expectedCount, ArchetypeChunkArray.CalculateEntityCount(chunks));
            chunks.Dispose();
        }
        void VerifyComponentCount <T>(int expectedCount)
            where T : IComponentData
        {
            var group  = m_Manager.CreateComponentGroup(ComponentType.Create <T>());
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            group.Dispose();
            Assert.AreEqual(expectedCount, ArchetypeChunkArray.CalculateEntityCount(chunks));
            chunks.Dispose();
        }
Beispiel #8
0
        void VerifyBufferCount <T>(int expectedCount)
            where T : ISystemStateBufferElementData
        {
            var group  = m_Manager.CreateEntityQuery(ComponentType.ReadWrite <T>());
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            group.Dispose();
            Assert.AreEqual(expectedCount, ArchetypeChunkArray.CalculateEntityCount(chunks));
            chunks.Dispose();
        }
        void VerifyComponentCount <T>(int expectedCount)
            where T : IComponentData
        {
            var query = new EntityArchetypeQuery
            {
                Any  = Array.Empty <ComponentType>(),
                None = Array.Empty <ComponentType>(),
                All  = new ComponentType[] { typeof(T) }
            };
            var chunks = m_Manager.CreateArchetypeChunkArray(query, Allocator.TempJob);

            Assert.AreEqual(expectedCount, ArchetypeChunkArray.CalculateEntityCount(chunks));
            chunks.Dispose();
        }
        public void PFB_DontFindPrefabInChunkIterator()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(EcsTestData));
            var archetype1 = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(Prefab));

            var entity0 = m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.CreateEntity(archetype1);

            var group  = m_Manager.CreateComponentGroup(ComponentType.ReadWrite <EcsTestData>());
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            group.Dispose();
            var count = ArchetypeChunkArray.CalculateEntityCount(chunks);

            chunks.Dispose();

            Assert.AreEqual(1, count);

            m_Manager.DestroyEntity(entity0);
            m_Manager.DestroyEntity(entity1);
        }
Beispiel #11
0
        public void SCG_DoesNotMatchRemovedSharedComponentInChunkQuery()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(SharedData1), typeof(EcsTestData));
            var archetype1 = m_Manager.CreateArchetype(typeof(SharedData1), typeof(EcsTestData), typeof(SharedData2));

            var query0 = new EntityArchetypeQuery
            {
                All  = new ComponentType[] { typeof(SharedData1) },
                Any  = Array.Empty <ComponentType>(),
                None = Array.Empty <ComponentType>()
            };
            var query1 = new EntityArchetypeQuery
            {
                All  = new ComponentType[] { typeof(SharedData2) },
                Any  = Array.Empty <ComponentType>(),
                None = Array.Empty <ComponentType>()
            };

            var entity0 = m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.CreateEntity(archetype1);

            var preChunks0 = m_Manager.CreateArchetypeChunkArray(query0, Allocator.TempJob);
            var preChunks1 = m_Manager.CreateArchetypeChunkArray(query1, Allocator.TempJob);

            Assert.AreEqual(2, ArchetypeChunkArray.CalculateEntityCount(preChunks0));
            Assert.AreEqual(1, ArchetypeChunkArray.CalculateEntityCount(preChunks1));

            m_Manager.RemoveComponent <SharedData2>(entity1);

            var postChunks0 = m_Manager.CreateArchetypeChunkArray(query0, Allocator.TempJob);
            var postChunks1 = m_Manager.CreateArchetypeChunkArray(query1, Allocator.TempJob);

            Assert.AreEqual(2, ArchetypeChunkArray.CalculateEntityCount(postChunks0));
            Assert.AreEqual(0, ArchetypeChunkArray.CalculateEntityCount(postChunks1));

            preChunks0.Dispose();
            preChunks1.Dispose();
            postChunks0.Dispose();
            postChunks1.Dispose();
        }
        public void PFB_InstantiatedWithoutPrefab()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(Prefab));

            var entity0 = m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.Instantiate(entity0);

            Assert.AreEqual(true, m_Manager.HasComponent <Prefab>(entity0));
            Assert.AreEqual(false, m_Manager.HasComponent <Prefab>(entity1));

            var group  = m_Manager.CreateComponentGroup(ComponentType.ReadWrite <EcsTestData>());
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            group.Dispose();
            var count = ArchetypeChunkArray.CalculateEntityCount(chunks);

            chunks.Dispose();

            Assert.AreEqual(1, count);

            m_Manager.DestroyEntity(entity0);
            m_Manager.DestroyEntity(entity1);
        }
        public void DIS_FindDisabledIfRequestedInChunkIterator()
        {
            var archetype0 = m_Manager.CreateArchetype(typeof(EcsTestData));
            var archetype1 = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(Disabled));

            var entity0 = m_Manager.CreateEntity(archetype0);
            var entity1 = m_Manager.CreateEntity(archetype1);
            var entity2 = m_Manager.CreateEntity(archetype1);

            var group  = m_Manager.CreateEntityQuery(ComponentType.ReadWrite <EcsTestData>(), ComponentType.ReadWrite <Disabled>());
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            group.Dispose();
            var count = ArchetypeChunkArray.CalculateEntityCount(chunks);

            chunks.Dispose();

            Assert.AreEqual(2, count);

            m_Manager.DestroyEntity(entity0);
            m_Manager.DestroyEntity(entity1);
            m_Manager.DestroyEntity(entity2);
        }
        public void SIZ_TagCannotGetNativeArrayFromArchetypeChunk()
        {
            m_Manager.CreateEntity(typeof(EcsTestTag));
            var group  = m_Manager.CreateComponentGroup(ComponentType.ReadWrite <EcsTestTag>());
            var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob);

            group.Dispose();

            var tagType = m_Manager.GetArchetypeChunkComponentType <EcsTestTag>(false);

            Assert.AreEqual(1, ArchetypeChunkArray.CalculateEntityCount(chunks));

            for (int i = 0; i < chunks.Length; i++)
            {
                var chunk = chunks[i];
                Assert.IsTrue(chunk.Has(tagType));
                Assert.Throws <ArgumentException>(() =>
                {
                    chunk.GetNativeArray(tagType);
                });
            }

            chunks.Dispose();
        }