Changeset 9663 for code/trunk/src/orxonox/worldentities
- Timestamp:
- Aug 25, 2013, 10:03:25 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r9625 r9663 324 324 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 325 325 { 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 326 // Start to control a new entity if you're the master of a formation 327 if(this->hasSlaves()) 328 { 329 Controller* slave = this->getSlave(); 330 ControllableEntity* entity = slave->getControllableEntity(); 331 332 333 if(!entity->hasHumanController()) 334 { 335 // delete the AIController 336 slave->setControllableEntity(0); 337 338 // set a new master within the formation 339 orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave)); 340 341 // start to control a slave 342 this->getPlayer()->startControl(entity); 343 } 344 else 345 { 346 this->getPlayer()->stopControl(); 347 } 348 349 } 350 else 351 { 352 this->getPlayer()->stopControl(); 353 } 354 354 } 355 355 if (GameMode::isMaster()) … … 503 503 bool Pawn::hasSlaves() 504 504 { 505 506 507 508 509 510 511 512 513 505 for (ObjectList<FormationController>::iterator it = 506 ObjectList<FormationController>::begin(); 507 it != ObjectList<FormationController>::end(); ++it ) 508 { 509 // checks if the pawn's controller has a slave 510 if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController()) 511 return true; 512 } 513 return false; 514 514 } 515 515 516 516 // A function that returns a slave of the pawn's controller 517 517 Controller* Pawn::getSlave(){ 518 519 520 521 522 523 524 525 518 for (ObjectList<FormationController>::iterator it = 519 ObjectList<FormationController>::begin(); 520 it != ObjectList<FormationController>::end(); ++it ) 521 { 522 if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController()) 523 return it->getController(); 524 } 525 return 0; 526 526 } 527 527
Note: See TracChangeset
for help on using the changeset viewer.