solveZombie method
void
solveZombie()
Implementation
void solveZombie() {
// removes particles with zombie flag
bool isZombie(Particle particle) {
return (particle.flags & ParticleType.zombieParticle) != 0;
}
_particles.removeWhere((p) {
if (isZombie(p)) {
if ((p.flags & ParticleType.destroyListener) != 0) {
world.particleDestroyListener?.onDestroyParticle(p);
}
return true;
}
return false;
});
proxyBuffer.removeWhere((proxy) => isZombie(proxy.particle));
contactBuffer.removeWhere((c) => [c.particleA, c.particleB].any(isZombie));
bodyContactBuffer.removeWhere((c) => isZombie(c.particle));
pairBuffer.removeWhere((p) => [p.particleA, p.particleB].any(isZombie));
triadBuffer.removeWhere(
(t) => [t.particleA, t.particleB, t.particleC].any(isZombie),
);
groupBuffer.removeWhere((g) {
g.particles.removeWhere(isZombie);
final toBeRemoved = g.destroyAutomatically && g.particles.isEmpty;
if (toBeRemoved) {
world.particleDestroyListener?.onDestroyParticleGroup(g);
}
return toBeRemoved;
});
// TODO(spydon): split the groups sometimes if they are rigid?
}