Changeset 2422 for code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ExplosionChunk.cc
- Timestamp:
- Dec 13, 2008, 2:55:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ExplosionChunk.cc
r2414 r2422 30 30 #include "ExplosionChunk.h" 31 31 32 #include "core/Core.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/Executor.h" … … 47 48 ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given."); 48 49 50 this->bStop_ = false; 49 51 this->LOD_ = LODParticle::normal; 50 52 … … 63 65 } 64 66 65 Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)); 66 velocity.normalise(); 67 velocity *= rnd(40, 60); 68 this->setVelocity(velocity); 67 if (Core::isMaster()) 68 { 69 Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)); 70 velocity.normalise(); 71 velocity *= rnd(60, 80); 72 this->setVelocity(velocity); 69 73 70 this->destroyTimer_.setTimer(rnd(1, 2), false, this, createExecutor(createFunctor(&ExplosionChunk::stop))); 74 this->destroyTimer_.setTimer(rnd(1, 2), false, this, createExecutor(createFunctor(&ExplosionChunk::stop))); 75 } 71 76 72 77 this->registerVariables(); … … 86 91 void ExplosionChunk::registerVariables() 87 92 { 88 REGISTERDATA(this->LOD_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged)); 93 REGISTERDATA(this->LOD_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged)); 94 REGISTERDATA(this->bStop_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop)); 89 95 } 90 96 … … 97 103 } 98 104 105 void ExplosionChunk::checkStop() 106 { 107 if (this->bStop_) 108 this->stop(); 109 } 110 99 111 void ExplosionChunk::stop() 100 112 { … … 104 116 this->smoke_->setEnabled(false); 105 117 106 this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&ExplosionChunk::destroy))); 118 if (Core::isMaster()) 119 { 120 this->bStop_ = true; 121 this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&ExplosionChunk::destroy))); 122 } 107 123 } 108 124 … … 116 132 static const unsigned int CHANGES_PER_SECOND = 5; 117 133 118 if ( rnd() < dt*CHANGES_PER_SECOND)134 if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND) 119 135 { 120 136 float length = this->getVelocity().length();
Note: See TracChangeset
for help on using the changeset viewer.