Changeset 5750 in orxonox.OLD for trunk/src/world_entities/weapons/weapon_manager.cc
- Timestamp:
- Nov 24, 2005, 12:13:22 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/weapon_manager.cc
r5671 r5750 23 23 #include "crosshair.h" 24 24 25 #include "class_list.h" 25 26 #include "load_param.h" 26 27 #include "factory.h" 27 #include "vector.h"28 28 #include "list.h" 29 29 #include "t_animation.h" 30 30 #include "null_parent.h" 31 31 32 32 33 using namespace std; … … 109 110 this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR); 110 111 this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR); 112 113 this->targetIterator = NULL; 111 114 } 112 115 … … 334 337 } 335 338 } 339 } 340 341 342 /** 343 * Selects an Entity from the NPC-list, and returns the Target 344 */ 345 PNode* WeaponManager::getSomeTarget() 346 { 347 if (this->targetIterator == NULL) 348 { 349 tList<BaseObject>* npcList = ClassList::getList(CL_NPC); 350 if (npcList != NULL) 351 { 352 this->targetIterator = npcList->getIterator(); 353 this->targetIterator->firstElement(); 354 } 355 else 356 return NULL; 357 } 358 359 PNode* retNode = dynamic_cast<PNode*>(targetIterator->nextElement()); 360 if (retNode == NULL && this->targetIterator->getList()->getSize() > 0) 361 retNode = dynamic_cast<PNode*>(targetIterator->firstElement()); 362 363 return retNode; 364 } 365 366 367 /** 368 * Selects an Entity from the Entity-List, that is near of the carrier PNode. 369 * @param carrier: The PNode from which the distance should be measured 370 * @param distance: The Maximum Distance to Return. 371 */ 372 PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance) 373 { 374 tList<BaseObject>* npcList = ClassList::getList(CL_NPC); 375 if (npcList != NULL) 376 { 377 tIterator<BaseObject>* npcIT = npcList->getIterator(); 378 PNode* tmpNPC = dynamic_cast<PNode*>(npcIT->firstElement()); 379 while (tmpNPC != NULL) 380 { 381 if ((carrier->getAbsCoor() - tmpNPC->getAbsCoor()).len() < distance) 382 { 383 delete npcIT; 384 return tmpNPC; 385 } 386 tmpNPC = dynamic_cast<PNode*>(npcIT->nextElement()); 387 } 388 delete npcIT; 389 } 390 return this->getFixedTarget(); 391 336 392 } 337 393
Note: See TracChangeset
for help on using the changeset viewer.