public virtual ushort GenerateConstantEmissionCount( float timeElapsed )
{
ushort intRequest;
float durMax = float.IsNaN( durationMin ) ? durationFixed : durationMax;
float repDelMax = float.IsNaN( repeatDelayMin ) ? repeatDelayFixed : repeatDelayMax;
if ( isEnabled )
{
// Keep fractions, otherwise a high frame rate will result in zero emissions!
remainder += emissionRate * timeElapsed;
intRequest = (ushort)remainder;
remainder -= intRequest;
// Check duration
if ( durMax > 0.0f )
{
durationRemain -= timeElapsed;
if ( durationRemain <= 0.0f )
{
// Disable, duration is out (takes effect next time)
this.IsEnabled = false;
}
}
return intRequest;
}
else
{
// Check repeat
if ( repDelMax > 0.0f )
{
repeatDelayRemain -= timeElapsed;
if ( repeatDelayRemain <= 0.0f )
{
// Enable, repeat delay is out (takes effect next time)
this.IsEnabled = true;
}
}
if ( startTime > 0.0f )
{
startTime -= timeElapsed;
if ( startTime <= 0.0f )
{
this.IsEnabled = true;
startTime = 0;
}
}
return 0;
}
}