Changeset 2019 for code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
- Timestamp:
- Oct 27, 2008, 4:08:51 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
r2006 r2019 43 43 CreateFactory(ControllableEntity); 44 44 45 ControllableEntity::ControllableEntity( )45 ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator) 46 46 { 47 47 RegisterObject(ControllableEntity); … … 71 71 ControllableEntity::~ControllableEntity() 72 72 { 73 if (this->isInitialized() && this->bControlled_) 74 this->stopLocalControl(); 73 if (this->isInitialized()) 74 { 75 if (this->bControlled_) 76 this->stopLocalControl(); 77 78 if (this->hud_) 79 delete this->hud_; 80 81 if (this->camera_) 82 delete this->camera_; 83 } 75 84 } 76 85 … … 92 101 this->player_ = player; 93 102 this->playerID_ = player->getObjectID(); 94 this->bControlled_ = player->isLocalPlayer();103 this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer()); 95 104 96 105 if (this->bControlled_) 97 106 { 98 107 this->startLocalControl(); 99 this->setObjectMode(network::direction::bidirectional); 108 109 if (!Core::isMaster()) 110 this->setObjectMode(network::direction::bidirectional); 100 111 } 101 112 } … … 115 126 } 116 127 117 void ControllableEntity::updatePlayer() 118 { 128 void ControllableEntity::networkcallback_changedplayerID() 129 { 130 // just do this in case the entity wasn't yet synchronized when the corresponding PlayerInfo got our objectID 119 131 if (this->playerID_ != network::OBJECTID_UNKNOWN) 120 132 { 121 133 this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_)); 122 if (this->player_ && (this->player_->get Pawn() != this))134 if (this->player_ && (this->player_->getControllableEntity() != this)) 123 135 this->player_->startControl(this); 124 136 } … … 128 140 { 129 141 std::cout << this->getObjectID() << " ###### start local control" << std::endl; 130 this->camera_ = new Camera( );142 this->camera_ = new Camera(this); 131 143 this->camera_->requestFocus(); 132 144 this->attach(this->camera_); … … 134 146 if (this->hudtemplate_ != "") 135 147 { 136 this->hud_ = new OverlayGroup( );148 this->hud_ = new OverlayGroup(this); 137 149 this->hud_->addTemplate(this->hudtemplate_); 138 150 } … … 184 196 REGISTERDATA(this->client_overwrite_, network::direction::toserver); 185 197 186 REGISTERDATA(this->playerID_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity:: updatePlayer));198 REGISTERDATA(this->playerID_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 187 199 } 188 200
Note: See TracChangeset
for help on using the changeset viewer.