internal override void ExecuteModifiers(UpdateContext updateContext, ParticleModifierCollection modifiers, ref ParticleBuffer.Iterator iterator)
 {
     foreach (ParticleModifier modifier in modifiers)
     {
         modifier.Process(updateContext, ref iterator);
         iterator.Reset();
     }
 }
 internal override void ExecuteModifiers(UpdateContext updateContext, ParticleModifierCollection modifiers, ref ParticleBuffer.Iterator iterator)
 {
     ParticleBuffer.Iterator iter = iterator; // make sure that the iterator is always copied, so that all modifiers don't concurrently process the same iterator
     System.Threading.Tasks.Parallel.ForEach(modifiers, modifier =>
     {
         ParticleBuffer.Iterator iterInner = iter; // make sure that the iterator is always copied, so that all modifiers don't concurrently process the same iterator
         modifier.Process(updateContext, ref iterInner);
     });
 }
        public void AddUpdateModifierTest()
        {
            var c = new ParticleModifierCollection { new TestModifierA(false, true) };

            Assert.AreEqual(0, c.ReleaseModifiers.Count());
            Assert.AreEqual(1, c.UpdateModifiers.Count());

            ConsistencyAsserts(c);
        }
        public void AddUpdateModifierTest()
        {
            var c = new ParticleModifierCollection {
                new TestModifierA(false, true)
            };

            Assert.AreEqual(0, c.ReleaseModifiers.Count());
            Assert.AreEqual(1, c.UpdateModifiers.Count());

            ConsistencyAsserts(c);
        }
 public void DeepCopyTest()
 {
     var c = new ParticleModifierCollection
     { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };
     ConsistencyAsserts(c);
     var copy = c.DeepCopy();
     ConsistencyAsserts(copy);
     Assert.IsTrue(c.ContainSameElements(copy));
     Assert.IsTrue(c.ReleaseModifiers.ContainSameElements(copy.ReleaseModifiers));
     Assert.IsTrue(c.UpdateModifiers.ContainSameElements(copy.UpdateModifiers));
 }
 public void AddNullTest()
 {
     var c = new ParticleModifierCollection
     { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };
     var initial = c.ToArray();
     Assert.IsTrue(c.ContainSameElements(initial));
     ConsistencyAsserts(c);
     c.Add(null);
     Assert.IsTrue(c.ContainSameElements(initial));
     ConsistencyAsserts(c);
 }
        public void ToListTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };

            var a = c.ToList();

            Assert.IsTrue(c.ContainSameElements(a));
            Assert.AreEqual(c.Count, a.Count);
        }
        public void AddNullTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };
            var initial = c.ToArray();

            Assert.IsTrue(c.ContainSameElements(initial));
            ConsistencyAsserts(c);
            c.Add(null);
            Assert.IsTrue(c.ContainSameElements(initial));
            ConsistencyAsserts(c);
        }
        public void RemoveUpdateModifierFromMiddleTest()
        {
            var item = new TestModifierA(false, true);
            var c    = new ParticleModifierCollection {
                new TestModifierA(true, true), item, new TestModifierA(true, true)
            };

            c.Remove(item);

            Assert.AreEqual(2, c.ReleaseModifiers.Count());
            Assert.AreEqual(2, c.UpdateModifiers.Count());

            ConsistencyAsserts(c);
        }
        public void RemoveOnlyUpdateModifierTest()
        {
            var item = new TestModifierA(false, true);
            var c    = new ParticleModifierCollection {
                item
            };

            c.Remove(item);

            Assert.AreEqual(0, c.ReleaseModifiers.Count());
            Assert.AreEqual(0, c.UpdateModifiers.Count());

            ConsistencyAsserts(c);
        }
        public void DeepCopyTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };

            ConsistencyAsserts(c);
            var copy = c.DeepCopy();

            ConsistencyAsserts(copy);
            Assert.IsTrue(c.ContainSameElements(copy));
            Assert.IsTrue(c.ReleaseModifiers.ContainSameElements(copy.ReleaseModifiers));
            Assert.IsTrue(c.UpdateModifiers.ContainSameElements(copy.UpdateModifiers));
        }
        static void ConsistencyAsserts(ParticleModifierCollection c)
        {
            Assert.AreEqual(c.Count(x => x.ProcessOnRelease), c.ReleaseModifiers.Count(), "Sub-list has too many or too few elements.");
            Assert.AreEqual(c.Count(x => x.ProcessOnUpdate), c.UpdateModifiers.Count(), "Sub-list has too many or too few elements.");

            Assert.IsTrue(c.Where(x => x.ProcessOnRelease).ContainSameElements(c.ReleaseModifiers), "Sub-list does not match main list for given value.");
            Assert.IsTrue(c.Where(x => x.ProcessOnUpdate).ContainSameElements(c.UpdateModifiers), "Sub-list does not match main list for given value.");

            Assert.IsFalse(c.Any(x => x == null), "Shouldn't be able to add null items.");

            Assert.AreEqual(c.HasReleaseModifiers, !c.ReleaseModifiers.IsEmpty());
            Assert.AreEqual(c.HasUpdateModifiers, !c.UpdateModifiers.IsEmpty());

            var concatDistinct = c.ReleaseModifiers.Concat(c.UpdateModifiers).Distinct();
            Assert.IsTrue(c.ContainSameElements(concatDistinct), "Sub-collections don't contain same items as main collection.");
        }
        public void RemoveModifierThatDoesNotExistTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };

            Assert.AreEqual(2, c.ReleaseModifiers.Count());
            Assert.AreEqual(2, c.UpdateModifiers.Count());
            ConsistencyAsserts(c);

            c.Remove(new TestModifierA(false, true));

            Assert.AreEqual(2, c.ReleaseModifiers.Count());
            Assert.AreEqual(2, c.UpdateModifiers.Count());
            ConsistencyAsserts(c);
        }
        static void ConsistencyAsserts(ParticleModifierCollection c)
        {
            Assert.AreEqual(c.Count(x => x.ProcessOnRelease), c.ReleaseModifiers.Count(), "Sub-list has too many or too few elements.");
            Assert.AreEqual(c.Count(x => x.ProcessOnUpdate), c.UpdateModifiers.Count(), "Sub-list has too many or too few elements.");

            Assert.IsTrue(c.Where(x => x.ProcessOnRelease).ContainSameElements(c.ReleaseModifiers), "Sub-list does not match main list for given value.");
            Assert.IsTrue(c.Where(x => x.ProcessOnUpdate).ContainSameElements(c.UpdateModifiers), "Sub-list does not match main list for given value.");

            Assert.IsFalse(c.Any(x => x == null), "Shouldn't be able to add null items.");

            Assert.AreEqual(c.HasReleaseModifiers, !c.ReleaseModifiers.IsEmpty());
            Assert.AreEqual(c.HasUpdateModifiers, !c.UpdateModifiers.IsEmpty());

            var concatDistinct = c.ReleaseModifiers.Concat(c.UpdateModifiers).Distinct();

            Assert.IsTrue(c.ContainSameElements(concatDistinct), "Sub-collections don't contain same items as main collection.");
        }
 internal abstract void ExecuteModifiers(UpdateContext updateContext, ParticleModifierCollection modifiers, ref ParticleBuffer.Iterator iterator);
        public void ToListTest()
        {
            var c = new ParticleModifierCollection
            { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };

            var a = c.ToList();
            Assert.IsTrue(c.ContainSameElements(a));
            Assert.AreEqual(c.Count, a.Count);
        }
        public void RemoveUpdateModifierFromMiddleTest()
        {
            var item = new TestModifierA(false, true);
            var c = new ParticleModifierCollection { new TestModifierA(true, true), item, new TestModifierA(true, true) };
            c.Remove(item);

            Assert.AreEqual(2, c.ReleaseModifiers.Count());
            Assert.AreEqual(2, c.UpdateModifiers.Count());

            ConsistencyAsserts(c);
        }
        public void RemoveOnlyUpdateModifierTest()
        {
            var item = new TestModifierA(false, true);
            var c = new ParticleModifierCollection { item };
            c.Remove(item);

            Assert.AreEqual(0, c.ReleaseModifiers.Count());
            Assert.AreEqual(0, c.UpdateModifiers.Count());

            ConsistencyAsserts(c);
        }
        public void RemoveModifierThatDoesNotExistTest()
        {
            var c = new ParticleModifierCollection
            { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };

            Assert.AreEqual(2, c.ReleaseModifiers.Count());
            Assert.AreEqual(2, c.UpdateModifiers.Count());
            ConsistencyAsserts(c);

            c.Remove(new TestModifierA(false, true));

            Assert.AreEqual(2, c.ReleaseModifiers.Count());
            Assert.AreEqual(2, c.UpdateModifiers.Count());
            ConsistencyAsserts(c);
        }