diff options
Diffstat (limited to 'src/render/renderext.cc')
-rw-r--r-- | src/render/renderext.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/render/renderext.cc b/src/render/renderext.cc index 51b7976..20c4cae 100644 --- a/src/render/renderext.cc +++ b/src/render/renderext.cc @@ -26,6 +26,7 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re state_detailvisible = false; state_fuzz = math::randomf(); state_enginetime = state_fuzz * core::application()->time(); + state_explosion = 0; if (!entity->model() && entity->modelname().size()) { entity->set_modelname(entity->modelname()); @@ -64,12 +65,15 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re if ( script->type() == render::ParticleScript::Trail) { Trail *trail = new Trail(script, entity, particlesystem); state_particles.push_back(trail); + } else if (script->type() == render::ParticleScript::Jet) { Jet *jet = new Jet(script, entity, particlesystem); state_particles.push_back(jet); + } else if (script->type() == render::ParticleScript::Spray) { Spray *spray = new Spray(script, entity, particlesystem); state_particles.push_back(spray); + } else if (script->type() == render::ParticleScript::Flame) { Flame *flame = new Flame(script, entity, particlesystem); state_particles.push_back(flame); @@ -118,9 +122,11 @@ void RenderExt::frame(float elapsed) if (!state_visible) return; + int state = core::Entity::Normal; + if (entity()->type() == core::Entity::Dynamic) { - int state = static_cast<core::EntityDynamic *>(entity())->state(); + state = static_cast<core::EntityDynamic *>(entity())->state(); if ((state == core::Entity::NoPower) || (state == core::Entity::Destroyed)) { state_power = false; @@ -131,6 +137,8 @@ void RenderExt::frame(float elapsed) } else if ((entity()->type() == core::Entity::Controlable)) { core::EntityControlable *controlable = static_cast<core::EntityControlable *>(entity()); + + state = controlable->state(); if (controlable->state() == core::Entity::Docked) { state_visible = false; @@ -159,6 +167,29 @@ void RenderExt::frame(float elapsed) state_enginetime += elapsed; } + if (state == core::Entity::Destroyed) { + + if (!state_explosion) { + // add explosion + const ParticleScript *script = ParticleScript::load("explosion"); + if (script) { + state_explosion = (ParticleSystem *) new Spray(script, entity(), 0); + state_particles.push_back(state_explosion); + } + } + + } else { + if (state_explosion) { + // remove explosion + for (ParticleSystems::iterator it = particles().begin(); state_explosion && (it != particles().end()); it++) { + if ((*it) == state_explosion) { + particles().erase(it); + state_explosion = 0; + } + } + } + } + if (entity()->model()) { if (distance() < core::range::fxdistance) { |