/// <summary> /// Renders the specified Emitter, applying the specified transformation offset. /// </summary> public override void RenderEmitter(Emitter emitter, ref FarTransform transform) { Guard.ArgumentNull("emitter", emitter); Guard.IsTrue(this.Batch == null, "SpriteBatchRenderer is not ready! Did you forget to LoadContent?"); if (emitter.ParticleTexture != null && emitter.ActiveParticlesCount > 0) { // Bail if the emitter blend mode is "None"... if (emitter.BlendMode == EmitterBlendMode.None) { return; } // Calculate the source rectangle and origin offset of the Particle texture... Rectangle source = new Rectangle(0, 0, emitter.ParticleTexture.Width, emitter.ParticleTexture.Height); Vector2 origin = new Vector2(source.Width / 2f, source.Height / 2f); BlendState blendState = this.GetBlendState(emitter.BlendMode); this.Batch.Begin(SpriteSortMode.Deferred, blendState, null, null, null, null, transform.Matrix); for (int i = 0; i < emitter.ActiveParticlesCount; i++) { Particle particle = emitter.Particles[i]; float scale = particle.Scale / emitter.ParticleTexture.Width; this.Batch.Draw(emitter.ParticleTexture, (Vector2)(particle.Position + transform.Translation), source, new Color(particle.Colour), particle.Rotation, origin, scale, SpriteEffects.None, 0f); } this.Batch.End(); } }
/// <summary> /// Renders the specified ParticleEffect, applying the specified transformation offset. /// </summary> public virtual void RenderEffect(ParticleEffect effect, ref FarTransform transform) { Guard.ArgumentNull("effect", effect); for (int i = 0; i < effect.Count; i++) { this.RenderEmitter(effect[i], ref transform); } }
/// <summary> /// Renders the specified Emitter, applying the specified transformation offset. /// </summary> public abstract void RenderEmitter(Emitter emitter, ref FarTransform transform);