Ejemplo n.º 1
0
        public void CorrectWorkWithOneEntityManyComponent()
        {
            ecsManager.Register <AddValueProcessing>();
            ecsManager.Register <MinusProcessing>();
            var entitySystems = ecsManager.Init();

            var entity            = ecsManager.CreateEntity();
            var valueAddComponent = new ValueAddComponent {
                Value = 0
            };
            var valueMinusComponent = new ValueMinusComponent {
                Value = 0
            };

            ecsManager.EntityManager.AddComponent(entity, valueAddComponent);
            ecsManager.EntityManager.AddComponent(entity, valueMinusComponent);

            for (var i = 0; i < 5; i++)
            {
                entitySystems.OnUpdate();
            }

            Assert.AreEqual(5, valueAddComponent.Value);
            Assert.AreEqual(-5, valueMinusComponent.Value);
        }
Ejemplo n.º 2
0
        public void CorrectWorkWithTwoEntity_OneComponentAddedLater()
        {
            ecsManager.Register <AddValueProcessing>();
            var entitySystems = ecsManager.Init();

            var entityA            = ecsManager.CreateEntity();
            var entityB            = ecsManager.CreateEntity();
            var valueAddComponentA = new ValueAddComponent {
                Value = 0
            };
            var valueAddComponentB = new ValueAddComponent {
                Value = 0
            };

            ecsManager.EntityManager.AddComponent(entityB, valueAddComponentB);

            for (var i = 0; i < 5; i++)
            {
                entitySystems.OnUpdate();
            }

            ecsManager.EntityManager.AddComponent(entityA, valueAddComponentA);

            for (var i = 0; i < 5; i++)
            {
                entitySystems.OnUpdate();
            }

            Assert.AreEqual(5, valueAddComponentA.Value);
            Assert.AreEqual(10, valueAddComponentB.Value);
        }
Ejemplo n.º 3
0
        public void CorrectWorkWithOneEntity_OneComponentRemoveLater()
        {
            ecsManager.Register <AddValueProcessing>();
            var entitySystems = ecsManager.Init();

            var entity            = ecsManager.CreateEntity();
            var valueAddComponent = new ValueAddComponent {
                Value = 0
            };

            ecsManager.EntityManager.AddComponent(entity, valueAddComponent);

            entitySystems.OnUpdate();
            ecsManager.EntityManager.RemoveComponent <ValueAddComponent>(entity);

            entitySystems.OnUpdate();

            Assert.AreEqual(1, valueAddComponent.Value);
        }