Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2010, 6:26:54 PM (15 years ago)
Author:
dafrick
Message:

Additional documentation, code niceifying and potential bug fixing. Also: Renamed DroppedItem to DroppedPickup.

Location:
code/branches/pickup3/src/modules/pickup
Files:
15 edited
2 moved

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/modules/pickup/CMakeLists.txt

    r6466 r6475  
    11SET_SOURCE_FILES(PICKUP_SRC_FILES
    2   DroppedItem.cc
     2  DroppedPickup.cc
    33  Pickup.cc
    44  PickupCollection.cc
  • code/branches/pickup3/src/modules/pickup/DroppedPickup.cc

    r6466 r6475  
    2323 *      Daniel 'Huty' Haggenmueller
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
    2828
    29 #include "DroppedItem.h"
     29/**
     30    @file
     31    @brief Implementation of the DroppedPickup class.
     32*/
     33
     34#include "DroppedPickup.h"
    3035
    3136#include "core/CoreIncludes.h"
     
    3742    /**
    3843    @brief
    39         Constructor. Registers object and sets default values.
     44        Default constructor. Registers object and sets default values.
    4045    */
    41     DroppedItem::DroppedItem(BaseObject* creator) : PickupSpawner(creator)
     46    DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator)
    4247    {
     48        RegisterObject(DroppedPickup);
     49       
    4350        this->initialize();
    44     }
    45 
    46     DroppedItem::DroppedItem(BaseObject* creator, Pickupable* item, const Vector3& position, float triggerDistance) : PickupSpawner(creator, item, triggerDistance, 0, 1)
    47     {   
    48         this->initialize();
    49        
    50         this->createDrop(position);
    51     }
    52    
    53     void DroppedItem::initialize(void)
    54     {
    55         RegisterObject(DroppedItem);
    56        
    57         this->gotPickedUp_ = false;
    5851    }
    5952
    6053    /**
    6154    @brief
    62         Default destructor.
     55        Constructor. Registers the object and sets values.
     56    @param creator
     57        The creator of the DroppedPickup.
     58    @param pickup
     59        The Pickupable that was dropped.
     60    @param position
     61        The position at which the DroppedPickup should be created.
     62    @param triggerDistance
     63        The distance at which the PickupSpawner triggers. Default is 10.
    6364    */
    64     DroppedItem::~DroppedItem()
     65    DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 0, 1)
     66    {   
     67        RegisterObject(DroppedPickup);
     68       
     69        this->initialize();
     70       
     71        this->setPosition(position);
     72    }
     73
     74    /**
     75    @brief
     76        Destructor.
     77    */
     78    DroppedPickup::~DroppedPickup()
    6579    {
    6680        if(this->gotPickedUp_ && this->pickup_ != NULL)
     
    6983        }
    7084    }
     85   
     86    /**
     87    @brief
     88        Initializes the member variables of the object.
     89    */
     90    void DroppedPickup::initialize(void)
     91    {
     92        this->gotPickedUp_ = false;
     93    }
    7194
    72     Pickupable* DroppedItem::getPickup(void)
     95    /**
     96    @brief
     97        Creates the Pickupable that is going to get picked up.
     98        In the case of the DroppedItem it is the one and only Pickupable that was dropped. No additional Pickupables of the same type are created.
     99    */
     100    Pickupable* DroppedPickup::getPickup(void)
    73101    {
    74102        return this->pickup_;
    75103    }
    76    
    77     //TODO; Doesn't seem to be needed anymore, just put setPosition in the constructor.
    78     void DroppedItem::createDrop(const Vector3& position)
    79     {
    80         this->setPosition(position);
    81        
    82         //TODO: Make this work.
    83         //const Model& model = PickupManager::getModel(item->getPickupIdentifier());
    84         //this->attach(model);
    85     }
    86104
    87 //TODO: Remove.
    88     //TODO: Comment.
    89     //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.
    90 //    /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
    91 //     {
    92 //         //TODO: triggerDistance?
    93 //         float triggerDistance = 20.0;
    94 //         DroppedItem* droppedItem = new DroppedItem(item, item, triggerDistance, 0, 1);
    95 //         
    96 //         //TODO: Do this somehwere else?
    97 //         Model* model = new Model(item);
    98 //         Billboard* billboard = new Billboard(item);
    99 //
    100 //         model->setMeshSource("sphere.mesh");
    101 //         model->setScale(3.0f);
    102 //
    103 //         billboard->setMaterial("Examples/Flare");
    104 //         billboard->setColour(flareColour);
    105 //         billboard->setScale(0.5f);
    106 //
    107 //         droppedItem->setPosition(position);
    108 //         droppedItem->attach(model);
    109 //         droppedItem->attach(billboard);
    110 //
    111 //         COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;
    112 //
    113 //         return droppedItem;
    114 //     }
    115 
    116     //TODO: See one function above.
    117 //     DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)
    118 //     {
    119 //         Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f);
    120 //         return DroppedItem::createDefaultDrop(item, after, flareColour, timeToLive);
    121 //     }
    122105}
  • code/branches/pickup3/src/modules/pickup/DroppedPickup.h

    r6466 r6475  
    2323 *      Daniel 'Huty' Haggenmueller
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     
    2929/**
    3030    @file
    31     @brief Definition of DroppedItem
     31    @brief Definition of the DroppedPickup class.
    3232*/
    3333
    34 #ifndef _DroppedItem_H__
    35 #define _DroppedItem_H__
     34#ifndef _DroppedPickup_H__
     35#define _DroppedPickup_H__
    3636
    3737#include "PickupPrereqs.h"
     
    4141namespace orxonox
    4242{
    43     class _OrxonoxExport DroppedItem : public PickupSpawner
     43   
     44    /**
     45    @brief
     46        Special PickupSpawner that is created whe a Pickupable is dropped. It just spawns one pickup, the one that was dropped.
     47    @author
     48        Daniel 'Huty' Haggenmueller
     49        Damian 'Mozork' Frick
     50    */
     51    class _OrxonoxExport DroppedPickup : public PickupSpawner
    4452    {
    4553        public:
    46             DroppedItem(BaseObject* creator);
    47             DroppedItem(BaseObject* creator, Pickupable* item, const Vector3& position, float triggerDistance);
    48             virtual ~DroppedItem();
     54            DroppedPickup(BaseObject* creator); //!< Default constructor.
     55            DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance = 10.0); //!< Constructor.
     56            virtual ~DroppedPickup(); //!< Destructor.
    4957
    5058        protected:
    51             virtual Pickupable* getPickup(void);
     59            virtual Pickupable* getPickup(void); //!< Creates the Pickupable that is going to get picked up.
    5260           
    5361        private:
    54             void initialize(void);
    55             void createDrop(const Vector3& position);
     62            void initialize(void); //!< Initializes the member variables of the object.
    5663           
    57             bool gotPickedUp_;
     64            bool gotPickedUp_; //!< Whether the pickup got picked up or not.
    5865
    5966    };
    6067}
    6168
    62 #endif /* _DroppedItem_H__ */
     69#endif /* _DroppedPickup_H__ */
  • code/branches/pickup3/src/modules/pickup/Pickup.cc

    r6474 r6475  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "util/StringUtils.h"
     33#include "pickup/PickupIdentifier.h"
     34#include "DroppedPickup.h"
    3235
    3336namespace orxonox
     
    3841    /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
    3942    /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
    40     /*static*/ const std::string Pickup::blankString_s = "";
    41    
    42     //TODO: Should this bee here? Does it work without?
     43   
     44    //TODO: Should this be here? Does it work without?
    4345    CreateFactory(Pickup);
    4446   
     
    4749        RegisterObject(Pickup);
    4850       
     51        this->initialize();
    4952    }
    5053   
     
    5457    }
    5558   
     59    /**
     60    @brief
     61        Initializes the member variables.
     62    */
     63    void Pickup::initialize(void)
     64    {
     65        this->activationType_ = pickupActivationType::immediate;
     66        this->durationType_ = pickupDurationType::once;
     67    }
     68   
     69    /**
     70    @brief
     71        Initializes the PickupIdentififer of this Pickup.
     72    */
    5673    void Pickup::initializeIdentifier(void)
    5774    {
    58         this->pickupIdentifier_.addClass(this->getIdentifier());
     75        //TODO: Check whether this could not be done in the Constructor if Pickupable. Would be much more convenient.
     76        this->pickupIdentifier_->addClass(this->getIdentifier());
    5977       
    6078        //TODO: Works?
    6179        std::string val1 = this->getActivationType();
    6280        std::string type1 = "activationType";
    63         this->pickupIdentifier_.addParameter(type1, val1);
     81        this->pickupIdentifier_->addParameter(type1, val1);
    6482       
    6583        std::string val2 = this->getDurationType();
    6684        std::string type2 = "durationType";
    67         this->pickupIdentifier_.addParameter(type2, val2);
    68     }
    69    
     85        this->pickupIdentifier_->addParameter(type2, val2);
     86    }
     87   
     88    /**
     89    @brief
     90        Method for creating a Pickup object through XML.
     91    */
    7092    void Pickup::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7193    {
     
    81103    @brief
    82104        Get the activation type of the pickup.
    83     @param buffer
    84         The buffer to store the activation type as string in.
     105    @return
     106        Returns a string containing the activation type.
    85107    */
    86108    const std::string& Pickup::getActivationType(void)
     
    93115                return activationTypeOnUse_s;
    94116            default:
    95                 return blankString_s;
     117                return BLANKSTRING;
    96118        }
    97119    }
     
    100122    @brief
    101123        Get the duration type of the pickup.
    102     @param buffer
    103         The buffer to store the duration type as string in.
     124    @return
     125        Returns a string containing the duration type.
    104126    */
    105127    const std::string& Pickup::getDurationType(void)
     
    112134                return durationTypeContinuous_s;
    113135            default:
    114                 return blankString_s;
     136                return BLANKSTRING;
    115137        }
    116138    }
     
    162184    /**
    163185    @brief
    164         Creates a duplicate of the pickup.
     186        Should be called when the pickup has transited from picked up to dropped or the other way around.
     187        Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method.
     188    */
     189    void Pickup::changedCarrier(void)
     190    {
     191        SUPER(Pickup, changedCarrier);
     192       
     193        //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
     194        if(this->isPickedUp() && this->isImmediate())
     195        {
     196            this->setUsed(true);
     197        }
     198    }
     199   
     200    /**
     201    @brief
     202        Creates a duplicate of the Pickup.
    165203    @return
    166204        Returns the clone of this pickup as a pointer to a Pickupable.
     
    179217        pickup->initializeIdentifier();
    180218    }
    181    
    182     void Pickup::changedCarrier(void)
    183     {
    184         SUPER(Pickup, changedCarrier);
    185        
    186         if(this->isPickedUp() && this->isImmediate())
    187         {
    188             this->setUsed(true);
    189         }
     219       
     220    /**
     221    @brief
     222        Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     223        This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
     224        DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
     225    @param position
     226        The position at which the PickupSpawner should be placed.
     227    @return
     228        Returns true if a spawner was created, false if not.
     229    */
     230    bool Pickup::createSpawner(const Vector3& position)
     231    {
     232        DroppedPickup::DroppedPickup(this, this, position);
     233        return true;
    190234    }
    191235   
  • code/branches/pickup3/src/modules/pickup/Pickup.h

    r6474 r6475  
    2828
    2929#ifndef _Pickup_H__
    30 #define Pickup_H__
     30#define _Pickup_H__
    3131
    3232#include "pickup/PickupPrereqs.h"
    3333
    34 #include "interfaces/Pickupable.h"
    3534#include "core/BaseObject.h"
    3635#include "core/XMLPort.h"
     36
     37#include "interfaces/Pickupable.h"
    3738
    3839namespace orxonox
     
    5960    }
    6061   
     62    /**
     63    @brief
     64        Pickup class. Offers base functionality for a wide range of pickups.
     65        Pickups ingeriting from this class cann choose an activation type and a duration type.
     66    @author
     67        Damian 'Mozork' Frick
     68    */
    6169    class _PickupExport Pickup : public Pickupable, public BaseObject
    6270    {
    6371       
    6472        public:
    65            
    66             Pickup(BaseObject* creator);
    67             virtual ~Pickup();
     73            Pickup(BaseObject* creator); //!< Constructor.
     74            virtual ~Pickup(); //!< Destructor.
    6875           
    6976            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     
    8592            const std::string& getDurationType(void); //!< Get the duration type of the pickup.
    8693           
     94            /**
     95            @brief Get whether the activation type is 'immediate'.
     96            @return Returns true if the activation type is 'immediate'.
     97            */
    8798            inline bool isImmediate(void)
    8899                { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
     100            /**
     101            @brief Get whether the activation type is 'onUse'.
     102            @return Returns true if the activation type is 'onUse'.
     103            */
    89104            inline bool isOnUse(void)
    90105                { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
     106            /**
     107            @brief Get whether the duration type is 'once'.
     108            @return Returns true if the duration type is 'once'.
     109            */
    91110            inline bool isOnce(void)
    92111                { return this->getDurationTypeDirect() == pickupDurationType::once; }
     112            /**
     113            @brief Get whether the duration type is 'continuous'.
     114            @return Returns true if the duration type is 'continuous'.
     115            */
    93116            inline bool isContinuous(void)
    94117                { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
    95                        
    96             virtual void clone(OrxonoxClass* item);
    97118           
    98             virtual void changedCarrier(void);
     119            virtual void changedCarrier(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
     120                                   
     121            virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the Pickup.
    99122               
    100123        protected:
    101124            void initializeIdentifier(void);
     125           
     126            virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    102127           
    103128            /**
     
    118143               
    119144        private:
     145            void initialize(void); //!< Initializes the member variables.
     146           
    120147            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
    121148            pickupDurationType::Value durationType_; //!< The duration type of the pickup.
     
    125152            static const std::string durationTypeOnce_s;
    126153            static const std::string durationTypeContinuous_s;
    127             static const std::string blankString_s; //TODO: Maybe already implemented somewhere?
    128154       
    129155    };
  • code/branches/pickup3/src/modules/pickup/PickupCollection.cc

    r6466 r6475  
    3838#include "core/XMLPort.h"
    3939#include "interfaces/PickupCarrier.h"
     40#include "DroppedPickup.h"
     41
     42#include "PickupCollectionIdentifier.h"
    4043
    4144namespace orxonox
     
    4952    {
    5053        RegisterObject(PickupCollection);
     54       
     55        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier();
    5156    }
    5257   
     
    6065        for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    6166        {
    62             delete *it;
     67            (*it)->destroy();
    6368        }
    6469    }
     
    8085    void PickupCollection::initializeIdentifier(void)
    8186    {
    82         this->pickupCollectionIdentifier_.addClass(this->getIdentifier());
     87        this->pickupCollectionIdentifier_->addClass(this->getIdentifier());
    8388       
    8489        for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    8590        {
    86             this->pickupCollectionIdentifier_.addPickup((*it)->getPickupIdentifier());
     91            this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());
    8792        }
     93    }
     94   
     95    /**
     96    @brief
     97        Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     98        This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
     99        DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
     100    @param position
     101        The position at which the PickupSpawner should be placed.
     102    @return
     103        Returns true if a spawner was created, false if not.
     104    */
     105    bool PickupCollection::createSpawner(const Vector3& position)
     106    {
     107        DroppedPickup::DroppedPickup(this, this, position);
     108        return true;
    88109    }
    89110   
     
    159180    }
    160181   
     182    const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
     183    {
     184        return this->pickupCollectionIdentifier_;
     185    }
     186   
    161187}
  • code/branches/pickup3/src/modules/pickup/PickupCollection.h

    r6466 r6475  
    3636#include "core/XMLPort.h"
    3737
    38 #include "PickupCollectionIdentifier.h"
    39 
    4038#include <list>
    4139
     
    6664            virtual void clone(OrxonoxClass* item);
    6765           
    68             virtual const PickupIdentifier* getPickupIdentifier(void)
    69                 { return &this->pickupCollectionIdentifier_; }
     66            virtual const PickupIdentifier* getPickupIdentifier(void);
    7067           
    7168            bool addPickupable(Pickupable* pickup);
     
    7572            void initializeIdentifier(void);
    7673           
    77             PickupCollectionIdentifier pickupCollectionIdentifier_;
     74            virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     75           
     76            PickupCollectionIdentifier* pickupCollectionIdentifier_;
    7877           
    7978        private:
  • code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc

    r6474 r6475  
    4444    }
    4545
    46     int PickupCollectionIdentifier::compare(const PickupIdentifier& identifier) const
     46    int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const
    4747    {
    48         PickupIdentifier* temp = const_cast<PickupIdentifier*>(&identifier);
     48        PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier);
    4949        const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp);
    5050        if(collectionIdentifier == NULL)
     
    6060        {
    6161           
    62             if((*it)->compare(**it2) < 0)
     62            if((*it)->compare(*it2) < 0)
    6363                return -1;
    64             if((*it2)->compare(**it) < 0)
     64            if((*it2)->compare(*it) < 0)
    6565                return 1;
    6666        }
  • code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h

    r6474 r6475  
    4545            ~PickupCollectionIdentifier();
    4646           
    47             virtual int compare(const PickupIdentifier& identifier) const;
     47            virtual int compare(const PickupIdentifier* identifier) const;
    4848           
    4949            void addPickup(const PickupIdentifier* identifier);
    5050           
    5151        private:
    52             std::set<const PickupIdentifier*, PickupIdentifierPtrCompare> identifiers_;
     52            std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_;
    5353           
    5454    };
  • code/branches/pickup3/src/modules/pickup/PickupManager.cc

    r6474 r6475  
    8383    */
    8484    //TODO: Make sure that either the PickupRepresentation is destroyed upon destruction of the PickupManager if the representation wasn't created with XMLPort.
    85     bool PickupManager::registerRepresentation(const PickupIdentifier& identifier, PickupRepresentation* representation)
     85    bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    8686    {
    8787        if(this->representations_.find(identifier) == this->representations_.end()) //!< If the Pickupable already has a RepresentationRegistered.
     
    104104    PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier)
    105105    {
    106         std::map<const PickupIdentifier, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(*identifier);
     106        std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
    107107        if(it == this->representations_.end())
    108108        {
  • code/branches/pickup3/src/modules/pickup/PickupManager.h

    r6474 r6475  
    7171            static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); }
    7272           
    73             bool registerRepresentation(const PickupIdentifier& identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
     73            bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
    7474            PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
    7575           
     
    8181           
    8282            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
    83             std::map<const PickupIdentifier, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
     83            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
    8484           
    8585            //TODO: Delete or utilize this.
  • code/branches/pickup3/src/modules/pickup/PickupPrereqs.h

    r6466 r6475  
    6666{
    6767
    68     class DroppedItem;
     68    class DroppedPickup;
    6969    class Pickup;
    7070    class PickupCollection;
  • code/branches/pickup3/src/modules/pickup/PickupRepresentation.cc

    r6474 r6475  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "graphics/Billboard.h"
     33#include "util/StringUtils.h"
    3234#include "PickupManager.h"
    33 #include "graphics/Billboard.h"
    3435
    3536namespace orxonox
     
    3839    CreateFactory(PickupRepresentation);
    3940   
     41    /**
     42    @brief
     43        Constructor. Registers the object and initializes its member variables.
     44        This is primarily for use of the PickupManager in creating a default PickupRepresentation.
     45    */
    4046    PickupRepresentation::PickupRepresentation() : BaseObject(this)
    4147    {
     
    4551    }
    4652   
     53    /**
     54    @brief
     55        Default Constructor. Registers the object and initializes its member variables.
     56    */
    4757    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator)
    4858    {
     
    5262    }
    5363   
     64    /**
     65    @brief
     66        Destructor.
     67    */
    5468    PickupRepresentation::~PickupRepresentation()
    5569    {
    56        
     70        if(this->spawnerRepresentation_ != NULL)
     71            this->spawnerRepresentation_->destroy();
    5772    }
    5873   
     74    /**
     75    @brief
     76        Initializes the member variables of this PickupRepresentation.
     77    */
    5978    void PickupRepresentation::initialize(void)
    6079    {
     
    6685    }
    6786   
     87    /**
     88    @brief
     89        Method for creating a PickupRepresentation object through XML.
     90    */
    6891    void PickupRepresentation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6992    {
     
    7699        XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
    77100       
    78         PickupManager::getInstance().registerRepresentation(*this->pickup_->getPickupIdentifier(), this);
     101        PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
    79102    }
    80103   
     104    /**
     105    @brief
     106        Get a spawnerRepresentation for a specific PickupSpawner.
     107    @param spawner
     108        A pointer to the PickupSpawner.
     109    @return
     110        Returns a pointer to the StaticEntity.
     111    */
    81112    StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner)
    82113    {
     
    84115        {
    85116            COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
    86             if(this->spawnerTemplate_ == "")
     117            if(this->spawnerTemplate_ == BLANKSTRING)
    87118            {
    88119                COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
     120                //!< If neither spawnerRepresentation nor spawnerTemplate was specified
    89121                return this->getDefaultSpawnerRepresentation(spawner);
    90122            }
    91123            this->addTemplate(this->spawnerTemplate_);
    92124        }
     125       
    93126        StaticEntity* representation = this->spawnerRepresentation_;
    94127       
     
    98131    }
    99132   
     133    /**
     134    @brief
     135        Get the default spawnerRepresentation for a specific PickupSpawner.
     136        Helper method of internal use.
     137    @param spawner
     138        A pointer to the PickupSpawner.
     139    @return
     140        Returns a pointer to the StaticEntity.
     141    */
     142    //TODO: Think of more elegant solution.
    100143    StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
    101144    {
  • code/branches/pickup3/src/modules/pickup/PickupRepresentation.h

    r6474 r6475  
    3232#include "PickupPrereqs.h"
    3333
     34#include "core/XMLPort.h"
     35#include "interfaces/Pickupable.h"
     36#include "pickup/PickupIdentifier.h"
     37#include "worldentities/StaticEntity.h"
     38#include "PickupSpawner.h"
     39
    3440#include "core/BaseObject.h"
    35 
    36 #include "core/XMLPort.h"
    37 #include "pickup/PickupIdentifier.h"
    38 #include "interfaces/Pickupable.h"
    39 #include "pickup/PickupSpawner.h"
    40 #include "worldentities/StaticEntity.h"
    4141
    4242namespace orxonox
    4343{
    4444
     45    /**
     46    @brief
     47        The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like.
     48        They are created through XML and are registered with the PickupManager.
     49    */
    4550    class _PickupExport PickupRepresentation : public BaseObject
    4651    {
    4752       
    4853        public:
    49             PickupRepresentation();
    50             PickupRepresentation(BaseObject* creator);
    51             virtual ~PickupRepresentation();
     54            PickupRepresentation(); //!< Constructor
     55            PickupRepresentation(BaseObject* creator); //!< Default constructor.
     56            virtual ~PickupRepresentation(); //!< Destructor.
    5257           
    5358            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5459           
     60            /**
     61            @brief Set the name of the Pickupable represented by this PickupRepresentation.
     62            @param name The name.
     63            */
    5564            inline void setName(const std::string& name)
    5665                { this->name_ = name; }
     66            /**
     67            @brief Set the description of the Pickupable represented by this PickupRepresentation.
     68            @param description The Description.
     69            */
    5770            inline void setDescription(const std::string& description)
    5871                { this->description_ = description; }
     72            /**
     73            @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation.
     74                   The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
     75            @param spawnerTemplate The name of the template.
     76            */
    5977            inline void setSpawnerTemplate(const std::string& spawnerTemplate)
    6078                { this->spawnerTemplate_ = spawnerTemplate; }
     79            /**
     80            @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
     81                   This will be set by the spawnerTemplate. Setting it when creating the PickupRepresentation without creating a template and specifying its name will be futile, because through the course of the game many PickupSpawners for one specific pickup type may have to be created, thus the StaticEntity that is the spawnerRepresentation has to be generated (with the template) for every new PickupSpawner spawning the Pickupable represented by this PickupRepresentation. The spawnerRepresentation that is set here, however can only be used once.
     82            @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
     83            */
    6184            inline void setSpawnerRepresentation(StaticEntity* representation)
    6285                { this->spawnerRepresentation_ = representation; }
     86            /**
     87            @brief Set the Pickupable that is represented by this PickupRepresentation.
     88            @param pickup A pointer to the Pickupable.
     89            */
    6390            inline void setPickup(Pickupable* pickup)
    6491                { this->pickup_ = pickup; }
    6592               
     93            /**
     94            @brief Get the name of the Pickupable represented by this PickupRepresentation.
     95            @return Returns the name.
     96            */
    6697            inline const std::string& getName(void)
    6798                { return this->name_; }
     99            /**
     100            @brief Get the description of the Pickupable represented by this PickupRepresentation.
     101            @return Returns the description.
     102            */
    68103            inline const std::string& getDescription(void)
    69104                { return this->description_; }
     105            /**
     106            @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
     107            @return Returns the name of the spawnerTemplate.
     108            */
    70109            inline const std::string& getSpawnerTemplate(void)
    71110                { return this->spawnerTemplate_; }
     111            /**
     112            @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
     113            @param index The index.
     114            @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.
     115            */
    72116            inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
    73117                { if(index == 0) return this->spawnerRepresentation_; return NULL; }
     118            /**
     119            @brief Get the Pickupable represented by this PickupRepresentation.
     120            @param index The index.
     121            @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
     122            */
    74123            inline const Pickupable* getPickup(unsigned int index)
    75124                { if(index == 0) return this->pickup_; return NULL; }
    76125               
    77             StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner);
     126            StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
    78127       
    79128        private:
    80             void initialize(void);
    81             StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner);
     129            void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
     130            StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
    82131           
    83             std::string name_;
    84             std::string description_;
    85             std::string spawnerTemplate_;
    86             StaticEntity* spawnerRepresentation_;
     132            std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation.
     133            std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation.
     134            std::string spawnerTemplate_; //!<  The name of the template of this PickupRepresentation.
     135            StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation.
    87136           
    88             Pickupable* pickup_;
    89            
     137            Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
    90138           
    91139    };
  • code/branches/pickup3/src/modules/pickup/PickupSpawner.cc

    r6474 r6475  
    3535
    3636#include "core/CoreIncludes.h"
    37 //#include "core/GUIManager.h"     // HACK; see below
    3837#include "core/Template.h"
    3938#include "core/XMLPort.h"
     
    4140#include "PickupManager.h"
    4241#include "PickupRepresentation.h"
    43 //#include "PickupInventory.h"    // HACK; Only for hack, remove later
    44 
    4542
    4643namespace orxonox
    4744{
    48 
    49 //     const float PickupSpawner::bounceSpeed_s = 6.0f;
    50 //     const float PickupSpawner::rotationSpeed_s = 1.0f;
    51 //     const float PickupSpawner::bounceDistance_s = 4.0f;
    5245
    5346    CreateFactory(PickupSpawner);
     
    6457       
    6558        this->initialize();
    66        
    67         PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(NULL);
    68         this->attach(representation->getSpawnerRepresentation(this));
    6959    }
    7060
     
    9585        this->setMaxSpawnedItems(maxSpawnedItems);
    9686       
    97         PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
    98         this->attach(representation->getSpawnerRepresentation(this));
     87        if(this->pickup_ == NULL)
     88        {
     89            COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
     90            this->setActive(false);
     91        }
     92        else
     93        {
     94            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
     95            this->attach(representation->getSpawnerRepresentation(this));
     96        }
    9997    }
    10098
     
    109107        this->triggerDistance_ = 20;
    110108        this->respawnTime_ = 0;
    111         this->tickSum_ = 0;
    112109        this->maxSpawnedItems_ = INF;
    113110        this->spawnsRemaining_ = INF;
     
    141138        XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
    142139        XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
    143 
    144         //TODO: Kill hack.
    145         // HACKs
    146         // Load the GUI image as soon as the PickupSpawner gets loaded
    147         //  = less delays while running
    148 //         BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
    149 //         BaseItem* asItem = orxonox_cast<BaseItem*>(newObject);
    150 //         if (asItem)
    151 //         {
    152 //             asItem->addTemplate(this->itemTemplate_);
    153 //             PickupInventory::getImageForItem(asItem);
    154 //             newObject->destroy();
    155 //         }
    156 
    157         //  & load the GUI itself too, along with some empty windows
    158         //   = even less delays
    159 //         GUIManager::getInstance().showGUI("PickupInventory");
    160 //         GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
    161 //         PickupInventory::getSingleton();
     140       
     141        if(this->pickup_ == NULL)
     142        {
     143            COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
     144            this->setActive(false);
     145        }
     146        else
     147        {
     148            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
     149            this->attach(representation->getSpawnerRepresentation(this));
     150        }
     151    }
     152   
     153    /**
     154    @brief
     155        Invoked when the activity has changed. Sets visibility of attached objects.
     156    */
     157    void PickupSpawner::changedActivity()
     158    {
     159        SUPER(PickupSpawner, changedActivity);
     160
     161        for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
     162        {
     163            (*it)->setVisible(this->isActive());
     164        }
     165    }
     166     
     167    /**
     168    @brief
     169        Tick, checks if any Pawn is close enough to trigger.
     170    @param dt
     171        Time since last tick.
     172    */
     173    //TODO: Replace this with a real DistanceTrigger? Or better with collisions?
     174    void PickupSpawner::tick(float dt)
     175    {
     176        //! If the PickupSpawner is active.
     177        if (this->isActive())
     178        {
     179            //! Iterate trough all Pawns.
     180            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     181            {
     182                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
     183                //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
     184                if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it))
     185                {
     186                    this->trigger(*it);
     187                }
     188            }
     189        }
     190    }
     191   
     192    /**
     193    @brief
     194        Sets the maximum number of spawned items.
     195    @param items
     196        The maximum number of spawned items to be set.
     197    */
     198    void PickupSpawner::setMaxSpawnedItems(int items)
     199    {
     200        this->maxSpawnedItems_ = items;
     201        this->spawnsRemaining_ = items;
     202    }
     203   
     204    /**
     205    @brief
     206        Decrements the number of remaining spawns.
     207        Sets the PickupSpawner to inactive for the duration of the respawnTime.
     208        Destroys the PickupSpawner if the number of remaining spawns has reached zero.
     209    */
     210    void PickupSpawner::decrementSpawnsRemaining(void)
     211    {
     212        if(this->spawnsRemaining_ != INF)
     213        {
     214            this->spawnsRemaining_--;
     215        }
     216        if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
     217        {
     218            //TODO: Nicer? Does this even work?
     219            this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
     220
     221            this->setActive(false);
     222            this->fireEvent();
     223        }
     224        else
     225        {
     226            COUT(3) << "PickupSpawner empty, selfdestruct initialized." << std::endl;
     227            this->setActive(false);
     228            this->destroy();
     229        }
    162230    }
    163231   
     
    172240        if(this->pickup_ != NULL)
    173241        {
    174             COUT(1) << "addPickupable called, with this->pickup_ already set." << std::endl;
     242            COUT(1) << "In PickupSpawner: setPickupable called, with this->pickup_ already set." << std::endl;
    175243            return;
    176244        }
    177245        if(pickup == NULL)
    178246        {
    179             COUT(1) << "Argument of addPickupable is NULL." << std::endl;
     247            COUT(1) << "In PickupSpawner: Argument of setPickupable is NULL." << std::endl;
    180248            return;
    181249        }
     
    197265    /**
    198266    @brief
    199         Invoked when the activity has changed. Sets visibility of attached objects.
    200     */
    201 //     void PickupSpawner::changedActivity()
    202 //     {
    203 //         SUPER(PickupSpawner, changedActivity);
    204 //
    205 //         for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
    206 //             (*it)->setVisible(this->isActive());
    207 //     }
    208 
    209     /**
    210     @brief
    211         Sets the maximum number of spawned items.
    212     @param items
    213         The maximum number of spawned items to be set.
    214     */
    215     void PickupSpawner::setMaxSpawnedItems(int items)
    216     {
    217         this->maxSpawnedItems_ = items;
    218         this->spawnsRemaining_ = items;
    219     }
    220 
    221     /**
    222     @brief
    223         Tick, checks if any Pawn is close enough to trigger.
    224     @param dt
    225         Time since last tick.
    226     */
    227     //TODO: Replace this with a real DistanceTrigger? Or better with collisions?
    228     void PickupSpawner::tick(float dt)
    229     {
    230         //! If the PickupSpawner is active.
    231         if (this->isActive())
    232         {
    233             //! Iterate trough all Pawns.
    234             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    235             {
    236                 Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    237                 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
    238                 if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it))
    239                 {
    240                     this->trigger(*it);
    241                 }
    242             }
    243 
    244             //! Animation.
    245 //             this->yaw(Radian(rotationSpeed_s*dt));
    246 //             this->tickSum_ += bounceSpeed_s*dt;
    247 //             this->translate(Vector3(0,bounceDistance_s*dt*sin(this->tickSum_),0));
    248 //             if (this->tickSum_ > 2*Ogre::Math::PI)
    249 //                 this->tickSum_ -= 2*Ogre::Math::PI;
    250         }
    251     }
    252 
    253     /**
    254     @brief
    255267        Trigger the PickupSpawner.
    256 
    257         Adds the pickup to the Pawn that triggered,
    258         sets the timer to re-activate and deactives the PickupSpawner.
    259 
     268        Adds the pickup to the Pawn that triggered, sets the timer to re-activate and deactives the PickupSpawner.
    260269    @param pawn
    261270        Pawn which triggered the PickupSpawner.
    262271    */
     272    //TODO: Make more generic -> without pawn.
    263273    void PickupSpawner::trigger(Pawn* pawn)
    264274    {
    265         //TODO: If private, isActive doesn't need to be tested anymore.
    266275        if (this->isActive()) //!< Checks whether PickupItem is active.
    267276        {
     277            PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
     278            if(carrier == NULL)
     279            {
     280                COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl;
     281                return;
     282            }
     283           
     284            if(!carrier->isTarget(this->pickup_))
     285            {
     286                COUT(4) << "PickupSpawner triggered but Pawn wasn't a target of the Pickupable." << std::endl;
     287                return;
     288            }
     289           
     290            PickupCarrier* target = carrier->getTarget(this->pickup_);
    268291            Pickupable* pickup = this->getPickup();
    269             if (pickup != NULL) //!< If everything went ok, and pickup is not NULL.
    270             {
    271                 //TODO: Not correct anymore.
    272                 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
    273                 if(carrier == NULL)
    274                 {
    275                     COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl;
    276                     return;
    277                 }
     292           
     293            if(target != NULL || pickup != NULL)
     294            {
     295                if(carrier->pickup(pickup))
     296                {
     297                    this->decrementSpawnsRemaining();
     298                }
     299                else
     300                {
     301                    pickup->destroy();
     302                }
     303            }
     304            else
     305            {
     306                //TODO: Really that severe?
     307                if(target == NULL)
     308                    COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl;
    278309               
    279                 if(carrier->pickup(pickup))
    280                 {
    281                     COUT(3) << "Pickup got picked up." << std::endl;
    282 
    283                     this->decrementSpawnsRemaining();
     310                if(pickup == NULL)
     311                {
     312                    COUT(1) << "PickupSpawner: getPickup produced an error, no Pickupable created." << std::endl;
    284313                }
    285314                else
     
    288317                }
    289318            }
    290         }
    291     }
    292    
    293     /**
    294     @brief
    295         Decrements the number of remaining spawns.
    296         Sets the PickupSpawner to inactive for the duration of the respawnTime.
    297         Destroys the PickupSpawner if the number of remaining spawns has reached zero.
    298        
    299     */
    300     void PickupSpawner::decrementSpawnsRemaining(void)
    301     {
    302         if(this->spawnsRemaining_ != INF)
    303         {
    304             this->spawnsRemaining_--;
    305         }
    306         if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
    307         {
    308             //TODO: Nicer? Does this even work?
    309             this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
    310 
    311             this->setActive(false);
    312             this->fireEvent();
    313         }
    314         else
    315         {
    316             COUT(3) << "PickupSpawner empty, selfdistruct initialized." << std::endl;
    317             this->setActive(false);
    318             this->destroy(); //TODO: Implement destroy().
    319319        }
    320320    }
  • code/branches/pickup3/src/modules/pickup/PickupSpawner.h

    r6466 r6475  
    2323 *      Daniel 'Huty' Haggenmueller
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     
    3838
    3939#include <string>
     40#include "interfaces/Pickupable.h"
    4041#include "tools/Timer.h"
     42
    4143#include "tools/interfaces/Tickable.h"
    4244#include "worldentities/StaticEntity.h"
    43 #include "interfaces/Pickupable.h"
    4445
    4546namespace orxonox
    4647{
    4748    /**
    48         @brief PickupSpawner.
    49         @author Daniel 'Huty' Haggenmueller
     49        @brief
     50            The PickupSpawner class is responsible for spawning pickups of a specific type.
     51            Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things.
     52        @author
     53            Daniel 'Huty' Haggenmueller
     54            Damian 'Mozork' Frick
    5055    */
    5156    class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
    5257    {
    5358        public:
    54             //TODO: Add limit of items spawned here.
    55             PickupSpawner(BaseObject* creator);
    56             PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems);
    57             virtual ~PickupSpawner();
     59            PickupSpawner(BaseObject* creator); //!< Default Constructor.
     60            PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor.
     61            virtual ~PickupSpawner(); //!< Destructor.
    5862
    59             //virtual void changedActivity();                                 //!< Invoked when activity has changed (set visibilty).
    6063            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a PickupSpawner through XML.
     64            virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
    6165            virtual void tick(float dt);
    6266
    6367            /**
    64                 @brief Get the distance in which to trigger.
    65                 @return Returns the distance in which this gets triggered.
     68            @brief Get the distance in which to trigger.
     69            @return Returns the distance in which this gets triggered.
    6670            */
    6771            inline float getTriggerDistance() const
    6872                { return this->triggerDistance_; }
    6973            /**
    70                 @brief Set the distance in which to trigger.
    71                 @param value The new distance in which to trigger.
     74            @brief Set the distance in which to trigger.
     75            @param value The new distance in which to trigger.
    7276            */
    7377            inline void setTriggerDistance(float value)
     
    7579
    7680            /**
    77                 @brief Get the time to respawn.
    78                 @returns Returns the time after which this gets re-actived.
     81            @brief Get the time to respawn.
     82            @returns Returns the time after which this gets re-actived.
    7983            */
    8084            inline float getRespawnTime() const
    8185                { return this->respawnTime_; }
    8286            /**
    83                 @brief Set the time to respawn.
    84                 @param time New time after which this gets re-actived.
     87            @brief Set the time to respawn.
     88            @param time New time after which this gets re-actived.
    8589            */
    8690            inline void setRespawnTime(float time)
     
    8892
    8993            /**
    90                 @brief Get the maximum number of items that will be spawned by this PickupSpawner.
    91                 @return Returns the maximum number of items spawned by this PickupSpawner.
     94            @brief Get the maximum number of items that will be spawned by this PickupSpawner.
     95            @return Returns the maximum number of items spawned by this PickupSpawner.
    9296            */
    9397            inline int getMaxSpawnedItems(void)
    9498                { return this->maxSpawnedItems_; }
    95             void setMaxSpawnedItems(int items);
     99            void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.
    96100
    97101        protected:
    98             virtual Pickupable* getPickup(void);
     102            void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
    99103           
    100             void setPickupable(Pickupable* pickup);
    101             const Pickupable* getPickupable(void);
     104            virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
    102105           
    103             void decrementSpawnsRemaining(void);
     106            void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
     107            const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
    104108           
    105109            Pickupable* pickup_; //!< The pickup to be spawned.
     
    108112            void initialize(void);
    109113           
    110             void trigger(Pawn* pawn);                                       //!< Method called when a Pawn is close enough.
    111             void respawnTimerCallback();                                    //!< Method called when the timer runs out.
     114            void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
     115            void respawnTimerCallback(); //!< Method called when the timer runs out.
    112116
    113             int maxSpawnedItems_;                   //!< Maximum number of items spawned by this PickupSpawner.
    114             int spawnsRemaining_;                   //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
     117            int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner.
     118            int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
    115119
    116             float triggerDistance_;                 //!< Distance in which this gets triggered.
     120            float triggerDistance_; //!< Distance in which this gets triggered.
    117121
    118             /* Pickup animation */
    119             float tickSum_;                         //!< Adds up tick to use in sine movement
    120             static const float bounceSpeed_s;       //!< Speed of pickup to bounce up and down
    121             static const float bounceDistance_s;    //!< Distance the pickup bounces up and down
    122             static const float rotationSpeed_s;     //!< Rotation speed of pickup
     122            float respawnTime_; //!< Time after which this gets re-actived.
     123            Timer respawnTimer_; //!< Timer used for re-activating.
    123124
    124             float respawnTime_;                     //!< Time after which this gets re-actived.
    125             Timer respawnTimer_;                    //!< Timer used for re-activating.
    126 
    127             static const int INF = -1;             //!< Constant for infinity.
     125            static const int INF = -1; //!< Constant for infinity.
    128126    };
    129127}
  • code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc

    r6474 r6475  
    3333
    3434#include "worldentities/pawns/Pawn.h"
     35#include "pickup/PickupIdentifier.h"
    3536
    3637#include <sstream>
     
    7071    void HealthPickup::initializeIdentifier(void)
    7172    {
    72         this->pickupIdentifier_.addClass(this->getIdentifier());
     73        this->pickupIdentifier_->addClass(this->getIdentifier());
    7374       
    7475        std::stringstream stream;
     
    7677        std::string type1 = "health";
    7778        std::string val1 = stream.str();
    78         this->pickupIdentifier_.addParameter(type1, val1);
     79        this->pickupIdentifier_->addParameter(type1, val1);
    7980       
    8081        //TODO: Does this work, is val valid outside the function scope?
    8182        std::string val2 = this->getHealthType();
    8283        std::string type2 = "healthType";
    83         this->pickupIdentifier_.addParameter(type2, val2);
     84        this->pickupIdentifier_->addParameter(type2, val2);
    8485    }
    8586   
Note: See TracChangeset for help on using the changeset viewer.