+ i = m_particles.erase(i);
+ }
+}
+
+void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client,
+ LocalPlayer *player)
+{
+ switch (event->type) {
+ case CE_DELETE_PARTICLESPAWNER: {
+ MutexAutoLock lock(m_spawner_list_lock);
+ if (m_particle_spawners.find(event->delete_particlespawner.id) !=
+ m_particle_spawners.end()) {
+ delete m_particle_spawners.find(event->delete_particlespawner.id)->second;
+ m_particle_spawners.erase(event->delete_particlespawner.id);
+ }
+ // no allocated memory in delete event
+ break;
+ }
+ case CE_ADD_PARTICLESPAWNER: {
+ {
+ MutexAutoLock lock(m_spawner_list_lock);
+ if (m_particle_spawners.find(event->add_particlespawner.id) !=
+ m_particle_spawners.end()) {
+ delete m_particle_spawners.find(event->add_particlespawner.id)->second;
+ m_particle_spawners.erase(event->add_particlespawner.id);
+ }
+ }
+
+ video::ITexture *texture =
+ client->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
+
+ ParticleSpawner *toadd = new ParticleSpawner(client, player,
+ event->add_particlespawner.amount,
+ event->add_particlespawner.spawntime,
+ *event->add_particlespawner.minpos,
+ *event->add_particlespawner.maxpos,
+ *event->add_particlespawner.minvel,
+ *event->add_particlespawner.maxvel,
+ *event->add_particlespawner.minacc,
+ *event->add_particlespawner.maxacc,
+ event->add_particlespawner.minexptime,
+ event->add_particlespawner.maxexptime,
+ event->add_particlespawner.minsize,
+ event->add_particlespawner.maxsize,
+ event->add_particlespawner.collisiondetection,
+ event->add_particlespawner.collision_removal,
+ event->add_particlespawner.attached_id,
+ event->add_particlespawner.vertical,
+ texture,
+ event->add_particlespawner.id,
+ event->add_particlespawner.animation,
+ event->add_particlespawner.glow,
+ this);
+
+ /* delete allocated content of event */
+ delete event->add_particlespawner.minpos;
+ delete event->add_particlespawner.maxpos;
+ delete event->add_particlespawner.minvel;
+ delete event->add_particlespawner.maxvel;
+ delete event->add_particlespawner.minacc;
+ delete event->add_particlespawner.texture;
+ delete event->add_particlespawner.maxacc;
+
+ {
+ MutexAutoLock lock(m_spawner_list_lock);
+ m_particle_spawners.insert(
+ std::pair<u32, ParticleSpawner*>(
+ event->add_particlespawner.id,
+ toadd));
+ }
+ break;
+ }
+ case CE_SPAWN_PARTICLE: {
+ video::ITexture *texture =
+ client->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
+
+ Particle *toadd = new Particle(client, player, m_env,
+ *event->spawn_particle.pos,
+ *event->spawn_particle.vel,
+ *event->spawn_particle.acc,
+ event->spawn_particle.expirationtime,
+ event->spawn_particle.size,
+ event->spawn_particle.collisiondetection,
+ event->spawn_particle.collision_removal,
+ event->spawn_particle.vertical,
+ texture,
+ v2f(0.0, 0.0),
+ v2f(1.0, 1.0),
+ event->spawn_particle.animation,
+ event->spawn_particle.glow);
+
+ addParticle(toadd);
+
+ delete event->spawn_particle.pos;
+ delete event->spawn_particle.vel;
+ delete event->spawn_particle.acc;
+ delete event->spawn_particle.texture;
+
+ break;
+ }
+ default: break;
+ }
+}
+
+void ParticleManager::addDiggingParticles(IGameDef* gamedef,
+ LocalPlayer *player, v3s16 pos, const MapNode &n, const ContentFeatures &f)
+{
+ // No particles for "airlike" nodes
+ if (f.drawtype == NDT_AIRLIKE)
+ return;
+
+ // set the amount of particles here
+ for (u16 j = 0; j < 32; j++) {
+ addNodeParticle(gamedef, player, pos, n, f);