Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10546 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jan 31, 2007, 5:44:06 AM (18 years ago)
Author:
patrick
Message:

debug, and better slot pos

Location:
trunk/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/mount_point.cc

    r10542 r10546  
    190190    else if( obj->isA( WeaponSlot::staticClassID()))
    191191    {
    192 //       PRINTF(0)("=========+>we got a weapon slot\n");
     192      PRINTF(0)("=========+>we got a weapon slot at\n");
     193      this->getRelCoor().debug();
     194
    193195
    194196      // cast down the object to WE
     
    196198
    197199      // now set the position, direction and reparent it to this node
    198       this->_mount->setAbsCoor( this->getAbsCoor());
    199       this->_mount->setAbsDir( this->getAbsDir());
     200      this->_mount->setRelCoor( this->getRelCoor());
     201      this->_mount->setRelDir( this->getRelDir());
    200202      this->_mount->setParent( this);
    201203    }
  • trunk/src/world_entities/npcs/npc.cc

    r10545 r10546  
    195195
    196196
    197   // now get slots from the mount points
    198   std::map<int, MountPoint*>::iterator it = this->mountPointMap.begin();
    199   for( ;it != this->mountPointMap.end(); it++)
    200   {
    201     WeaponSlot* ws = dynamic_cast<WeaponSlot*>((*it).second->getMount());
    202     if( ws != NULL && ws->isA(WeaponSlot::staticClassID()))
    203     {
    204       int slot = ws->getWeaponSlot();
    205       int side = ws->getWeaponSide();
    206       this->getWeaponManager().setSlotPosition(slot, ws->getRelCoor());
    207       this->getWeaponManager().setSlotDirection(slot, ws->getRelDir());
    208       PRINTF(0)("setting slot %i\n", slot);
    209     }
    210   }
    211197
    212198  this->getWeaponManager().getFixedTarget()->setParent(this);
    213199  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
     200  this->bInit = false;
    214201}
    215202
     
    411398void NPC::tick(float dt)
    412399{
     400  if( !this->bInit)
     401  {
     402    // now get slots from the mount points
     403    std::map<int, MountPoint*>::iterator it = this->mountPointMap.begin();
     404    for( ;it != this->mountPointMap.end(); it++)
     405    {
     406      WeaponSlot* ws = dynamic_cast<WeaponSlot*>((*it).second->getMount());
     407      if( ws != NULL && ws->isA(WeaponSlot::staticClassID()))
     408      {
     409        int slot = ws->getWeaponSlot();
     410        int side = ws->getWeaponSide();
     411        this->getWeaponManager().setSlotPosition(slot, ws->getRelCoor());
     412        this->getWeaponManager().setSlotDirection(slot, ws->getRelDir());
     413        PRINTF(0)("setting slot %i\n", slot);
     414        ws->getRelCoor().debug();
     415      }
     416    }
     417  this->bInit = true;
     418  }
     419
     420
     421
    413422  this->weaponMan.tick(dt);
    414423  if (this->bFire)
  • trunk/src/world_entities/npcs/npc.h

    r10545 r10546  
    5757  WeaponManager         weaponMan;    //!< weapon manager
    5858  bool                  bFire;        //!< fire
     59  bool                  bInit;
    5960
    6061  AIModule*             aiModule;
  • trunk/src/world_entities/world_entity.cc

    r10540 r10546  
    426426void WorldEntity::addMountPoint(int slot, MountPoint* mountPoint)
    427427{
    428   if( this->mountPointMap.find(slot) == this->mountPointMap.end())
     428  if( this->mountPointMap.find(slot) != this->mountPointMap.end())
    429429  {
    430430    PRINTF(2)("adding a mount point to a slot, that already is occupied! ignoring - maybe some object did not get connected well (object: %s)\n", this->getClassCName());
     
    442442void WorldEntity::mount(int slot, WorldEntity* entity)
    443443{
    444   if( this->mountPointMap.find(slot) == this->mountPointMap.end())
     444  if( this->mountPointMap.find(slot) != this->mountPointMap.end())
    445445  {
    446446    PRINTF(0)("you tried to add an entity to a mount point that doesn't exist (slot %i)\n", slot);
Note: See TracChangeset for help on using the changeset viewer.