示例#1
0
        public void IterateOver_ThreeEntitiesTwoBlueprints()
        {
            var entityManager = new EntityManager();

            var entity  = entityManager.CreateEntity(typeof(Position), typeof(Velocity));
            var entity2 = entityManager.CreateEntity(typeof(Position));
            var entity3 = entityManager.CreateEntity(typeof(Position), typeof(Velocity));

            var blueprint  = entityManager.GetBlueprint(typeof(Position), typeof(Velocity));
            var blueprint2 = entityManager.GetBlueprint(typeof(Position));

            entityManager.GetComponent <Position>(entity).Value  = Vector3.UnitX;
            entityManager.GetComponent <Position>(entity2).Value = Vector3.UnitY;
            entityManager.GetComponent <Position>(entity3).Value = Vector3.UnitZ;

            var queryResult = new QueryResult();

            queryResult.AddBlueprint(blueprint2);
            queryResult.AddBlueprint(blueprint);

            var i = 0;

            foreach (ref readonly var idx in queryResult)
            {
                ++i;
            }

            i.Should().Be(3);
        }