Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6736 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 25, 2006, 9:28:18 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Weapons are ticked only if they are inside of a ticked OM_LIST (not by the WeaponManager anymore)

Location:
trunk/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/ground_turret.cc

    r6512 r6736  
    115115  if (likely(this->left != NULL))
    116116  {
    117     this->left->tickW(dt);
     117//    this->left->tickW(dt);
    118118    this->left->requestAction(WA_SHOOT);
    119119  }
    120120  if (likely(this->right != NULL))
    121121  {
    122     this->right->tickW(dt);
     122//    this->right->tickW(dt);
    123123    this->right->requestAction(WA_SHOOT);
    124124  }
  • trunk/src/world_entities/weapons/weapon.cc

    r6728 r6736  
    538538 * tick signal for time dependent/driven stuff
    539539*/
    540 void Weapon::tickW(float dt)
     540bool Weapon::tickW(float dt)
    541541{
    542542  //printf("%s ", stateToChar(this->currentState));
     
    550550    {
    551551      this->currentState = WS_INACTIVE;
    552       return;
     552      return false;
    553553    }
    554554    else
     
    561561    }
    562562  }
    563   tick(dt);
     563  return true;
    564564}
    565565
  • trunk/src/world_entities/weapons/weapon.h

    r6671 r6736  
    153153
    154154    // FLOW
    155     void tickW(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within
    156 
    157     virtual void tick(float dt) {};
     155    bool tickW(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within
     156
     157    virtual void tick(float dt) { tickW(dt); };
    158158
    159159    bool check() const;
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6728 r6736  
    121121
    122122  LoadParam(root, "slot-count", this, WeaponManager, setSlotCount)
    123       .describe("how many slots(cannons) the WeaponManager can handle");
     123  .describe("how many slots(cannons) the WeaponManager can handle");
    124124
    125125  LOAD_PARAM_START_CYCLE(root, element);
     
    127127    // CHECK IF THIS WORKS....
    128128    LoadParamXML_CYCLE(element, "weapons", this, WeaponManager, loadWeapons)
    129         .describe("loads Weapons");
     129    .describe("loads Weapons");
    130130  }
    131131  LOAD_PARAM_END_CYCLE(element);
     
    255255
    256256  if (!(this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLKINDS) &&
    257         this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLDIRS)
     257      this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLDIRS)
    258258  {
    259259    PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n",
     
    268268  this->configs[configID][slotID] = weapon;
    269269  weapon->setAmmoContainer(this->getAmmoContainer(weapon->getProjectileType()));
    270   if (this->parent != NULL)
    271   {
    272     this->parent->addChild(weapon);
    273   }
    274270  if(configID == this->currentConfigID)
    275271    this->currentSlotConfig[slotID].nextWeapon = weapon;
     272  if (this->parent != NULL)
     273  {
     274    this->parent->addChild(weapon);
     275    if (this->parent->isA(CL_PLAYABLE))
     276      dynamic_cast<Playable*>(this->parent)->weaponConfigChanged();
     277  }
    276278  PRINTF(3)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassName(), weapon->getName(), configID, slotID);
    277279  return true;
     
    350352  PRINTF(4)("Changing weapon configuration: to %i\n", this->currentConfigID);
    351353  for (int i = 0; i < WM_MAX_SLOTS; i++)
    352   {
    353354    this->currentSlotConfig[i].nextWeapon = this->configs[currentConfigID][i];
    354     if (this->currentSlotConfig[i].currentWeapon != this->currentSlotConfig[i].nextWeapon)
    355     {
    356       if (this->currentSlotConfig[i].currentWeapon != NULL)
    357         (this->currentSlotConfig[i].currentWeapon->requestAction(WA_DEACTIVATE));
    358       if (this->currentSlotConfig[i].nextWeapon != NULL && this->currentSlotConfig[i].nextWeapon->isActive())
    359         this->currentSlotConfig[i].nextWeapon = NULL;
    360     }
    361   }
    362355}
    363356
     
    387380  Weapon* tickWeapon;
    388381
    389   // all weapons
    390382  for(int i = 0; i < this->slotCount; i++)
    391383  {
    392 
     384/*
     385    NICE LITTLE DEBUG FUNCTION
     386       if (this->currentSlotConfig[i].currentWeapon != NULL || this->currentSlotConfig[i].nextWeapon != NULL)
     387      printf("%p %p\n", this->currentSlotConfig[i].currentWeapon, this->currentSlotConfig[i].nextWeapon);*/
     388
     389    // current Weapon in Slot i
    393390    tickWeapon = this->currentSlotConfig[i].currentWeapon;
    394     if (tickWeapon != this->currentSlotConfig[i].nextWeapon) // if no change occures
    395     {
    396       if (tickWeapon != NULL && tickWeapon->isActive())
     391    // On A change (current != next)
     392    if (tickWeapon != this->currentSlotConfig[i].nextWeapon)
     393    {
     394      // if a Weapon is Active in slot i, deactivate it.
     395      if (tickWeapon != NULL )
    397396      {
    398         tickWeapon->requestAction(WA_DEACTIVATE);
     397        if (tickWeapon->isActive())
     398        {
     399          tickWeapon->requestAction(WA_DEACTIVATE);
     400          continue;
     401        }
     402        else
     403        {
     404          tickWeapon->toList(OM_NULL);
     405          this->currentSlotConfig[i].currentWeapon = NULL;
     406        }
     407      }
     408
     409      // switching to next Weapon
     410      tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon;
     411      if (tickWeapon != NULL)
     412      {
     413        if (this->parent != NULL)
     414          tickWeapon->toList(this->parent->getOMListNumber());
     415        tickWeapon->requestAction(WA_ACTIVATE);
     416        this->currentSlotConfig[i].position.activateNode();
     417        tickWeapon->setParent(&this->currentSlotConfig[i].position);
     418        printf("ACTIVATE\n");
    399419      }
    400420      else
    401       {
    402         if (this->currentSlotConfig[i].currentWeapon != NULL)
    403           this->currentSlotConfig[i].currentWeapon->toList(OM_NULL);
    404         tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon;
    405         if (tickWeapon != NULL)
    406         {
    407           tickWeapon->requestAction(WA_ACTIVATE);
    408           tickWeapon->setParent(&this->currentSlotConfig[i].position);
    409           tickWeapon->toList(this->parent->getOMListNumber());
    410           this->currentSlotConfig[i].position.activateNode();
    411           if (this->parent->isA(CL_PLAYABLE))
    412           {
    413             dynamic_cast<Playable*>(this->parent)->weaponConfigChanged();
    414           }
    415         }
    416         else
    417           this->currentSlotConfig[i].position.deactivateNode();
    418       }
    419     }
    420 
    421     if( tickWeapon != NULL && tickWeapon->isActive())
    422       tickWeapon->tickW(dt);
    423   }
    424 
    425   crosshair->setRotationSpeed(5);
     421        this->currentSlotConfig[i].position.deactivateNode();
     422      if (this->parent != NULL && this->parent->isA(CL_PLAYABLE))
     423        dynamic_cast<Playable*>(this->parent)->weaponConfigChanged();
     424    }
     425  }
    426426}
    427427
     
    457457            (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS))
    458458          return i;
    459     }
     459      }
    460460  }
    461461  else
Note: See TracChangeset for help on using the changeset viewer.