Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 24, 2005, 12:13:22 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the WorldEntities into the Trunk.
Merged with command:
svn merge branches/world_entities/ trunk/ -r5516:HEAD

conflics from world_entities changed in favor of branches/world_entity
all other conflict in favor of the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5671 r5750  
    2323#include "crosshair.h"
    2424
     25#include "class_list.h"
    2526#include "load_param.h"
    2627#include "factory.h"
    27 #include "vector.h"
    2828#include "list.h"
    2929#include "t_animation.h"
    3030#include "null_parent.h"
     31
    3132
    3233using namespace std;
     
    109110  this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR);
    110111  this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR);
     112
     113  this->targetIterator = NULL;
    111114}
    112115
     
    334337    }
    335338  }
     339}
     340
     341
     342/**
     343 * Selects an Entity from the NPC-list, and returns the Target
     344 */
     345PNode* 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 */
     372PNode* 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
    336392}
    337393
Note: See TracChangeset for help on using the changeset viewer.