Changeset 2973
- Timestamp:
- May 12, 2009, 9:24:58 PM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/infos/HumanPlayer.cc
r2896 r2973 167 167 } 168 168 169 void HumanPlayer::changedControllableEntity()170 {171 PlayerInfo::changedControllableEntity();172 173 if (this->humanHud_)174 this->humanHud_->setOwner(this->getControllableEntity());175 }176 177 169 void HumanPlayer::updateHumanHUD() 178 170 { … … 187 179 this->humanHud_ = new OverlayGroup(this); 188 180 this->humanHud_->addTemplate(this->humanHudTemplate_); 189 this->humanHud_->setOwner(this ->getControllableEntity());181 this->humanHud_->setOwner(this); 190 182 } 191 183 } … … 203 195 this->gametypeHud_ = new OverlayGroup(this); 204 196 this->gametypeHud_->addTemplate(this->gametypeHudTemplate_); 205 this->gametypeHud_->setOwner(this ->getGametype());197 this->gametypeHud_->setOwner(this); 206 198 } 207 199 } -
code/trunk/src/orxonox/objects/infos/HumanPlayer.h
r2826 r2973 52 52 53 53 virtual void changedGametype(); 54 virtual void changedControllableEntity();55 54 56 55 inline void setHumanHUDTemplate(const std::string& name) -
code/trunk/src/orxonox/objects/infos/PlayerInfo.cc
r2839 r2973 51 51 this->controllableEntityID_ = CLIENTID_UNKNOWN; 52 52 53 this->gtinfo_ = 0; 54 this->gtinfoID_ = OBJECTID_UNKNOWN; 55 this->updateGametypeInfo(); 56 53 57 this->registerVariables(); 54 58 } … … 76 80 registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 77 81 registerVariable(this->bReadyToSpawn_, variableDirection::toserver); 82 registerVariable(this->gtinfoID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID)); 78 83 } 79 84 … … 88 93 void PlayerInfo::changedGametype() 89 94 { 95 this->updateGametypeInfo(); 96 90 97 if (this->isInitialized()) 91 98 { … … 108 115 } 109 116 117 void PlayerInfo::updateGametypeInfo() 118 { 119 this->gtinfo_ = 0; 120 this->gtinfoID_ = OBJECTID_UNKNOWN; 121 122 if (this->getGametype() && this->getGametype()->getGametypeInfo()) 123 { 124 this->gtinfo_ = this->getGametype()->getGametypeInfo(); 125 this->gtinfoID_ = this->gtinfo_->getObjectID(); 126 } 127 } 128 110 129 void PlayerInfo::createController() 111 130 { … … 181 200 } 182 201 } 202 203 void PlayerInfo::networkcallback_changedgtinfoID() 204 { 205 if (this->gtinfoID_ != OBJECTID_UNKNOWN) 206 { 207 this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_)); 208 209 if (!this->gtinfo_) 210 this->gtinfoID_ = OBJECTID_UNKNOWN; 211 } 212 } 183 213 } -
code/trunk/src/orxonox/objects/infos/PlayerInfo.h
r2826 r2973 77 77 { return this->controller_; } 78 78 79 inline const GametypeInfo* getGametypeInfo() const 80 { return this->gtinfo_; } 81 79 82 protected: 80 83 void createController(); … … 88 91 private: 89 92 void networkcallback_changedcontrollableentityID(); 93 void networkcallback_changedgtinfoID(); 94 void updateGametypeInfo(); 90 95 91 96 bool bReadyToSpawn_; … … 93 98 ControllableEntity* controllableEntity_; 94 99 unsigned int controllableEntityID_; 100 101 const GametypeInfo* gtinfo_; 102 unsigned int gtinfoID_; 95 103 }; 96 104 } -
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
r2896 r2973 42 42 #include "objects/worldentities/Camera.h" 43 43 #include "objects/worldentities/CameraPosition.h" 44 #include "objects/gametypes/Gametype.h"45 44 #include "overlays/OverlayGroup.h" 46 45 … … 67 66 this->mouseLookSpeed_ = 200; 68 67 69 this->gtinfo_ = 0;70 this->gtinfoID_ = OBJECTID_UNKNOWN;71 this->changedGametype();72 73 68 this->server_position_ = Vector3::ZERO; 74 69 this->client_position_ = Vector3::ZERO; … … 125 120 { 126 121 SetConfigValue(mouseLookSpeed_, 3.0f); 127 }128 129 void ControllableEntity::changedGametype()130 {131 //SUPER(ControllableEntity, changedGametype);132 WorldEntity::changedGametype();133 134 this->gtinfo_ = 0;135 this->gtinfoID_ = OBJECTID_UNKNOWN;136 137 if (this->getGametype() && this->getGametype()->getGametypeInfo())138 {139 this->gtinfo_ = this->getGametype()->getGametypeInfo();140 this->gtinfoID_ = this->gtinfo_->getObjectID();141 }142 122 } 143 123 … … 283 263 } 284 264 285 void ControllableEntity::networkcallback_changedgtinfoID()286 {287 if (this->gtinfoID_ != OBJECTID_UNKNOWN)288 {289 this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));290 291 if (!this->gtinfo_)292 this->gtinfoID_ = OBJECTID_UNKNOWN;293 }294 }295 296 265 void ControllableEntity::startLocalHumanControl() 297 266 { … … 394 363 395 364 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 396 registerVariable(this->gtinfoID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));397 365 } 398 366 -
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h
r2851 r2973 48 48 void setConfigValues(); 49 49 50 virtual void changedGametype();51 50 virtual void changedPlayer() {} 52 51 … … 126 125 { return this->bHasHumanController_; } 127 126 128 inline const GametypeInfo* getGametypeInfo() const129 { return this->gtinfo_; }130 131 127 inline bool isInMouseLook() const 132 128 { return this->bMouseLook_; } … … 157 153 158 154 void networkcallback_changedplayerID(); 159 void networkcallback_changedgtinfoID();160 155 161 156 // Bullet btMotionState related … … 190 185 std::list<CameraPosition*> cameraPositions_; 191 186 std::string cameraPositionTemplate_; 192 193 const GametypeInfo* gtinfo_;194 unsigned int gtinfoID_;195 187 }; 196 188 } -
code/trunk/src/orxonox/overlays/hud/GametypeStatus.cc
r2662 r2973 58 58 SUPER(GametypeStatus, tick, dt); 59 59 60 if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->get Player())60 if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity()) 61 61 { 62 62 const GametypeInfo* gtinfo = this->owner_->getGametypeInfo(); 63 PlayerInfo* pinfo = this->owner_->getPlayer();63 ControllableEntity* ce = this->owner_->getControllableEntity(); 64 64 65 65 if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning()) 66 66 { 67 if (! pinfo->isReadyToSpawn())67 if (!this->owner_->isReadyToSpawn()) 68 68 this->setCaption("Press [Fire] to start the match"); 69 69 else … … 74 74 if (gtinfo->isStartCountdownRunning()) 75 75 this->setCaption(convertToString((int)ceil(gtinfo->getStartCountdown()))); 76 else if ( this->owner_->isA(Class(Spectator)))76 else if (ce->isA(Class(Spectator))) 77 77 this->setCaption("Press [Fire] to respawn"); 78 78 else … … 89 89 SUPER(GametypeStatus, changedOwner); 90 90 91 this->owner_ = dynamic_cast< ControllableEntity*>(this->getOwner());91 this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner()); 92 92 } 93 93 } -
code/trunk/src/orxonox/overlays/hud/GametypeStatus.h
r2662 r2973 47 47 48 48 private: 49 ControllableEntity* owner_;49 PlayerInfo* owner_; 50 50 }; 51 51 } -
code/trunk/src/orxonox/overlays/hud/PongScore.cc
r2890 r2973 135 135 SUPER(PongScore, changedOwner); 136 136 137 this->owner_ = dynamic_cast<Pong*>(this->getOwner()); 137 if (this->getOwner() && this->getOwner()->getGametype()) 138 this->owner_ = dynamic_cast<Pong*>(this->getOwner()->getGametype()); 139 else 140 this->owner_ = 0; 138 141 } 139 142 }
Note: See TracChangeset
for help on using the changeset viewer.