Changeset 6101
- Timestamp:
- Nov 20, 2009, 1:02:09 AM (15 years ago)
- Location:
- code/branches/particles2/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
r6098 r6101 137 137 SUPER(Rocket, tick, dt); 138 138 139 if( GameMode::isMaster() )139 if( this->hasLocalController() ) 140 140 { 141 141 this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_); … … 196 196 } 197 197 198 void Rocket::fire (unsigned int firemode)198 void Rocket::fired(unsigned int firemode) 199 199 { 200 200 if (this->owner_) -
code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
r6087 r6101 110 110 inline float getDamage() const 111 111 { return this->damage_; } 112 virtual void fire (unsigned int firemode);112 virtual void fired(unsigned int firemode); 113 113 114 114 private: -
code/branches/particles2/src/orxonox/controllers/AIController.cc
r6087 r6101 109 109 110 110 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f)) 111 //this->getControllableEntity()->fire(0);111 this->getControllableEntity()->fire(0); 112 112 113 113 SUPER(AIController, tick, dt); -
code/branches/particles2/src/orxonox/controllers/HumanController.cc
r5929 r6101 145 145 void HumanController::fire(unsigned int firemode) 146 146 { 147 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)147 if( HumanController::localController_s && HumanController::localController_s->controllableEntity_ ) 148 148 HumanController::localController_s->controllableEntity_->fire(firemode); 149 149 } -
code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
r6087 r6101 51 51 this->controllableEntity_ = 0; 52 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->temporaryControllableEntity_ = 0; 54 this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0; 55 54 56 55 this->gtinfo_ = 0; … … 82 81 registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 83 82 registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 84 registerVariable(this->temporaryControllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));85 registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);86 83 registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID)); 87 84 } … … 151 148 return; 152 149 150 if (this->oldControllableEntity_) 151 this->stopTemporaryControl(); 153 152 if (this->controllableEntity_) 154 153 this->stopControl(); … … 172 171 return; 173 172 174 assert( this->temporaryControllableEntity_==0 ); 175 176 this->temporaryControllableEntity_ = entity; 177 this->temporaryControllableEntityID_ = entity->getObjectID(); 173 // assert( this->temporaryControllableEntity_==0 ); 174 175 this->oldControllableEntity_ = this->controllableEntity_; 176 this->controllableEntity_ = entity; 177 this->controllableEntityID_ = entity->getObjectID(); 178 178 179 179 entity->setPlayer(this); 180 180 181 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);182 183 181 if (this->controller_) 184 182 this->controller_->setControllableEntity(entity); … … 189 187 void PlayerInfo::stopControl() 190 188 { 189 if ( this->oldControllableEntity_ ) 190 this->stopTemporaryControl(); 191 191 192 ControllableEntity* entity = this->controllableEntity_; 192 193 … … 200 201 this->controller_->setControllableEntity(0); 201 202 202 entity->removePlayer(); 203 if ( GameMode::isMaster() ) 204 entity->removePlayer(); 203 205 204 206 this->changedControllableEntity(); … … 207 209 void PlayerInfo::stopTemporaryControl() 208 210 { 209 ControllableEntity* entity = this->temporaryControllableEntity_; 210 211 if (!entity) 212 return; 213 214 this->temporaryControllableEntity_ = 0; 215 this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN; 211 ControllableEntity* entity = this->controllableEntity_; 212 213 if (!entity || !this->oldControllableEntity_) 214 return; 215 216 this->controllableEntity_ = this->oldControllableEntity_; 217 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 218 this->oldControllableEntity_ = 0; 216 219 217 220 if ( this->controllableEntity_ && this->controller_) 218 221 this->controller_->setControllableEntity(this->controllableEntity_); 219 222 220 entity->removePlayer(); 223 if ( GameMode::isMaster() ) 224 entity->removePlayer(); 221 225 222 226 this->changedControllableEntity(); … … 237 241 } 238 242 239 void PlayerInfo::networkcallback_changedtemporarycontrollableentityID()240 {241 CCOUT(0) << "changedtemporarycontrollableentityid" << endl;242 if (this->temporaryControllableEntityID_ != OBJECTID_UNKNOWN)243 {244 Synchronisable* temp = Synchronisable::getSynchronisable(this->temporaryControllableEntityID_);245 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(temp);246 this->startTemporaryControl(entity);247 }248 else249 {250 this->stopTemporaryControl();251 }252 }253 254 243 255 244 void PlayerInfo::networkcallback_changedgtinfoID() 256 245 { 257 CCOUT(0) << "changedcontrollableentityid" << endl;258 246 if (this->gtinfoID_ != OBJECTID_UNKNOWN) 259 247 { -
code/branches/particles2/src/orxonox/infos/PlayerInfo.h
r6087 r6101 92 92 private: 93 93 void networkcallback_changedcontrollableentityID(); 94 void networkcallback_changedtemporarycontrollableentityID();95 94 void networkcallback_changedgtinfoID(); 96 95 void updateGametypeInfo(); … … 99 98 Controller* controller_; 100 99 ControllableEntity* controllableEntity_; 101 ControllableEntity* temporaryControllableEntity_;100 ControllableEntity* oldControllableEntity_; 102 101 unsigned int controllableEntityID_; 103 unsigned int temporaryControllableEntityID_;104 102 105 103 const GametypeInfo* gtinfo_; -
code/branches/particles2/src/orxonox/worldentities/ControllableEntity.cc
r5929 r6101 36 36 #include "core/GameMode.h" 37 37 #include "core/XMLPort.h" 38 #include "network/NetworkFunction.h" 38 39 39 40 #include "Scene.h" … … 47 48 { 48 49 CreateFactory(ControllableEntity); 50 51 registerMemberNetworkFunction( ControllableEntity, fire ); 49 52 50 53 ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator) … … 217 220 this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 218 221 } 222 223 void ControllableEntity::fire(unsigned int firemode) 224 { 225 if(GameMode::isMaster()) 226 { 227 this->fired(firemode); 228 } 229 else 230 { 231 callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode); 232 } 233 } 219 234 220 235 void ControllableEntity::setPlayer(PlayerInfo* player) -
code/branches/particles2/src/orxonox/worldentities/ControllableEntity.h
r5929 r6101 84 84 { this->rotateRoll(Vector2(value, 0)); } 85 85 86 virtual void fire(unsigned int firemode) {} 86 void fire(unsigned int firemode); 87 virtual void fired(unsigned int firemode) {} 87 88 virtual void reload() {} 88 89 -
code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc
r6078 r6101 52 52 CreateFactory(Pawn); 53 53 54 registerMemberNetworkFunction( Pawn, doFire );55 56 54 Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator) 57 55 { … … 263 261 } 264 262 265 void Pawn::fire(unsigned int firemode) 266 { 267 this->doFire(firemode); 268 } 269 270 void Pawn::doFire(uint8_t firemode) 271 { 272 if(GameMode::isMaster()) 273 { 274 if (this->weaponSystem_) 275 this->weaponSystem_->fire(firemode); 276 } 277 else 278 { 279 callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode); 280 if (this->weaponSystem_) 281 this->weaponSystem_->fire(firemode); 282 } 263 void Pawn::fired(unsigned int firemode) 264 { 265 if (this->weaponSystem_) 266 this->weaponSystem_->fire(firemode); 283 267 } 284 268 -
code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h
r6078 r6101 79 79 virtual void kill(); 80 80 81 virtual void fire (unsigned int firemode);81 virtual void fired(unsigned int firemode); 82 82 virtual void reload(); 83 virtual void doFire(uint8_t firemode);84 83 virtual void postSpawn(); 85 84 -
code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.cc
r5929 r6101 189 189 } 190 190 191 void Spectator::fire (unsigned int firemode)191 void Spectator::fired(unsigned int firemode) 192 192 { 193 193 if (this->getPlayer()) -
code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.h
r5781 r6101 55 55 virtual void rotateRoll(const Vector2& value); 56 56 57 virtual void fire (unsigned int firemode);57 virtual void fired(unsigned int firemode); 58 58 virtual void greet(); 59 59
Note: See TracChangeset
for help on using the changeset viewer.