Changeset 5447 in orxonox.OLD for trunk/src/world_entities/weapons
- Timestamp:
- Oct 29, 2005, 1:14:24 PM (19 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/projectile.h
r5443 r5447 22 22 23 23 #include "world_entity.h" 24 #include "vector.h" 24 25 class FastFactory; 25 26 26 27 class Projectile : public WorldEntity -
trunk/src/world_entities/weapons/test_bullet.cc
r5446 r5447 18 18 #include "test_bullet.h" 19 19 20 #include "model.h"21 #include "vector.h"22 #include "garbage_collector.h"23 20 #include "fast_factory.h" 24 21 … … 34 31 using namespace std; 35 32 36 CREATE_FAST_FACTORY (TestBullet, CL_TEST_BULLET);33 CREATE_FAST_FACTORY_STATIC(TestBullet, CL_TEST_BULLET); 37 34 38 35 /** … … 51 48 this->lifeSpan = 5; 52 49 53 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 0.01);50 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); 54 51 this->emitter->setParent(this); 55 this->emitter->setEmissionRate(20);56 57 52 this->emitter->setSpread(M_2_PI); 58 53 } … … 67 62 68 63 /* this is normaly done by World.cc by deleting the ParticleEngine */ 64 if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 65 { 66 if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM)) 67 delete TestBullet::trailParticles; 68 TestBullet::trailParticles = NULL; 69 } 69 70 if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 70 71 { … … 76 77 } 77 78 79 ParticleSystem* TestBullet::trailParticles = NULL; 78 80 ParticleSystem* TestBullet::explosionParticles = NULL; 79 80 81 81 82 void TestBullet::activate() 82 83 { 83 84 State::getWorldEntityList()->add(this); 85 if (unlikely(TestBullet::trailParticles == NULL)) 86 { 87 TestBullet::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 88 TestBullet::trailParticles->setName("TestBulletTrailParticles"); 89 TestBullet::trailParticles->setLifeSpan(.5, .3); 90 TestBullet::trailParticles->setRadius(0.0, .5); 91 TestBullet::trailParticles->setRadius(0.5, 2.0); 92 TestBullet::trailParticles->setRadius(1.0, 5.0); 93 TestBullet::trailParticles->setColor(0.0, 1,0,0,.7); 94 TestBullet::trailParticles->setColor(0.5, .8,.8,0,.5); 95 TestBullet::trailParticles->setColor(1.0, .7,.7,.7,.0); 96 } 84 97 if (unlikely(TestBullet::explosionParticles == NULL)) 85 98 { 86 ClassList::debug(3, CL_PARTICLE_SYSTEM);87 99 TestBullet::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 88 TestBullet::explosionParticles->setName("TestBullet TrailParticles");100 TestBullet::explosionParticles->setName("TestBulletExplosionParticles"); 89 101 TestBullet::explosionParticles->setLifeSpan(.5, .3); 90 TestBullet::explosionParticles->setRadius(0.0, .5);91 TestBullet::explosionParticles->setRadius( 0.5, 2.0);92 TestBullet::explosionParticles->setRadius(1.0, 5.0);93 TestBullet::explosionParticles->setColor(0.0, 1,0,0,.7);102 TestBullet::explosionParticles->setRadius(0.0, 10); 103 TestBullet::explosionParticles->setRadius(.5, 20.0); 104 TestBullet::explosionParticles->setRadius(1.0, 3.0); 105 TestBullet::explosionParticles->setColor(0.0, 0,1,0,.7); 94 106 TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5); 95 TestBullet::explosionParticles->setColor(1.0, .7,.7,.7,.0);107 TestBullet::explosionParticles->setColor(1.0, 1,1,1,.0); 96 108 } 97 109 98 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles); 110 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::trailParticles); 111 112 this->emitter->setEmissionRate(20.0); 113 this->emitter->setEmissionVelocity(10.0); 99 114 } 100 115 … … 102 117 void TestBullet::deactivate() 103 118 { 104 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::explosionParticles); 119 ParticleEngine::getInstance()->breakConnections(this->emitter); 120 this->lifeCycle = 0.0; 105 121 106 GarbageCollector::getInstance()->collect(this); 107 this->lifeCycle = 0.0; 122 // GarbageCollector::getInstance()->collect(this); 123 State::getWorldEntityList()->remove(this); 124 TestBullet::fastFactory->kill(this); 108 125 } 109 126 … … 111 128 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location) 112 129 { 113 130 if (this->hitEntity != entity && entity->isA(CL_NPC)) 131 this->destroy(); 132 this->hitEntity = entity; 114 133 } 115 134 … … 125 144 126 145 this->lifeCycle += time/this->lifeSpan; 127 if( this->lifeCycle >= 1 )146 if( this->lifeCycle >= 1.0) 128 147 { 129 148 PRINTF(5)("FINALIZE==========================\n"); 130 149 PRINTF(5)("current life cycle is: %f\n", this->lifeCycle); 131 150 PRINTF(5)("FINALIZE===========================\n"); 132 // this->finalize(); 151 133 152 this->deactivate(); 134 153 } … … 140 159 void TestBullet::destroy () 141 160 { 142 this->deactivate(); 161 printf("DESTROY TestBullet\n"); 162 this->lifeCycle = .95; 163 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::trailParticles); 164 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles); 143 165 144 145 GarbageCollector::getInstance()->collect(this); 166 this->emitter->setEmissionRate(1000.0); 167 this->emitter->setEmissionVelocity(50.0); 168 // this->deactivate(); 146 169 147 170 } -
trunk/src/world_entities/weapons/test_bullet.h
r5443 r5447 13 13 class ParticleSystem; 14 14 class ParticleEmitter; 15 class FastFactory; 15 16 16 17 class TestBullet : public Projectile … … 33 34 34 35 private: 35 static ParticleSystem* explosionParticles; 36 ParticleEmitter* emitter; 36 static FastFactory* fastFactory; 37 static ParticleSystem* trailParticles; 38 static ParticleSystem* explosionParticles; 39 40 ParticleEmitter* emitter; 41 42 43 WorldEntity* hitEntity; // FIXME TEMPORARY 37 44 38 45 };
Note: See TracChangeset
for help on using the changeset viewer.