Changeset 6107 for code/branches/presentation2/src/orxonox/infos
- Timestamp:
- Nov 20, 2009, 5:20:11 PM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2
- Property svn:mergeinfo changed
/code/branches/particles2 (added) merged: 6050,6059,6065-6068,6076,6078-6082,6086-6087,6098-6099,6101
- Property svn:mergeinfo changed
-
code/branches/presentation2/src/orxonox/infos/PlayerInfo.cc
r5929 r6107 50 50 this->controller_ = 0; 51 51 this->controllableEntity_ = 0; 52 this->controllableEntityID_ = CLIENTID_UNKNOWN; 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0; 53 54 54 55 this->gtinfo_ = 0; … … 80 81 registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 81 82 registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 82 registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);83 83 registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID)); 84 84 } … … 148 148 return; 149 149 150 if (this->oldControllableEntity_) 151 this->stopTemporaryControl(); 150 152 if (this->controllableEntity_) 151 153 this->stopControl(); … … 163 165 this->changedControllableEntity(); 164 166 } 167 168 void PlayerInfo::startTemporaryControl(ControllableEntity* entity) 169 { 170 if (!entity) 171 return; 172 173 // assert( this->temporaryControllableEntity_==0 ); 174 175 this->oldControllableEntity_ = this->controllableEntity_; 176 this->controllableEntity_ = entity; 177 this->controllableEntityID_ = entity->getObjectID(); 178 179 entity->setPlayer(this); 180 181 if (this->controller_) 182 this->controller_->setControllableEntity(entity); 183 184 this->changedControllableEntity(); 185 } 165 186 166 187 void PlayerInfo::stopControl() 167 188 { 189 if ( this->oldControllableEntity_ ) 190 this->stopTemporaryControl(); 191 168 192 ControllableEntity* entity = this->controllableEntity_; 169 193 … … 177 201 this->controller_->setControllableEntity(0); 178 202 179 entity->removePlayer(); 180 181 this->changedControllableEntity(); 182 } 183 203 if ( GameMode::isMaster() ) 204 entity->removePlayer(); 205 206 this->changedControllableEntity(); 207 } 208 209 void PlayerInfo::stopTemporaryControl() 210 { 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; 219 220 if ( this->controllableEntity_ && this->controller_) 221 this->controller_->setControllableEntity(this->controllableEntity_); 222 223 if ( GameMode::isMaster() ) 224 entity->removePlayer(); 225 226 this->changedControllableEntity(); 227 } 228 184 229 void PlayerInfo::networkcallback_changedcontrollableentityID() 185 230 { … … 196 241 } 197 242 243 198 244 void PlayerInfo::networkcallback_changedgtinfoID() 199 245 { -
code/branches/presentation2/src/orxonox/infos/PlayerInfo.h
r5929 r6107 69 69 void startControl(ControllableEntity* entity); 70 70 void stopControl(); 71 void startTemporaryControl(ControllableEntity* entity); 72 void stopTemporaryControl(); 71 73 72 74 inline ControllableEntity* getControllableEntity() const … … 96 98 Controller* controller_; 97 99 ControllableEntity* controllableEntity_; 100 ControllableEntity* oldControllableEntity_; 98 101 unsigned int controllableEntityID_; 99 102
Note: See TracChangeset
for help on using the changeset viewer.