PerfTimer updateTimer = new PerfTimer("ParticleSystemManager");     // Will update every 1 second (the default).
#endif
        public void Update()
        {
#if UPDATE_TIMERS
            updateTimer.Start();
#endif

            ExplosionManager.Update();

            int newNumParticles = 0;
            for (int i = 0; i < emitterList.Count; i++)
            {
                BaseEmitter emitter = emitterList[i];
                if (emitter != null)
                {
                    emitter.Update();

                    newNumParticles += emitter.ParticleCount();
                }
            }
            numParticles = newNumParticles;

#if UPDATE_TIMERS
            updateTimer.Stop();
#endif
        }   // end of ParticleSystemManager Update()
        }   // end of ParticleSystemManager Render()

        public void Render(Camera camera, BaseEmitter.Use usage)
        {
            for (int i = 0; i < emitterList.Count; i++)
            {
                BaseEmitter emitter = emitterList[i];
                if ((emitter != null) && emitter.HasUsage(usage))
                {
                    emitter.Render(camera);
                }
            }
        }   // end of ParticleSystemManager Render()
        }   // end of ParticleSystemManager Render()

        public void AddEmitter(BaseEmitter emitter)
        {
            if (!emitter.InManager)
            {
                if (emitter.HasUsage(BaseEmitter.Use.Distort))
                {
                    ++numPartyDistort;
                }
                emitter.InManager = true;
                emitterList.Add(emitter);
            }
        }   // end of ParticleSystemManager AddEmitter()
        }   // end of ParticleSystemManager AddEmitter()

        public void RemoveEmitter(BaseEmitter emitter)
        {
            if (emitter.InManager)
            {
                emitterList.Remove(emitter);
                emitter.FlushAllParticles();
                emitter.InManager = false;
                if (emitter.HasUsage(BaseEmitter.Use.Distort))
                {
                    --numPartyDistort;
                }
            }
        }   // end of ParticleSystemManager RemoveEmitter()
        }   // end of ParticleSystemManager RemoveEmitter()

        /// <summary>
        /// Removes all emitters from the manager except those that
        /// are persistent.  These are flushed.
        /// </summary>
        public void ClearAllEmitters()
        {
            int cnt = emitterList.Count;

            for (int i = cnt - 1; i >= 0; --i)
            {
                BaseEmitter e = emitterList[i];
                e.FlushAllParticles();
                if (!e.Persistent)
                {
                    emitterList.RemoveAt(i);

                    e.InManager = false;

                    if (e.HasUsage(BaseEmitter.Use.Distort))
                    {
                        --numPartyDistort;
                    }
                }
            }
            numParticles = 0;
        }   // end of ParticleSystemManager ClearAllEmitters()