Ejemplo n.º 1
0
        public void GroupInvokesOnEntityRemovedAndOnEntityAddedWhenReplacingComponents()
        {
            SetupGroupEntities();

            var g = _defaultContext.GetGroup(matcherAB);
            var didDispatchRemoved = 0;
            var didDispatchAdded   = 0;
            var componentA         = new ComponentA();

            g.OnEntityRemoved += (group, entity, index, component) =>
            {
                Assert.AreEqual(g, group);
                Assert.AreEqual(eAB1, entity);
                Assert.AreEqual(MyTestComponentsLookup.ComponentA, index);
                Assert.AreEqual(Component.A, component);

                didDispatchRemoved++;
            };

            g.OnEntityAdded += (group, entity, index, component) =>
            {
                Assert.AreEqual(g, group);
                Assert.AreEqual(eAB1, entity);
                Assert.AreEqual(MyTestComponentsLookup.ComponentA, index);
                Assert.AreEqual(componentA, component);

                didDispatchAdded++;
            };
            eAB1.ReplaceComponentA(componentA);

            Assert.AreEqual(1, didDispatchRemoved);
            Assert.AreEqual(1, didDispatchAdded);
        }
Ejemplo n.º 2
0
        public void ReplacingNonExistentComponentAddsComponent()
        {
            _defaultEntity.ReplaceComponentA(Component.A);

            AssertHasComponentA(_defaultEntity);
        }