Changeset 8561 for code/branches/presentation/src/orxonox/infos
- Timestamp:
- May 24, 2011, 4:44:39 PM (14 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/infos/PlayerInfo.cc
r8327 r8561 51 51 this->controllableEntity_ = 0; 52 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0;54 53 55 54 this->gtinfo_ = 0; … … 151 150 return; 152 151 153 if (this->oldControllableEntity_)152 while (this->previousControllableEntity_.size() > 0) 154 153 this->stopTemporaryControl(); 154 155 155 if (this->controllableEntity_) 156 156 this->stopControl(); … … 176 176 if (!entity) 177 177 return; 178 179 assert( this->oldControllableEntity_==0 ); 180 181 this->oldControllableEntity_ = this->controllableEntity_; 178 179 this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_)); 182 180 this->controllableEntity_ = entity; 183 181 this->controllableEntityID_ = entity->getObjectID(); … … 194 192 void PlayerInfo::stopControl() 195 193 { 196 if ( this->oldControllableEntity_)194 while ( this->previousControllableEntity_.size() > 0) 197 195 this->stopTemporaryControl(); 198 196 … … 215 213 } 216 214 215 void PlayerInfo::pauseControl() 216 { 217 ControllableEntity* entity = this->controllableEntity_; 218 219 if (!entity) 220 return; 221 222 this->controllableEntity_->getController()->setActive(false); 223 //this->controllableEntity_->getController()->setControllableEntity(NULL); 224 this->controllableEntity_->setController(0); 225 } 226 217 227 void PlayerInfo::stopTemporaryControl() 218 228 { 219 229 ControllableEntity* entity = this->controllableEntity_; 220 230 221 assert( this->controllableEntity_ && this->oldControllableEntity_);222 if( !entity || !this->oldControllableEntity_)231 assert(this->controllableEntity_ != NULL); 232 if( !entity || this->previousControllableEntity_.size() == 0 ) 223 233 return; 224 234 225 235 this->controllableEntity_->setController(0); 226 236 227 this->controllableEntity_ = this->oldControllableEntity_; 237 // this->controllableEntity_ = this->previousControllableEntity_.back(); 238 do { 239 this->controllableEntity_ = this->previousControllableEntity_.back(); 240 } while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0); 228 241 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 229 this-> oldControllableEntity_ = 0;230 231 if ( this->controllableEntity_ && this->controller_)242 this->previousControllableEntity_.pop_back(); 243 244 if ( this->controllableEntity_ != NULL && this->controller_ != NULL) 232 245 this->controller_->setControllableEntity(this->controllableEntity_); 233 246 -
code/branches/presentation/src/orxonox/infos/PlayerInfo.h
r7163 r8561 68 68 void startControl(ControllableEntity* entity); 69 69 void stopControl(); 70 void pauseControl(); 70 71 void startTemporaryControl(ControllableEntity* entity); 71 72 void stopTemporaryControl(); … … 98 99 Controller* controller_; 99 100 ControllableEntity* controllableEntity_; 100 ControllableEntity* oldControllableEntity_;101 std::vector< WeakPtr<ControllableEntity> > previousControllableEntity_; //!< List of the previous ControllableEntities if repeatedly startTemporary control was called. The ControllableEntity at the back is the most recent. 101 102 unsigned int controllableEntityID_; 102 103
Note: See TracChangeset
for help on using the changeset viewer.