Пример #1
0
        public void GetByIndex()
        {
            ComponentArray <Component2> array = new ComponentArray <Component2>();

            array.UpdateChunks(ref chunks);
            var arrayCount = 30;

            for (int i = 0; i < arrayCount; i++)
            {
                Assert.AreEqual(i, array[i].Value);
            }
        }
Пример #2
0
        public void UpdateChunks()
        {
            ComponentArray <Component2> array = new ComponentArray <Component2>();
            var typeIndex = ComponentType.Create <Component2>().TypeIndex;

            Assert.AreEqual(typeIndex, array.TypeIndex);
            array.UpdateChunks(ref chunks);
            Assert.AreEqual(3, array.componentDatas.Length);
            Assert.AreEqual(array.componentDatas[0], chunks[0].ComponentDatas[typeIndex]);
            Assert.AreEqual(array.componentDatas[1], chunks[1].ComponentDatas[typeIndex]);
            Assert.AreEqual(array.componentDatas[2], chunks[2].ComponentDatas[typeIndex]);
        }
Пример #3
0
        public void GetByEnumerator()
        {
            Group group = new Group();

            group.Chunks = chunks;
            ComponentArray <Component2> array = new ComponentArray <Component2>();

            array.UpdateChunks(ref chunks);
            var enumerator = new EntityIterator();

            enumerator.ApplyGroup(group);

            int entityCount = 0;

            while (enumerator.MoveNext())
            {
                var component = array.Get(enumerator);
                Assert.AreEqual(entityCount, component.Value);
                ++entityCount;
            }
        }