Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 14, 2009, 1:44:19 PM (16 years ago)
Author:
rgrieder
Message:

Merged pickup branch revisions to pickup2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc

    r5929 r5947  
    4141    CreateFactory(DroppedItem);
    4242
     43    /**
     44    @brief
     45        Constructor. Registers object and sets default values.
     46    */
    4347    DroppedItem::DroppedItem(BaseObject* creator) : StaticEntity(creator)
    4448    {
     
    4751        this->triggerDistance_ = 20.0f;
    4852        this->timeToLive_ = 0;
    49         this->item_ = 0;
     53        this->item_ = NULL;
    5054    }
     55
     56    /**
     57    @brief
     58        Default destructor.
     59    */
     60    //TODO: Destroy something?
    5161    DroppedItem::~DroppedItem()
    5262    {
     63       
    5364    }
     65
     66    /**
     67    @brief
     68        Checks whether any pawn is in triggerDistance of the Item and calls this->trigger if so.
     69    @param dt
     70        The  duration of the last time interval.   
     71    */
     72    //TODO: Replace this with a DistanceTrigger!
    5473    void DroppedItem::tick(float dt)
    5574    {
    5675        if (this->item_)
    5776        {
    58             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     77            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) //!< Iterate through all Pawns.
    5978            {
    6079                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
     
    6483        }
    6584    }
     85
     86    /**
     87    @brief
     88        Called when the DroppedItem is triggered. Adds the item to the triggering pawn.
     89    */
    6690    void DroppedItem::trigger(Pawn* pawn)
    6791    {
    68         if (this->item_->pickedUp(pawn))
     92        if (this->item_->pickedUp(pawn)) //If pickup was successful.
    6993        {
    7094            COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl;
     
    7296        }
    7397    }
     98
     99    /**
     100    @brief
     101        Creates a timer to call this->timerCallback() at expiration of timeToLive.
     102    */
     103    //TODO: Better Comments.
    74104    void DroppedItem::createTimer()
    75105    {
     
    79109        }
    80110    }
     111   
     112    /**
     113    @brief
     114        Destroys the item. Called by the set timer upon its expiration.
     115    */
     116    //TODO: Choose better function name if this doesn't create dependency inconsistencies. e.g. this->destroy() or this->timeOut()
     117    //Make certain that only one pawn has the same item, because if not, deliting the item would lead to a possible segfault.
     118    //If the item is destroyed here, shouldn't it be destroyed in the destructor as well?
    81119    void DroppedItem::timerCallback()
    82120    {
     
    90128    }
    91129
    92     DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
     130    /**
     131    @brief
     132       
     133    */
     134    //TODO: Comment.
     135    //This is for pawns dropping items they have...
     136    //Probably better to create a spawner with only 1 item in it.
     137    //Various different thigs are done here, which in my opinion should eighter be done in XML or some where else, preferably in XML.
     138    //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.
     139    //The position, item and timetoLive should be specified by this Classes XMLPort function.
     140    //These adjustments above, will very likely create inkonsistencies in the level files, possibly templates.
     141    /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
    93142    {
    94143        DroppedItem* drop = new DroppedItem(item);
     
    116165        return drop;
    117166    }
     167
     168    /**
     169    @brief
     170
     171    */
     172    //TODO: See one function above.
    118173    DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)
    119174    {
Note: See TracChangeset for help on using the changeset viewer.