- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/controllers/ActionpointController.cc
r11052 r11071 339 339 inLoop = this->bInLoop_; 340 340 341 Action ::Valuevalue;341 Action value; 342 342 343 343 if ( actionName == "FIGHT" ) … … 371 371 return this->actionpoints_[index]; 372 372 else 373 return 0;373 return nullptr; 374 374 } 375 375 //XML method 376 Action ::ValueActionpointController::getAction ()376 Action ActionpointController::getAction () 377 377 { 378 378 return this->action_; … … 401 401 } 402 402 //XML method 403 void ActionpointController::setAction (Action ::Valueaction)403 void ActionpointController::setAction (Action action) 404 404 { 405 405 this->action_ = action; 406 406 } 407 407 //set action and target/protect 408 void ActionpointController::setAction (Action ::Valueaction, ControllableEntity* target)408 void ActionpointController::setAction (Action action, ControllableEntity* target) 409 409 { 410 410 if (!this || !this->getControllableEntity()) … … 423 423 } 424 424 //set action and target position 425 void ActionpointController::setAction (Action ::Valueaction, const Vector3& target)425 void ActionpointController::setAction (Action action, const Vector3& target) 426 426 { 427 427 if (!this || !this->getControllableEntity()) … … 434 434 } 435 435 //set action and target position and orientation 436 void ActionpointController::setAction (Action ::Valueaction, const Vector3& target, const Quaternion& orient )436 void ActionpointController::setAction (Action action, const Vector3& target, const Quaternion& orient ) 437 437 { 438 438 if (!this || !this->getControllableEntity()) … … 476 476 return; 477 477 478 this->setTarget( 0);478 this->setTarget(nullptr); 479 479 this->setTargetPosition(this->getControllableEntity()->getWorldPosition()); 480 480 this->action_ = Action::NONE; … … 506 506 if (targetName == "") 507 507 break; 508 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)509 { 510 if (!this || !this->getControllableEntity()) 511 return; 512 if (CommonController::getName( *itP) == targetName)508 for (Pawn* pawn : ObjectList<Pawn>()) 509 { 510 if (!this || !this->getControllableEntity()) 511 return; 512 if (CommonController::getName(pawn) == targetName) 513 513 { 514 this->setTarget (static_cast<ControllableEntity*>( *itP));514 this->setTarget (static_cast<ControllableEntity*>(pawn)); 515 515 } 516 516 } … … 541 541 if (protectName == "reservedKeyword:human") 542 542 { 543 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)543 for (Pawn* pawn : ObjectList<Pawn>()) 544 544 { 545 if (orxonox_cast<ControllableEntity*>( *itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController"))545 if (orxonox_cast<ControllableEntity*>(pawn) && (pawn->getController()) && (pawn->getController()->getIdentifier()->getName() == "NewHumanController")) 546 546 { 547 this->setProtect (static_cast<ControllableEntity*>( *itP));547 this->setProtect (static_cast<ControllableEntity*>(pawn)); 548 548 } 549 549 } … … 551 551 else 552 552 { 553 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)553 for (Pawn* pawn : ObjectList<Pawn>()) 554 554 { 555 if (CommonController::getName( *itP) == protectName)555 if (CommonController::getName(pawn) == protectName) 556 556 { 557 this->setProtect (static_cast<ControllableEntity*>( *itP));557 this->setProtect (static_cast<ControllableEntity*>(pawn)); 558 558 } 559 559 } … … 578 578 std::string targetName = p.name; 579 579 580 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)581 { 582 if (CommonController::getName( *itP) == targetName)580 for (Pawn* pawn : ObjectList<Pawn>()) 581 { 582 if (CommonController::getName(pawn) == targetName) 583 583 { 584 584 if (!this || !this->getControllableEntity()) 585 585 return; 586 this->setTarget (static_cast<ControllableEntity*>( *itP));586 this->setTarget (static_cast<ControllableEntity*>(pawn)); 587 587 } 588 588 } … … 702 702 { 703 703 if (!this || !this->getControllableEntity()) 704 return 0;705 706 Pawn* closestTarget = 0;704 return nullptr; 705 706 Pawn* closestTarget = nullptr; 707 707 float minDistance = std::numeric_limits<float>::infinity(); 708 708 Gametype* gt = this->getGametype(); 709 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)709 for (Pawn* pawn : ObjectList<Pawn>()) 710 710 { 711 711 if (!this || !this->getControllableEntity()) 712 return 0;713 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )712 return nullptr; 713 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 714 714 continue; 715 715 716 float distance = CommonController::distance ( *itP, this->getControllableEntity());716 float distance = CommonController::distance (pawn, this->getControllableEntity()); 717 717 if (distance < minDistance) 718 718 { 719 closestTarget = *itP;719 closestTarget = pawn; 720 720 minDistance = distance; 721 721 } … … 725 725 return closestTarget; 726 726 } 727 return 0;727 return nullptr; 728 728 } 729 729 //push action FIGHT to the stack and set target to the closest enemy
Note: See TracChangeset
for help on using the changeset viewer.