Changeset 9939 for code/trunk/src/orxonox/worldentities
- Timestamp:
- Dec 21, 2013, 11:16:54 PM (11 years ago)
- Location:
- code/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/BigExplosion.cc
r9667 r9939 43 43 RegisterClass(BigExplosion); 44 44 45 BigExplosion::BigExplosion(Context* context) : StaticEntity(context)45 BigExplosion::BigExplosion(Context* context) : MobileEntity(context) 46 46 { 47 47 RegisterObject(BigExplosion); 48 49 if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) ) 50 ThrowException(AbortLoading, "Can't create BigExplosion, no scene or no scene manager given."); 51 52 this->bStop_ = false; 53 this->LOD_ = LODParticle::Normal; 54 55 if ( GameMode::showsGraphics() ) 56 { 57 try 58 { 59 this->init(); 60 } 61 catch (const std::exception& ex) 62 { 63 orxout(internal_error) << "Couldn't load particle effect in BigExplosion: " << ex.what() << endl; 64 this->initZero(); 65 } 66 } 67 else 68 { 69 this->initZero(); 70 } 71 72 if (GameMode::isMaster()) 73 { 74 this->destroyTimer_.setTimer(rnd(2, 4), false, createExecutor(createFunctor(&BigExplosion::stop, this))); 75 } 76 77 this->registerVariables(); 78 } 79 80 BigExplosion::BigExplosion(Context* context, Vector3 initVelocity) : MobileEntity(context) 81 { 82 RegisterObject(BigExplosion); 83 this->setVelocity(initVelocity); 48 84 49 85 if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) ) … … 100 136 this->debris4_->setSyncMode(0); 101 137 102 this->explosion_ = new StaticEntity(this->getContext());138 this->explosion_ = new MobileEntity(this->getContext()); 103 139 this->explosion_->setSyncMode(0); 104 140 … … 148 184 this->debrisEntity4_->attach(debris4_); 149 185 186 // /////////////////////// 187 // TODO: particleSpawner is a static entity. It should probably be dynamic, for better explosions. 188 // 150 189 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 190 orxout() << "vel " << this->getVelocity() << endl; 191 // effect->setVelocity(this->getVelocity()); 151 192 effect->setDestroyAfterLife(true); 152 193 effect->setSource("Orxonox/explosion2b"); … … 155 196 156 197 ParticleSpawner* effect2 = new ParticleSpawner(this->getContext()); 198 // effect2->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10, 200)); 157 199 effect2->setDestroyAfterLife(true); 158 200 effect2->setSource("Orxonox/smoke6"); -
code/trunk/src/orxonox/worldentities/BigExplosion.h
r9667 r9939 22 22 * Author: 23 23 * Benjamin de Capitani 24 * Co-authors: 24 * Co-authors:§ 25 25 * ... 26 26 * … … 33 33 34 34 #include "tools/Timer.h" 35 #include " StaticEntity.h"35 #include "MobileEntity.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport BigExplosion : public StaticEntity39 class _OrxonoxExport BigExplosion : public MobileEntity 40 40 { 41 41 public: 42 42 BigExplosion(Context* context); 43 BigExplosion(Context* context, Vector3 initVelocity); 43 44 virtual ~BigExplosion(); 44 45 … … 60 61 bool bStop_; 61 62 62 StaticEntity* explosion_;63 MobileEntity* explosion_; 63 64 64 65 MovableEntity* debrisEntity1_; -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r9667 r9939 46 46 #include "weaponsystem/WeaponPack.h" 47 47 #include "weaponsystem/WeaponSet.h" 48 #include "sound/WorldSound.h" 48 49 49 50 #include "controllers/FormationController.h" … … 100 101 101 102 this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition 103 104 if (GameMode::isMaster()) 105 { 106 this->explosionSound_ = new WorldSound(this->getContext()); 107 this->explosionSound_->setVolume(1.0f); 108 } 109 else 110 { 111 this->explosionSound_ = 0; 112 } 102 113 } 103 114 … … 109 120 this->weaponSystem_->destroy(); 110 121 } 122 111 123 } 112 124 … … 135 147 XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); 136 148 149 XMLPortParam(Pawn, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode); 150 137 151 XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode ); 138 152 } 153 139 154 140 155 void Pawn::registerVariables() … … 290 305 void Pawn::kill() 291 306 { 292 307 this->damage(this->health_); 293 308 this->death(); 294 309 } … … 314 329 if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 315 330 { 316 // Set bAlive_ to false and wait for PawnManager to do the destruction 331 explosionSound_->play(); 332 // Set bAlive_ to false and wait for PawnManager to do the destruction 317 333 this->bAlive_ = false; 318 334 … … 365 381 this->setDestroyWhenPlayerLeft(false); 366 382 367 BigExplosion* chunk = new BigExplosion(this->getContext()); 383 orxout() << "big explosion: " << this->getVelocity() << endl; 384 BigExplosion* chunk = new BigExplosion(this->getContext(), this->getVelocity()); 368 385 chunk->setPosition(this->getPosition()); 386 // chunk->setVelocity(this->getVelocity()); 369 387 370 388 } … … 376 394 effect->setPosition(this->getPosition()); 377 395 effect->setOrientation(this->getOrientation()); 396 effect->setVelocity(this->getVelocity()); 378 397 effect->setDestroyAfterLife(true); 379 398 effect->setSource("Orxonox/explosion2b"); … … 384 403 effect->setPosition(this->getPosition()); 385 404 effect->setOrientation(this->getOrientation()); 405 effect->setVelocity(this->getVelocity()); 386 406 effect->setDestroyAfterLife(true); 387 407 effect->setSource("Orxonox/smoke6"); … … 392 412 effect->setPosition(this->getPosition()); 393 413 effect->setOrientation(this->getOrientation()); 414 effect->setVelocity(this->getVelocity()); 394 415 effect->setDestroyAfterLife(true); 395 416 effect->setSource("Orxonox/sparks"); … … 527 548 528 549 550 void Pawn::setExplosionSound(const std::string &explosionSound) 551 { 552 if(explosionSound_ ) 553 explosionSound_->setSource(explosionSound); 554 else 555 assert(0); // This should never happen, because soundpointer is only available on master 556 } 557 558 const std::string& Pawn::getExplosionSound() 559 { 560 if( explosionSound_ ) 561 return explosionSound_->getSource(); 562 else 563 assert(0); 564 return BLANKSTRING; 565 } 566 529 567 530 568 } -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r9667 r9939 36 36 #include "interfaces/RadarViewable.h" 37 37 #include "worldentities/ControllableEntity.h" 38 38 39 39 40 namespace orxonox // tolua_export … … 178 179 virtual void changedVisibility(); 179 180 181 void setExplosionSound(const std::string& engineSound); 182 const std::string& getExplosionSound(); 183 180 184 protected: 181 185 virtual void preDestroy(); … … 231 235 232 236 Vector3 aimPosition_; 237 238 WorldSound* explosionSound_; 239 233 240 }; // tolua_export 234 241 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.