Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 4, 2010, 11:56:26 AM (14 years ago)
Author:
dafrick
Message:

Lots of things done in pickups module. Compiles, but it seems, that I've also introduced an error preventing steering of the spaceship.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h

    r6421 r6466  
    3737#include "OrxonoxPrereqs.h"
    3838#include "core/OrxonoxClass.h"
     39#include "Pickupable.h"
    3940
    4041#include <set>
     42#include <list>
    4143
    4244namespace orxonox
    4345{
    4446
    45     class _OrxonoxExport PickupCarrier : public OrxonoxClass
     47    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
    4648    {
     49        friend class Pickupable;
    4750       
    4851        public:
    4952            PickupCarrier();
    5053            virtual ~PickupCarrier() {}
     54           
     55            //TODO: Secure uniqueness of each item in the set, if neccessary, check.
     56            inline bool pickup(Pickupable* pickup)
     57                {
     58                    bool pickedUp = this->pickups_.insert(pickup).second;
     59                    if(pickedUp) pickup->pickedUp(this);
     60                    return pickedUp;
     61                }
     62               
     63            inline bool drop(Pickupable* pickup)
     64                {
     65                   bool dropped = this->pickups_.erase(pickup) == 1;
     66                   if(dropped)
     67                   {
     68                       pickup->dropped();
     69                        //TODO: Create Spawner.
     70                   }
     71                   return dropped;
     72                }
     73               
     74            inline bool isTarget(Pickupable* pickup)
     75                {
     76                    if(pickup->isTarget(this))
     77                        return true;
     78                    const std::list<PickupCarrier*>* children = this->getChildren();
     79                    for(std::list<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
     80                    {
     81                        if((*it)->isTarget(pickup))
     82                            return true;
     83                    }
     84                   
     85                    return false;
     86                }
     87           
     88        protected:           
     89            //TODO: Good return type?
     90            virtual const std::list<PickupCarrier*>* getChildren(void) = 0;
     91            virtual PickupCarrier* getParent(void) = 0;
    5192       
    5293        private:
     94            std::set<Pickupable*> pickups_;
    5395           
    54             std::set<Pickupable*> pickups_;
    5596       
    5697    };
Note: See TracChangeset for help on using the changeset viewer.