Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8844 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Jun 28, 2006, 12:17:53 PM (19 years ago)
Author:
bensch
Message:

deleting weapons should be fixed

Location:
trunk/src/world_entities/weapons
Files:
2 edited

Legend:

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

    r8315 r8844  
    3939{
    4040  this->init();
    41   this->setParent(parent);
     41  this->setParentEntity(parent);
     42
     43  assert (parent != NULL);
    4244}
    4345
     
    6668  this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
    6769
    68   this->parent = NULL;
     70  this->parentNode = NULL;
     71  this->parentEntity = NULL;
    6972
    7073  for (int i = 0; i < WM_MAX_CONFIGS; i++)
     
    161164 * a PNode.
    162165 */
    163 void WeaponManager::setParent(WorldEntity* parent)
    164 {
    165   this->parent = parent;
    166   if (this->parent != NULL)
     166void WeaponManager::setParentEntity(WorldEntity* parent)
     167{
     168  this->parentEntity = parent;
     169  if (this->parentNode == NULL)
     170    this->setParentNode(parent);
     171}
     172
     173
     174void WeaponManager::setParentNode(PNode* parent)
     175{
     176  this->parentNode = parent;
     177  assert(parent != NULL);
     178
     179  if (this->parentNode != NULL)
    167180  {
    168181    for (int i = 0; i < WM_MAX_SLOTS; i++)
    169       this->parent->addChild(&this->currentSlotConfig[i].position);
    170   }
    171 }
     182      this->parentNode->addChild(&this->currentSlotConfig[i].position);
     183  }
     184
     185}
     186
    172187
    173188/**
     
    280295  if(configID == this->currentConfigID)
    281296    this->currentSlotConfig[slotID].nextWeapon = weapon;
    282   if (this->parent != NULL)
    283   {
    284     this->parent->addChild(weapon);
    285     if (this->parent->isA(CL_PLAYABLE))
    286       dynamic_cast<Playable*>(this->parent)->weaponConfigChanged();
     297  //if (this->parent != NULL)
     298  {
     299    this->parentNode->addChild(weapon);
     300    if (this->parentEntity->isA(CL_PLAYABLE))
     301      dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
    287302    weapon->setDefaultTarget(this->crosshair);
    288303  }
     
    445460      if (tickWeapon != NULL)
    446461      {
    447         if (this->parent != NULL)
    448           tickWeapon->toList(this->parent->getOMListNumber());
     462           //        if (this->parent != NULL)
     463          tickWeapon->toList(this->parentEntity->getOMListNumber());
    449464        tickWeapon->requestAction(WA_ACTIVATE);
    450465        this->currentSlotConfig[i].position.activateNode();
     
    453468      else
    454469        this->currentSlotConfig[i].position.deactivateNode();
    455       if (this->parent != NULL && this->parent->isA(CL_PLAYABLE))
    456         dynamic_cast<Playable*>(this->parent)->weaponConfigChanged();
     470      if (this->parentEntity != NULL && this->parentEntity->isA(CL_PLAYABLE))
     471        dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
    457472    }
    458473    else if (unlikely(tickWeapon != NULL && tickWeapon->getCurrentState() == WS_DEACTIVATING))
  • trunk/src/world_entities/weapons/weapon_manager.h

    r6981 r8844  
    7070    long getSlotCapability(int slot) const { return this->currentSlotConfig[slot].capability; };
    7171
    72     void setParent(WorldEntity* parent);
     72    void setParentEntity(WorldEntity* parent);
     73    WorldEntity* getParentEntity() const { return this->parentEntity; };
     74
     75    void setParentNode(PNode* node);
    7376    /** @returns the Parent (carrier) of this WeaponManager */
    74     PNode* getParent() const { return this->parent; };
     77    PNode* getParentNode() const { return this->parentNode; };
    7578
    7679    bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
     
    107110
    108111  private:
    109     WorldEntity*            parent;                                   //!< The parent, this WeaponManager is connected to.
     112    WorldEntity*            parentEntity;                             //!< The parent, this WeaponManager is connected to.
     113    PNode*                  parentNode;                               //!< The parented Node the WeaponManager is connected to. (by default == parentEntity).
    110114
    111115    int                     slotCount;                                //!< number of weapon slots the ship has.
Note: See TracChangeset for help on using the changeset viewer.