Changeset 3038
- Timestamp:
- May 24, 2009, 5:42:50 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/controllers/HumanController.cc
r2872 r3038 159 159 pawn->kill(); 160 160 else if (HumanController::localController_s->player_) 161 HumanController::localController_s->player_->stopControl( HumanController::localController_s->controllableEntity_);161 HumanController::localController_s->player_->stopControl(); 162 162 } 163 163 } -
code/trunk/src/orxonox/objects/gametypes/Gametype.cc
r3033 r3038 130 130 { 131 131 ControllableEntity* oldentity = it->first->getControllableEntity(); 132 132 133 133 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator()); 134 134 if (oldentity->getCamera()) … … 143 143 } 144 144 145 it->first->stopControl(oldentity, true);146 145 it->first->startControl(entity); 147 146 } … … 421 420 422 421 void Gametype::addTime(float t) 423 { 422 { 424 423 if (this->timeLimit_ == 0) 425 424 this->time_ -= t; … … 429 428 430 429 void Gametype::removeTime(float t) 431 { 430 { 432 431 if (this->timeLimit_ == 0) 433 432 this->time_ += t; … … 437 436 438 437 void Gametype::resetTimer() 439 { 438 { 440 439 this->resetTimer(timeLimit_); 441 440 } 442 441 443 442 void Gametype::resetTimer(float t) 444 { 443 { 445 444 this->timeLimit_ = t; 446 445 this->time_ = t; -
code/trunk/src/orxonox/objects/infos/PlayerInfo.cc
r2973 r3038 62 62 if (this->BaseObject::isInitialized()) 63 63 { 64 this->stopControl( this->controllableEntity_);64 this->stopControl(); 65 65 66 66 if (this->controller_) … … 142 142 } 143 143 144 void PlayerInfo::startControl(ControllableEntity* entity , bool callback)145 { 146 if ( entity == this->controllableEntity_)144 void PlayerInfo::startControl(ControllableEntity* entity) 145 { 146 if (!entity || entity == this->controllableEntity_) 147 147 return; 148 148 149 149 if (this->controllableEntity_) 150 this->stopControl( this->controllableEntity_, callback);150 this->stopControl(); 151 151 152 152 this->controllableEntity_ = entity; 153 154 if (entity) 155 { 156 this->controllableEntityID_ = entity->getObjectID(); 157 entity->setPlayer(this); 158 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_); 159 } 160 else 161 { 162 this->controllableEntityID_ = OBJECTID_UNKNOWN; 163 } 153 this->controllableEntityID_ = entity->getObjectID(); 154 155 entity->setPlayer(this); 156 157 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_); 164 158 165 159 if (this->controller_) … … 169 163 } 170 164 171 void PlayerInfo::stopControl(ControllableEntity* entity, bool callback) 172 { 173 if (entity && this->controllableEntity_ == entity) 174 { 175 this->controllableEntity_ = 0; 176 this->controllableEntityID_ = OBJECTID_UNKNOWN; 177 178 if (this->controller_) 179 this->controller_->setControllableEntity(0); 180 181 if (callback) 182 entity->removePlayer(); 183 184 this->changedControllableEntity(); 185 } 165 void PlayerInfo::stopControl() 166 { 167 ControllableEntity* entity = this->controllableEntity_; 168 169 if (!entity) 170 return; 171 172 this->controllableEntity_ = 0; 173 this->controllableEntityID_ = OBJECTID_UNKNOWN; 174 175 if (this->controller_) 176 this->controller_->setControllableEntity(0); 177 178 entity->removePlayer(); 179 180 this->changedControllableEntity(); 186 181 } 187 182 … … 192 187 Synchronisable* temp = Synchronisable::getSynchronisable(this->controllableEntityID_); 193 188 ControllableEntity* entity = dynamic_cast<ControllableEntity*>(temp); 194 195 189 this->startControl(entity); 196 190 } 197 191 else 198 192 { 199 this->stopControl( this->controllableEntity_);193 this->stopControl(); 200 194 } 201 195 } -
code/trunk/src/orxonox/objects/infos/PlayerInfo.h
r2973 r3038 68 68 { return this->bReadyToSpawn_; } 69 69 70 void startControl(ControllableEntity* entity , bool callback = true);71 void stopControl( ControllableEntity* entity, bool callback = true);70 void startControl(ControllableEntity* entity); 71 void stopControl(); 72 72 73 73 inline ControllableEntity* getControllableEntity() const -
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
r2973 r3038 91 91 92 92 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 93 this->getPlayer()->stopControl( this, false);93 this->getPlayer()->stopControl(); 94 94 95 95 if (this->hud_) -
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h
r2973 r3038 39 39 class _OrxonoxExport ControllableEntity : public MobileEntity 40 40 { 41 friend class PlayerInfo; // PlayerInfo uses setPlayer and removePlayer 42 41 43 public: 42 44 ControllableEntity(BaseObject* creator); … … 50 52 virtual void changedPlayer() {} 51 53 52 virtual void setPlayer(PlayerInfo* player);53 virtual void removePlayer();54 54 inline PlayerInfo* getPlayer() const 55 55 { return this->player_; } … … 131 131 132 132 protected: 133 virtual void setPlayer(PlayerInfo* player); // don't call this directly, use friend class PlayerInfo instead 134 virtual void removePlayer(); // don't call this directly, use friend class PlayerInfo instead 135 133 136 virtual void startLocalHumanControl(); 134 137 virtual void stopLocalHumanControl(); -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
r3033 r3038 209 209 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 210 210 211 if (this->getPlayer() )212 this->getPlayer()->stopControl( this);211 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 212 this->getPlayer()->stopControl(); 213 213 214 214 if (GameMode::isMaster()) -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
r2826 r3038 47 47 virtual void tick(float dt); 48 48 void registerVariables(); 49 50 virtual void setPlayer(PlayerInfo* player);51 virtual void removePlayer();52 49 53 50 inline bool isAlive() const … … 113 110 114 111 protected: 112 virtual void setPlayer(PlayerInfo* player); 113 virtual void removePlayer(); 114 115 115 virtual void death(); 116 116 virtual void deatheffect(); -
code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.h
r2662 r3038 46 46 virtual void tick(float dt); 47 47 48 virtual void setPlayer(PlayerInfo* player);49 virtual void startLocalHumanControl();50 51 48 virtual void moveFrontBack(const Vector2& value); 52 49 virtual void moveRightLeft(const Vector2& value); … … 59 56 virtual void fire(WeaponMode::Enum fireMode); 60 57 virtual void greet(); 58 59 protected: 60 virtual void setPlayer(PlayerInfo* player); 61 virtual void startLocalHumanControl(); 61 62 62 63 private:
Note: See TracChangeset
for help on using the changeset viewer.