- Timestamp:
- Dec 25, 2009, 10:23:58 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r5929 r6417 36 36 #include "core/GameMode.h" 37 37 #include "core/XMLPort.h" 38 #include "network/NetworkFunction.h" 38 39 39 40 #include "Scene.h" … … 47 48 { 48 49 CreateFactory(ControllableEntity); 50 51 registerMemberNetworkFunction( ControllableEntity, fire ); 52 registerMemberNetworkFunction( ControllableEntity, setTargetInternal ); 49 53 50 54 ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator) … … 62 66 this->camera_ = 0; 63 67 this->xmlcontroller_ = 0; 68 this->controller_ = 0; 64 69 this->reverseCamera_ = 0; 65 70 this->bDestroyWhenPlayerLeft_ = false; 66 71 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); 72 this->currentCameraPosition_ = 0; 67 73 this->bMouseLook_ = false; 68 74 this->mouseLookSpeed_ = 200; … … 169 175 { 170 176 this->cameraPositions_.front()->attachCamera(this->camera_); 177 this->currentCameraPosition_ = this->cameraPositions_.front().get(); 171 178 } 172 179 else if (this->cameraPositions_.size() > 0) … … 178 185 ++it; 179 186 if (it != this->cameraPositions_.end()) 187 { 180 188 (*it)->attachCamera(this->camera_); 189 this->currentCameraPosition_ = *it; 190 } 181 191 else 192 { 182 193 (*this->cameraPositions_.begin())->attachCamera(this->camera_); 194 this->currentCameraPosition_ = *this->cameraPositions_.begin(); 195 } 183 196 break; 184 197 } … … 188 201 { 189 202 this->camera_->attachToNode(this->cameraPositionRootNode_); 203 this->currentCameraPosition_ = 0; 190 204 } 191 205 } … … 198 212 if (!this->bMouseLook_) 199 213 this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY); 214 if (this->getCamera()) 215 { 216 if (!this->bMouseLook_&& this->currentCameraPosition_->getDrag()) 217 this->getCamera()->setDrag(true); 218 else 219 this->getCamera()->setDrag(false); 220 } 200 221 } 201 222 … … 216 237 if (this->bMouseLook_) 217 238 this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 239 } 240 241 void ControllableEntity::fire(unsigned int firemode) 242 { 243 if(GameMode::isMaster()) 244 { 245 this->fired(firemode); 246 } 247 else 248 { 249 callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode); 250 } 251 } 252 253 void ControllableEntity::setTarget( WorldEntity* target ) 254 { 255 this->target_ = target; 256 if ( !GameMode::isMaster() ) 257 { 258 if ( target != 0 ) 259 { 260 callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() ); 261 } 262 else 263 { 264 callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN ); 265 } 266 } 267 } 268 269 void ControllableEntity::setTargetInternal( uint32_t targetID ) 270 { 271 this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) ); 218 272 } 219 273 … … 279 333 this->camera_ = new Camera(this); 280 334 this->camera_->requestFocus(); 281 if ( this->cameraPositionTemplate_ != "")335 if (!this->cameraPositionTemplate_.empty()) 282 336 this->addTemplate(this->cameraPositionTemplate_); 283 337 if (this->cameraPositions_.size() > 0) 338 { 284 339 this->cameraPositions_.front()->attachCamera(this->camera_); 340 this->currentCameraPosition_ = this->cameraPositions_.front(); 341 } 285 342 else 343 { 286 344 this->camera_->attachToNode(this->cameraPositionRootNode_); 345 this->currentCameraPosition_ = 0; 346 } 287 347 } 288 348 289 349 if (!this->hud_ && GameMode::showsGraphics()) 290 350 { 291 if ( this->hudtemplate_ != "")351 if (!this->hudtemplate_.empty()) 292 352 { 293 353 this->hud_ = new OverlayGroup(this);
Note: See TracChangeset
for help on using the changeset viewer.