Changeset 2662 for code/trunk/src/orxonox/objects/infos
- Timestamp:
- Feb 14, 2009, 10:17:35 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 7 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/infos/CMakeLists.txt
r2171 r2662 1 1 SET( SRC_FILES 2 Bot.cc 2 3 Info.cc 3 4 PlayerInfo.cc 4 5 HumanPlayer.cc 6 GametypeInfo.cc 5 7 ) 6 8 -
code/trunk/src/orxonox/objects/infos/HumanPlayer.cc
r2171 r2662 37 37 #include "objects/controllers/HumanController.h" 38 38 #include "objects/gametypes/Gametype.h" 39 #include "overlays/OverlayGroup.h" 39 40 40 41 namespace orxonox … … 63 64 { 64 65 SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick); 66 SetConfigValue(hudtemplate_, "defaultHUD").callback(this, &HumanPlayer::configvaluecallback_changedHUDTemplate); 65 67 } 66 68 67 69 void HumanPlayer::registerVariables() 68 70 { 69 REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));71 registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick)); 70 72 71 REGISTERDATA(this->clientID_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));72 REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));73 REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));73 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged)); 74 registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized)); 75 registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized)); 74 76 } 75 77 … … 83 85 this->setName(this->nick_); 84 86 } 87 } 88 89 void HumanPlayer::configvaluecallback_changedHUDTemplate() 90 { 91 this->changedController(); 85 92 } 86 93 … … 99 106 100 107 if (!Core::isMaster()) 101 this->setObjectMode( direction::bidirectional);108 this->setObjectMode(objectDirection::bidirectional); 102 109 else 103 110 this->setName(this->nick_); … … 138 145 this->networkcallback_clientIDchanged(); 139 146 } 147 148 void HumanPlayer::changedController() 149 { 150 if (this->getController()) 151 { 152 this->getController()->setHUDTemplate(this->hudtemplate_); 153 154 if (this->getController() && this->getController()->getHUD()) 155 this->getController()->getHUD()->setOwner(this->getControllableEntity()); 156 } 157 } 140 158 } -
code/trunk/src/orxonox/objects/infos/HumanPlayer.h
r2171 r2662 33 33 34 34 #include "PlayerInfo.h" 35 #include "core/Identifier.h"36 #include "objects/controllers/Controller.h"37 35 38 36 namespace orxonox … … 53 51 void setClientID(unsigned int clientID); 54 52 53 virtual void changedController(); 54 55 55 protected: 56 56 void configvaluecallback_changednick(); 57 void configvaluecallback_changedHUDTemplate(); 57 58 void networkcallback_changednick(); 58 59 void networkcallback_clientIDchanged(); … … 62 63 std::string nick_; 63 64 std::string synchronize_nick_; 65 std::string hudtemplate_; 64 66 bool server_initialized_; 65 67 bool client_initialized_; -
code/trunk/src/orxonox/objects/infos/Info.h
r2171 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "network/ Synchronisable.h"34 #include "network/synchronisable/Synchronisable.h" 35 35 #include "core/BaseObject.h" 36 36 -
code/trunk/src/orxonox/objects/infos/PlayerInfo.cc
r2171 r2662 46 46 this->bLocalPlayer_ = false; 47 47 this->bReadyToSpawn_ = false; 48 this->bSetUnreadyAfterSpawn_ = true; 48 49 this->controller_ = 0; 49 50 this->controllableEntity_ = 0; … … 64 65 this->controller_ = 0; 65 66 } 67 68 if (this->getGametype()) 69 this->getGametype()->playerLeft(this); 66 70 } 67 71 } … … 69 73 void PlayerInfo::registerVariables() 70 74 { 71 REGISTERSTRING(this->name_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));72 REGISTERDATA (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));73 REGISTERDATA (this->bReadyToSpawn_, direction::toserver);75 registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 76 registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 77 registerVariable(this->bReadyToSpawn_, variableDirection::toserver); 74 78 } 75 79 76 80 void PlayerInfo::changedName() 77 81 { 82 SUPER(PlayerInfo, changedName); 83 78 84 if (this->isInitialized() && this->getGametype()) 79 85 this->getGametype()->playerChangedName(this); … … 109 115 if (this->controllableEntity_) 110 116 this->controller_->setControllableEntity(this->controllableEntity_); 117 this->changedController(); 111 118 } 112 119 113 void PlayerInfo::startControl(ControllableEntity* entity )120 void PlayerInfo::startControl(ControllableEntity* entity, bool callback) 114 121 { 122 if (entity == this->controllableEntity_) 123 return; 124 115 125 if (this->controllableEntity_) 116 this->stopControl(this->controllableEntity_ );126 this->stopControl(this->controllableEntity_, callback); 117 127 118 128 this->controllableEntity_ = entity; … … 122 132 this->controllableEntityID_ = entity->getObjectID(); 123 133 entity->setPlayer(this); 124 this->bReadyToSpawn_ = false;134 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_); 125 135 } 126 136 else -
code/trunk/src/orxonox/objects/infos/PlayerInfo.h
r2171 r2662 65 65 { return this->bReadyToSpawn_; } 66 66 67 void startControl(ControllableEntity* entity );67 void startControl(ControllableEntity* entity, bool callback = true); 68 68 void stopControl(ControllableEntity* entity, bool callback = true); 69 69 … … 71 71 { return this->controllableEntity_; } 72 72 73 inline Controller* getController() const 74 { return this->controller_; } 75 virtual void changedController() {} 76 73 77 protected: 74 78 void createController(); 75 void networkcallback_changedcontrollableentityID();76 79 77 80 bool bHumanPlayer_; 78 81 bool bLocalPlayer_; 82 bool bSetUnreadyAfterSpawn_; 83 SubclassIdentifier<Controller> defaultController_; 84 unsigned int clientID_; 85 86 private: 87 void networkcallback_changedcontrollableentityID(); 88 79 89 bool bReadyToSpawn_; 80 SubclassIdentifier<Controller> defaultController_;81 90 Controller* controller_; 82 91 ControllableEntity* controllableEntity_; 83 92 unsigned int controllableEntityID_; 84 unsigned int clientID_;85 93 }; 86 94 }
Note: See TracChangeset
for help on using the changeset viewer.