/// <summary>
        /// Initializes the <see cref="ParticleEmitterFactory"/> class.
        /// </summary>
        static ParticleEmitterFactory()
        {
            // Create the filter
            var filterCreator = new TypeFilterCreator
            {
                IsClass               = true,
                IsAbstract            = false,
                RequireConstructor    = true,
                ConstructorParameters = new Type[] { typeof(IParticleEffect) },
                Subclass              = typeof(ParticleEmitter)
            };

            _particleEmitterFilter = filterCreator.GetFilter();

            // Create the factory instance
            _instance = new ParticleEmitterFactory();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the <see cref="ParticleEmitterFactory"/> class.
        /// </summary>
        static ParticleEmitterFactory()
        {
            // Create the filter
            var filterCreator = new TypeFilterCreator
            {
                IsClass = true,
                IsAbstract = false,
                RequireConstructor = true,
                ConstructorParameters = new Type[] { typeof(IParticleEffect) },
                Subclass = typeof(ParticleEmitter)
            };

            _particleEmitterFilter = filterCreator.GetFilter();

            // Create the factory instance
            _instance = new ParticleEmitterFactory();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            reader = reader.ReadNode(_particleEffectNodeName);

            // Clear the emitters
            foreach (var e in _emitters.ToImmutable())
            {
                e.Dispose();
            }

            Debug.Assert(_emitters.IsEmpty());
            _emitters.Clear();

            // Read the effect properties
            PersistableHelper.Read(this, reader);

            // Read the emitters
            var readEmitters = reader.ReadManyNodes(_emittersNodeName, r => ParticleEmitterFactory.Read(r, this));

            Debug.Assert(readEmitters.All(x => x.Owner == this));
        }