Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 6, 2009, 3:53:50 PM (16 years ago)
Author:
danielh
Message:
  • some changes to the base framework
  • added DroppedItem
  • implemented usable items and a test UsableItem (Jump), console command to use an item is "useItem"
  • added ModifierType::Acceleration
Location:
code/branches/pickups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickups

    • Property svn:ignore set to
      build
      dependencies
  • code/branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc

    r2864 r2900  
    9494        for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
    9595        {
    96             (*it).second->dropped((*it).second->getOwner());
    97 
    98             delete (*it).second;
     96            if((*it).second && (*it).second->getOwner())
     97                (*it).second->dropped((*it).second->getOwner());
    9998        }
    10099        this->items_.clear();
     
    125124            return false;
    126125        }
     126    }
     127    //! Uses the first usable item in the collection on the owner.
     128    void PickupCollection::useItem()
     129    {
     130        Identifier* ident = Class(UsableItem);
     131        for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
     132        {
     133            if ((*it).second->isA(ident))
     134            {
     135                UsableItem* asUsable = dynamic_cast<UsableItem*>((*it).second);
     136                asUsable->used(this->owner_);
     137                return;
     138            }
     139        }
     140    }
     141    /**
     142        @brief Uses a usable item on the owner of the collection.
     143        @param item Item to use.
     144    */
     145    void PickupCollection::useItem(UsableItem* item)
     146    {
     147        if (item && this->owner_)
     148            item->used(this->owner_);
    127149    }
    128150    /**
Note: See TracChangeset for help on using the changeset viewer.