emit method
Returns the number of particles to emit over a step of length dt that
starts at system time time.
Implementation
int emit(double dt, double time) {
var count = 0;
if (rate > 0.0) {
_accumulator += rate * dt;
final whole = _accumulator.floor();
_accumulator -= whole;
count += whole;
}
if (bursts.isNotEmpty) {
final end = time + dt;
for (final burst in bursts) {
if (burst.interval > 0.0) {
// Occurrence k is at burst.time + k * interval; count those in the
// half-open window [time, end) directly rather than iterating cycles.
final inverse = 1.0 / burst.interval;
var first = ((time - burst.time) * inverse).ceil();
if (first < 0) first = 0;
var last = ((end - burst.time) * inverse).ceil() - 1;
final cycles = burst.cycles;
if (cycles != null && last > cycles - 1) last = cycles - 1;
if (last >= first) count += (last - first + 1) * burst.count;
} else if (burst.time >= time && burst.time < end) {
count += burst.count;
}
}
}
return count;
}