Esempio n. 1
0
        public void FixedArrayFromEntityWorks()
        {
            var entityInt = m_Manager.CreateEntity(ComponentType.FixedArray(typeof(int), 3));

            m_Manager.GetFixedArray <int>(entityInt).CopyFrom(new int[] { 1, 2, 3 });

            var intLookup = EmptySystem.GetFixedArrayFromEntity <int>();

            Assert.IsTrue(intLookup.Exists(entityInt));
            Assert.IsFalse(intLookup.Exists(new Entity()));

            Assert.AreEqual(2, intLookup[entityInt][1]);
        }
        public void JobProcessComponentGroupCorrect()
        {
            m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestData2));

            ComponentType[] expectedTypes = { ComponentType.ReadOnly <EcsTestData>(), ComponentType.Create <EcsTestData2>() };

            new Process2().Run(EmptySystem);
            new Process2().Run(EmptySystem);
            var group = EmptySystem.GetComponentGroup(expectedTypes);

            Assert.AreEqual(1, EmptySystem.ComponentGroups.Length);
            Assert.IsTrue(EmptySystem.ComponentGroups[0].CompareComponents(expectedTypes));
            Assert.AreEqual(group, EmptySystem.ComponentGroups[0]);
        }
Esempio n. 3
0
        public void GetComponentGroupWithDuplicates()
        {
            // Currently duplicates will create two seperate groups doing the same thing...
            ComponentType[] dup_1 = { typeof(EcsTestData2) };
            ComponentType[] dup_2 = { typeof(EcsTestData2), typeof(EcsTestData2) };

            var dup1_system = EmptySystem.GetComponentGroup(dup_1);
            var dup2_system = EmptySystem.GetComponentGroup(dup_2);

            Assert.AreEqual(dup1_system, EmptySystem.GetComponentGroup(dup_1));
            Assert.AreEqual(dup2_system, EmptySystem.GetComponentGroup(dup_2));

            Assert.AreEqual(2, EmptySystem.ComponentGroups.Length);
        }
Esempio n. 4
0
        public void ComponentDataArrayFromEntityThrowsIfNotExist()
        {
            var entity          = m_Manager.CreateEntity(typeof(EcsTestData));
            var destroyedEntity = m_Manager.CreateEntity(typeof(EcsTestData));

            m_Manager.DestroyEntity(destroyedEntity);

            var data = EmptySystem.GetComponentDataFromEntity <EcsTestData2>();

            Assert.Throws <System.ArgumentException>(() => { data[entity] = new EcsTestData2(); });
            Assert.Throws <System.ArgumentException>(() => { data[destroyedEntity] = new EcsTestData2(); });

            Assert.Throws <System.ArgumentException>(() => { var p = data[entity]; });
            Assert.Throws <System.ArgumentException>(() => { var p = data[destroyedEntity]; });
        }
Esempio n. 5
0
        public void GetComponentGroup()
        {
            ComponentType[] ro_rw = { ComponentType.ReadOnly <EcsTestData>(), typeof(EcsTestData2) };
            ComponentType[] rw_rw = { typeof(EcsTestData), typeof(EcsTestData2) };
            ComponentType[] rw    = { typeof(EcsTestData) };

            var ro_rw0_system = EmptySystem.GetComponentGroup(ro_rw);
            var rw_rw_system  = EmptySystem.GetComponentGroup(rw_rw);
            var rw_system     = EmptySystem.GetComponentGroup(rw);

            Assert.AreEqual(ro_rw0_system, EmptySystem.GetComponentGroup(ro_rw));
            Assert.AreEqual(rw_rw_system, EmptySystem.GetComponentGroup(rw_rw));
            Assert.AreEqual(rw_system, EmptySystem.GetComponentGroup(rw));

            Assert.AreEqual(3, EmptySystem.ComponentGroups.Length);
        }
Esempio n. 6
0
 public void GetComponentGroupWithEntityThrows()
 {
     ComponentType[] e = { typeof(Entity), typeof(EcsTestData) };
     EmptySystem.GetComponentGroup(e);
     Assert.Throws <ArgumentException>(() => EmptySystem.GetComponentGroup(e));
 }