public override ComponentQuery GetQuery()
 {
     posQuery.IncludeReadonly <Position>();
     posQuery.Exclude <Rotation>();
     posQuery.Exclude <Scale>();
     posQuery.IncludeReadWrite <ObjectToWorld>();
     return(posQuery);
 }
Example #2
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <RigidBody>();
            query.IncludeReadonly <InternalColliderHandle>();
            query.Exclude <InternalRigidBodyHandle>();
            query.Exclude <StaticRigidBody>();
            return(query);
        }
        public void HashCodeSame()
        {
            ComponentQuery query1 = new ComponentQuery();

            query1.IncludeReadWrite <TestComponent1>();
            ComponentQuery query2 = new ComponentQuery();

            query2.IncludeReadWrite <TestComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());

            query1 = new ComponentQuery();
            query1.Exclude <TestComponent1>();
            query2 = new ComponentQuery();
            query2.Exclude <TestComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());

            query1 = new ComponentQuery();
            query1.IncludeShared <SharedComponent1>();
            query2 = new ComponentQuery();
            query2.IncludeShared <SharedComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());

            query1 = new ComponentQuery();
            query1.ExcludeShared <SharedComponent1>();
            query2 = new ComponentQuery();
            query2.ExcludeShared <SharedComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());
        }
Example #4
0
        public void RemoveComponentFromEntity()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1   = new SharedComponent1();
            EntityArchetype  archetype = EntityArchetype.Empty;

            archetype = archetype.Add <TestComponent1>();
            archetype = archetype.AddShared(shared1);

            Entity target = world.Instantiate(archetype);

            buffer.RemoveComponent <TestComponent1>(target);
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.Exclude <TestComponent1>();
            query.IncludeShared <SharedComponent1>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
            });
        }
Example #5
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeShared <MeshCollider>();
            query.Exclude <InternalColliderHandle>();
            return(query);
        }
Example #6
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <BoxCollider>();
            query.Exclude <InternalColliderHandle>();
            return(query);
        }
Example #7
0
        public override ComponentQuery GetQuery()
        {
            var query = new ComponentQuery();

            query.IncludeReadonly <PhysicsBodyLockAxis>();
            query.Exclude <PhysicsBodyLockedValues>();

            return(query);
        }
        public void Exclude()
        {
            ComponentQuery query = new ComponentQuery();

            query.Exclude <TestComponent2>();

            Assert.True(query.Matches(archetypeEmpty));
            Assert.False(query.Matches(archetypeC1C2S1));
            Assert.False(query.Matches(archetypeC1C2S1S2));
            Assert.True(query.Matches(archetypeC1));
            Assert.False(query.Matches(archetypeC1C2));
            Assert.True(query.Matches(archetypeC1S1));
            Assert.False(query.Matches(archetypeC2S1));
        }
        public void IncludeExcludeAll()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponent1>();
            query.Exclude <TestComponent2>();
            query.IncludeShared <SharedComponent1>();
            query.ExcludeShared <SharedComponent2>();

            Assert.False(query.Matches(archetypeEmpty));
            Assert.False(query.Matches(archetypeC1C2S1));
            Assert.False(query.Matches(archetypeC1C2S1S2));
            Assert.False(query.Matches(archetypeC1));
            Assert.False(query.Matches(archetypeC1C2));
            Assert.True(query.Matches(archetypeC1S1));
            Assert.False(query.Matches(archetypeC2S1));
        }
        public void HashCodeNotZero()
        {
            ComponentQuery query1 = new ComponentQuery();

            query1.IncludeReadWrite <TestComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());

            query1 = new ComponentQuery();
            query1.Exclude <TestComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());

            query1 = new ComponentQuery();
            query1.IncludeShared <SharedComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());

            query1 = new ComponentQuery();
            query1.ExcludeShared <SharedComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());
        }
Example #11
0
        public void CreateEntityAddComponent()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1 = new SharedComponent1();
            Prefab           prefab  = new Prefab();

            prefab.AddComponent(new TestComponentVector3()
            {
                value = Vector3.UnitY
            });
            prefab.AddSharedComponent(shared1);


            buffer.CreateEntity(prefab);
            buffer.CreateEntity(prefab);
            buffer.AddComponent(new TestComponent2()
            {
                i = 1, d = 2, f = 3
            });
            buffer.CreateEntity(prefab.Archetype);
            buffer.AddComponent(new TestComponent1()
            {
                i = 1, d = 2, f = 3
            });
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponentVector3>();
            query.Exclude <TestComponent2>();
            query.Exclude <TestComponent1>();
            query.IncludeShared <SharedComponent1>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
                var cData = accessor.GetComponentData <TestComponentVector3>();
                Assert.Equal(Vector3.UnitY, cData[0].value);

                var shared = accessor.GetSharedComponentData <SharedComponent1>();
                Assert.Same(shared1, shared);
            });

            query.IncludeReadWrite <TestComponent2>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
                var cData = accessor.GetComponentData <TestComponentVector3>();
                Assert.Equal(Vector3.UnitY, cData[0].value);
                var cData2 = accessor.GetComponentData <TestComponent2>();
                Assert.Equal(1, cData2[0].i);
                Assert.Equal(2d, cData2[0].d, 3);
                Assert.Equal(3f, cData2[0].f, 3);

                var shared = accessor.GetSharedComponentData <SharedComponent1>();
                Assert.Same(shared1, shared);
            });

            query.IncludeReadWrite <TestComponent1>();
            query.Exclude <TestComponent2>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
                var cData = accessor.GetComponentData <TestComponentVector3>();
                Assert.Equal(Vector3.Zero, cData[0].value);
                var cData2 = accessor.GetComponentData <TestComponent1>();
                Assert.Equal(1, cData2[0].i);
                Assert.Equal(2d, cData2[0].d, 3);
                Assert.Equal(3f, cData2[0].f, 3);

                var shared = accessor.GetSharedComponentData <SharedComponent1>();
                Assert.Same(shared1, shared);
            });
        }