Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 16, 2010, 9:35:11 PM (14 years ago)
Author:
dafrick
Message:

Removed some TODO's. Finished up documenting pickup module.

Location:
code/trunk/src/modules/pickup
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pickup/DroppedPickup.cc

    r6524 r6540  
    2828
    2929/**
    30     @file
     30    @file DroppedPickup.cc
    3131    @brief Implementation of the DroppedPickup class.
    3232*/
     
    3636#include "core/CoreIncludes.h"
    3737#include "interfaces/Pickupable.h"
     38#include "interfaces/PickupCarrier.h"
    3839#include "graphics/Model.h"
    3940
     
    6566        The distance at which the PickupSpawner triggers. Default is 10.
    6667    */
    67     DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 10, 1)
     68    DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 5, 1)
    6869    {   
    6970        RegisterObject(DroppedPickup);
    7071
    71         this->setPosition(position);
     72        this->setPosition(carrier->getCarrierPosition());
    7273        this->setActive(false);
     74       
     75        //TODO: Do more elegantly.
    7376        this->startRespawnTimer();
    7477    }
  • code/trunk/src/modules/pickup/DroppedPickup.h

    r6524 r6540  
    2828
    2929/**
    30     @file
     30    @file DroppedPickup.h
    3131    @brief Definition of the DroppedPickup class.
    3232*/
     
    5353        public:
    5454            DroppedPickup(BaseObject* creator); //!< Default constructor.
    55             DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance = 10.0); //!< Constructor.
     55            DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance = 10.0); //!< Constructor.
    5656            virtual ~DroppedPickup(); //!< Destructor.
    5757
  • code/trunk/src/modules/pickup/Pickup.cc

    r6533 r6540  
    2727*/
    2828
     29/**
     30    @file Pickup.cc
     31    @brief Implementation of the Pickup class.
     32*/
     33
    2934#include "Pickup.h"
    3035
     
    4146    /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
    4247    /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
    43    
    44     //TODO: Should this be here? Does it work without?
    45     CreateFactory(Pickup);
    4648   
    4749    Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
     
    224226        Returns true if a spawner was created, false if not.
    225227    */
    226     bool Pickup::createSpawner(const Vector3& position)
    227     {
    228         new DroppedPickup(this, this, position);
     228    bool Pickup::createSpawner(void)
     229    {
     230        new DroppedPickup(this, this, this->getCarrier());
    229231        return true;
    230232    }
  • code/trunk/src/modules/pickup/Pickup.h

    r6524 r6540  
    2525 *      ...
    2626 *
     27*/
     28
     29/**
     30    @file Pickup.h
     31    @brief Declaration of the Pickup class.
    2732*/
    2833
     
    7075    {
    7176       
     77        protected:
     78            Pickup(BaseObject* creator); //!< Constructor.
     79       
    7280        public:
    73             Pickup(BaseObject* creator); //!< Constructor.
    7481            virtual ~Pickup(); //!< Destructor.
    7582           
     
    124131            void initializeIdentifier(void);
    125132           
    126             virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     133            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    127134           
    128135            /**
  • code/trunk/src/modules/pickup/PickupCollection.cc

    r6538 r6540  
    158158       
    159159        PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
    160         //! Clone allPickupables this PickupCollection consist of.
     160        //! Clone all Pickupables this PickupCollection consist of.
    161161        for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    162162        {
     
    240240        Returns true if a spawner was created, false if not.
    241241    */
    242     bool PickupCollection::createSpawner(const Vector3& position)
    243     {
    244         new DroppedPickup(this, this, position);
     242    bool PickupCollection::createSpawner(void)
     243    {
     244        new DroppedPickup(this, this, this->getCarrier());
    245245        return true;
    246246    }
  • code/trunk/src/modules/pickup/PickupCollection.h

    r6538 r6540  
    7777            void initializeIdentifier(void); //!< Initializes the PickupIdentifier for this pickup.
    7878           
    79             virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     79            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    8080           
    8181            PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves.
  • code/trunk/src/modules/pickup/PickupManager.cc

    r6524 r6540  
    2828
    2929/**
    30     @file
     30    @file PickupManager.cc
    3131    @brief Implementation of the PickupManager class.
    3232*/
     
    5050        Constructor. Registers the PickupManager and creates the default PickupRepresentation.
    5151    */
    52     PickupManager::PickupManager()
     52    PickupManager::PickupManager() : defaultRepresentation_(NULL)
    5353    {
    54         this->defaultRepresentation_ = NULL;
    55         this->pickupCarrierStructure_ = NULL;
    5654        RegisterRootObject(PickupManager);
    5755       
     
    6866        if(this->defaultRepresentation_ != NULL)
    6967            this->defaultRepresentation_->destroy();
    70        
    71         if(this->pickupCarrierStructure_ != NULL)
    72             delete this->pickupCarrierStructure_;
    7368    }
    7469   
     
    8479        Returns true if successful and false if not.
    8580    */
    86     //TODO: Make sure that either the PickupRepresentation is destroyed upon destruction of the PickupManager if the representation wasn't created with XMLPort.
    8781    bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    8882    {
  • code/trunk/src/modules/pickup/PickupManager.h

    r6524 r6540  
    2828
    2929/**
    30     @file
     30    @file PickupManager.h
    3131    @brief Definition of the PickupManager class.
    3232*/
     
    4646namespace orxonox
    4747{
    48     //TODO: Actually utilize this.
    49     struct PickupCarrierNode
    50     {
    51         Identifier* identifier;
    52         std::set<PickupCarrierNode*> children;
    53     };
    5448
    5549    /**
     
    7468            PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
    7569           
    76             //TODO: Delete or utilitze this.
    77             //bool registerCarrier(Identifier* parent, )
    78            
    7970        private:
    8071            static PickupManager* singletonPtr_s;
     
    8273            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
    8374            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
    84            
    85             //TODO: Delete or utilize this.
    86             PickupCarrierNode* pickupCarrierStructure_;
    8775       
    8876    };
  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    r6524 r6540  
    2727*/
    2828
     29/**
     30    @file PickupRepresentation.cc
     31    @brief Implementation of the PickupRepresentation class.
     32*/
     33
    2934#include "PickupRepresentation.h"
    3035
     
    4449        This is primarily for use of the PickupManager in creating a default PickupRepresentation.
    4550    */
    46     //TODO: Not this as creator!!!
    47     PickupRepresentation::PickupRepresentation() : BaseObject(this)
     51    PickupRepresentation::PickupRepresentation() : BaseObject(NULL), spawnerRepresentation_(NULL)
    4852    {
    49         this->spawnerRepresentation_ = NULL;
    50        
    5153        RegisterObject(PickupRepresentation);
    5254       
     
    5860        Default Constructor. Registers the object and initializes its member variables.
    5961    */
    60     PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator)
     62    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), spawnerRepresentation_(NULL)
    6163    {
    62         this->spawnerRepresentation_ = NULL;
    63        
    6464        RegisterObject(PickupRepresentation);
    6565       
     
    151151        Returns a pointer to the StaticEntity.
    152152    */
    153     //TODO: Think of more elegant solution.
     153    //TODO: Possibility to define default representation through XML.
    154154    StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
    155155    {
  • code/trunk/src/modules/pickup/PickupRepresentation.h

    r6524 r6540  
    2525 *      ...
    2626 *
     27*/
     28
     29/**
     30    @file PickupRepresentation.h
     31    @brief Definition of the PickupRepresentation class.
    2732*/
    2833
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r6524 r6540  
    2828
    2929/**
    30     @file
    31     @brief Implementation of PickupSpawner.
     30    @file PickupSpawner.cc
     31    @brief Implementation of the PickupSpawner class.
    3232*/
    3333
     
    5252        Pointer to the object which created this item.
    5353    */
    54     PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
    55     {
     54    PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator), pickup_(NULL)
     55    {
     56        RegisterObject(PickupSpawner);
     57       
    5658        this->initialize();
    57 
    58         RegisterObject(PickupSpawner);
    5959    }
    6060
     
    7373        The maximum number of items spawned by this PickupSpawner.
    7474    */
    75     PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator)
     75    PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator), pickup_(NULL)
    7676    {
    7777        RegisterObject(PickupSpawner);
     
    103103    void PickupSpawner::initialize(void)
    104104    {
    105         this->pickup_ = NULL;
    106        
    107105        this->triggerDistance_ = 20;
    108106        this->respawnTime_ = 0;
     
    170168        Time since last tick.
    171169    */
    172     //TODO: Replace this with a real DistanceTrigger? Or better with collisions?
     170    //TODO: Replace with collisions.
    173171    void PickupSpawner::tick(float dt)
    174172    {
     173        SUPER(PickupSpawner, tick, dt);
     174       
    175175        //! If the PickupSpawner is active.
    176176        if (this->isActive())
     
    215215        if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
    216216        {
    217             //TODO: Nicer? Does this even work?
    218217            this->startRespawnTimer();
    219218
     
    278277        Pawn which triggered the PickupSpawner.
    279278    */
    280     //TODO: Make more generic -> without pawn.
    281279    void PickupSpawner::trigger(Pawn* pawn)
    282280    {
     
    314312            else
    315313            {
    316                 //TODO: Really that severe?
    317314                if(target == NULL)
    318315                    COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl;
  • code/trunk/src/modules/pickup/PickupSpawner.h

    r6524 r6540  
    2828
    2929/**
    30     @file
    31     @brief Definition of PickupSpawner.
     30    @file PickupSpawner.h
     31    @brief Definition of the PickupSpawner class.
    3232*/
    3333
  • code/trunk/src/modules/pickup/items/HealthPickup.cc

    r6524 r6540  
    2626 *
    2727 */
     28
     29/**
     30    @file HealthPickup.cc
     31    @brief Implementation of the HealthPickup class.
     32*/
    2833
    2934#include "HealthPickup.h"
     
    9499        this->pickupIdentifier_->addParameter(type1, val1);
    95100       
    96         //TODO: Does this work, is val valid outside the function scope?
    97101        std::string val2 = this->getHealthType();
    98102        std::string type2 = "healthType";
     
    133137    void HealthPickup::tick(float dt)
    134138    {
     139        SUPER(HealthPickup, tick, dt);
     140       
    135141        if(this->isContinuous() && this->isUsed())
    136142        {
  • code/trunk/src/modules/pickup/items/HealthPickup.h

    r6524 r6540  
    2626 *
    2727 */
     28
     29/**
     30    @file HealthPickup.h
     31    @brief Declaration of the HealthPickup class.
     32*/
    2833
    2934#ifndef _HealthPickup_H__
Note: See TracChangeset for help on using the changeset viewer.