public void Update(float frameTime)
        {
            if (IsFinished)
            {
                return;
            }

            time += frameTime;

            var nextStartTime        = startTime.NextNumber();
            var nextEmissionDuration = emissionDuration.NextNumber();

            if (time >= nextStartTime && (nextEmissionDuration == 0f || time <= nextStartTime + nextEmissionDuration))
            {
                var numToEmit = (int)Math.Floor((time - lastEmissionTime) / emitInterval);
                var emitCount = Math.Min(5 * emitRate.NextNumber(), numToEmit); // Limit the amount of particles to emit at once in case of refocus
                for (var i = 0; i < emitCount; i++)
                {
                    var particle = new Particle(baseProperties);
                    particle.ParticleCount = ++particleCount;
                    particleEmitCallback(particle);
                }

                lastEmissionTime += numToEmit * emitInterval;
            }
        }
Ejemplo n.º 2
0
        public void Update(float frameTime)
        {
            time += frameTime;

            if (!IsFinished && time >= startTime.NextNumber())
            {
                var numToEmit = emitCount.NextInt(); // Get value from number provider
                for (var i = 0; i < numToEmit; i++)
                {
                    particleEmitCallback();
                }

                IsFinished = true;
            }
        }
        public ContinuousEmitter(IKeyValueCollection baseProperties, IKeyValueCollection keyValues)
        {
            this.baseProperties = baseProperties;

            if (keyValues.ContainsKey("m_flEmissionDuration"))
            {
                emissionDuration = keyValues.GetNumberProvider("m_flEmissionDuration");
            }

            if (keyValues.ContainsKey("m_flStartTime"))
            {
                startTime = keyValues.GetNumberProvider("m_flStartTime");
            }

            if (keyValues.ContainsKey("m_flEmitRate"))
            {
                emitRate     = keyValues.GetNumberProvider("m_flEmitRate");
                emitInterval = 1.0f / (float)emitRate.NextNumber();
            }
        }
Ejemplo n.º 4
0
 public static int NextInt(this INumberProvider numberProvider)
 {
     return((int)numberProvider.NextNumber());
 }