// Particle Effect Blender.
// Worthless Bums 2012.


// Blends a particle effect in real time.
function blendParticleEffect (%particleEffect, %position,
							  %red, %green, %blue)
{//echo("blendParticleEffect()");
	// Make sure we have a valid particle effect object first!
	if (isObject(%particleEffect))
	{
		// Grab the particle effect color.
		%color = %particleEffect.getBlendColor();
		
		// Clone the specified particle effect.
		%explosion = %particleEffect.clone();
		%emitter = %explosion.findEmitterObject("NewEmitterName");
		
		%emitter.selectGraph("red_life");
		%emitter.clearDataKeys();
		// Add our keys.
		%emitter.addDataKey(1.0, getWord(%color, 0)); 
		
		%emitter.selectGraph("green_life");
		%emitter.clearDataKeys();
		// Add our keys.
		%emitter.addDataKey(1.0, getWord(%color, 1));           
		
		%emitter.selectGraph("blue_life" );
		%emitter.clearDataKeys();
		// Add our keys.
		%emitter.addDataKey(1.0, getWord(%color, 2));
		
		// Position and play.
		%explosion.position = %position;
		%explosion.playEffect();
		%explosion.setEffectLifeMode("Kill", 1.0);
	}
}