Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-14 10:10:55 +0000
committerStijn Buys <ingar@osirion.org>2012-10-14 10:10:55 +0000
commit5227a260a893c0562f93f994f6b94b310ddc4f73 (patch)
tree3ab36e2a36d1ea6715c43653ad8ad3f85f9b4409 /src/render/renderext.cc
parent97d79a827ef4978df15fa117e013817dbcde1d09 (diff)
Render a generic explosion effect for destroyed entities.
Diffstat (limited to 'src/render/renderext.cc')
-rw-r--r--src/render/renderext.cc33
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) {