Changeset 6087 for code/branches/particles2/src/modules/weapons/projectiles
- Timestamp:
- Nov 18, 2009, 1:34:14 PM (15 years ago)
- Location:
- code/branches/particles2/src/modules/weapons/projectiles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
r6086 r6087 52 52 RegisterObject(Rocket);// - register the Rocket class to the core 53 53 54 this->setCollisionType(WorldEntity::Kinematic);55 this->setVelocity(0,0,-100);56 this->model_ = new Model(this);57 this->model_->setMeshSource("rocket_test.mesh");58 this->attach(this->model_);59 this->lifetime_ = 100;60 this->bDestroy_ = false;61 62 54 if (GameMode::isMaster()) 63 55 { 56 this->setCollisionType(WorldEntity::Kinematic); 57 this->setVelocity(0,0,-100); 58 this->lifetime_ = 100; 59 this->bDestroy_ = false; 60 61 this->model_ = new Model(this); 62 this->model_->setMeshSource("rocket_test.mesh"); 63 this->attach(this->model_); 64 64 65 this->enableCollisionCallback(); 65 66 this->setCollisionResponse(false); … … 76 77 this->camPosition_ = new CameraPosition(this); 77 78 this->camPosition_->setPosition(0,10,40); 79 this->camPosition_->setSyncMode(0x0); 78 80 this->attach( this->camPosition_ ); 79 81 this->addCameraPosition( this->camPosition_ ); … … 88 90 if(this->isInitialized()) 89 91 { 90 this->collisionShape_->destroy();91 this->model_->destroy();92 92 93 if (GameMode::isMaster() && this->player_) 93 if (GameMode::isMaster() && this->player_.get()) 94 { 95 this->model_->destroy(); 96 this->collisionShape_->destroy(); 94 97 this->player_->stopTemporaryControl(); 98 } 95 99 this->camPosition_->destroy(); 96 100 } … … 110 114 { 111 115 this->owner_ = owner; 112 113 116 this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity(); 114 117 this->player_ = this->owner_->getPlayer(); … … 126 129 SUPER(Rocket, tick, dt); 127 130 128 this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_); 129 this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() ); 130 this->localAngularVelocity_ = 0; 131 132 if( this->bDestroy_ ) 133 this->destroy(); 131 if( GameMode::isMaster() ) 132 { 133 this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_); 134 this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() ); 135 this->localAngularVelocity_ = 0; 136 137 if( this->bDestroy_ ) 138 this->destroy(); 139 } 134 140 } 135 141 … … 180 186 this->destroy(); 181 187 } 188 189 void Rocket::fire(unsigned int firemode) 190 { 191 if (this->owner_) 192 { 193 { 194 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 195 effect->setPosition(this->getPosition()); 196 effect->setOrientation(this->getOrientation()); 197 effect->setDestroyAfterLife(true); 198 effect->setSource("Orxonox/explosion3"); 199 effect->setLifetime(2.0f); 200 } 201 { 202 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 203 effect->setPosition(this->getPosition()); 204 effect->setOrientation(this->getOrientation()); 205 effect->setDestroyAfterLife(true); 206 effect->setSource("Orxonox/smoke4"); 207 effect->setLifetime(3.0f); 208 } 209 this->destroy(); 210 } 211 } 182 212 183 213 /** -
code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
r6082 r6087 110 110 inline float getDamage() const 111 111 { return this->damage_; } 112 virtual void fire(unsigned int firemode) { this->destroy(); }112 virtual void fire(unsigned int firemode); 113 113 114 114 private: … … 122 122 CameraPosition* camPosition_; 123 123 ConeCollisionShape* collisionShape_; 124 PlayerInfo*player_;124 WeakPtr<PlayerInfo> player_; 125 125 Timer destroyTimer_; 126 126 float lifetime_;
Note: See TracChangeset
for help on using the changeset viewer.