Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6540 for code/trunk/src


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

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

Location:
code/trunk/src
Files:
24 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__
  • code/trunk/src/modules/weapons/projectiles/Projectile.cc

    r6524 r6540  
    123123            }
    124124
    125             float dmg = this->damage_;
    126             //TODO: Remove.
    127 //             if (this->owner_)
    128 //                 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
    129 
    130125            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    131126            if (victim)
    132                 victim->hit(this->owner_, contactPoint, dmg);
     127                victim->hit(this->owner_, contactPoint, this->damage_);
    133128        }
    134129        return false;
  • code/trunk/src/modules/weapons/projectiles/Rocket.cc

    r6524 r6540  
    200200            }
    201201
    202             float dmg = this->damage_;
    203             //TODO: This souldn't be necessary here.
    204             //if (this->owner_)
    205             //    dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
    206 
    207202            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    208203            if (victim)
    209                 victim->hit(this->owner_, contactPoint, dmg);
     204                victim->hit(this->owner_, contactPoint, this->damage_);
    210205//             this->destroy();
    211206        }
  • code/trunk/src/orxonox/interfaces/PickupCarrier.h

    r6533 r6540  
    2828
    2929/**
    30     @file
     30    @file PickupCarrier.h
    3131    @brief Definition of the PickupCarrier class.
    3232*/
     
    4848{
    4949
     50    //! Pre-declarations.
    5051    class Pickup;
    5152    class HealthPickup;
     
    6061    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
    6162    {
    62         friend class Pickupable; //!< The Pickupable has full acces to its PickupCarrier.
    63         //TODO: Ugly workaround.
     63         //! So that the different Pickupables have full access to their PickupCarrier.
     64        friend class Pickupable;
    6465        friend class Pickup;
    6566        friend class HealthPickup;
     
    108109            @return Returns true if the PickupCarrier or one of its children is a target, false if not.
    109110            */
    110             //TODO: Use?
    111111            bool isTarget(const Pickupable* pickup)
    112112                {
     
    154154                    return NULL;
    155155                }
     156               
     157            /**
     158            @brief Get the (absolute) position of the PickupCarrier.
     159                   This method needs to be implemented by any direct derivative class of PickupCarrier.
     160            @return Returns the position as a Vector3.
     161            */
     162            virtual const Vector3& getCarrierPosition(void) = 0;
    156163           
    157164        protected:       
     
    159166            @brief Get all direct children of this PickupSpawner.
    160167                   This method needs to be implemented by any direct derivative class of PickupCarrier.
     168                   The returned list will be deleted by the methods calling this function.
    161169            @return Returns a pointer to a list of all direct children.
    162170            */
    163             //TODO: Good return type? Maybe not const and destroyed in isTarget...
    164171            virtual std::list<PickupCarrier*>* getCarrierChildren(void) = 0;
    165172            /**
     
    169176            */
    170177            virtual PickupCarrier* getCarrierParent(void) = 0;
    171             /**
    172             @brief Get the (absolute) position of the PickupCarrier.
    173                    This method needs to be implemented by any direct derivative class of PickupCarrier.
    174             @return Returns the position as a Vector3.
    175             */
    176             virtual const Vector3& getCarrierPosition(void) = 0;
    177178                           
    178179            /**
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    r6538 r6540  
    4646        Constructor. Registers the objects and initializes its member variables.
    4747    */
    48     Pickupable::Pickupable()
    49     {
    50         this->used_ = false;
    51         this->pickedUp_ = false;
    52        
     48    Pickupable::Pickupable() : used_(false), pickedUp_(false)
     49    {       
    5350        RegisterRootObject(Pickupable);
    5451       
     
    231228        this->setPickedUp(false);
    232229       
    233         bool created = this->createSpawner(this->getCarrier()->getCarrierPosition());
     230        bool created = this->createSpawner();
    234231       
    235232        this->setCarrier(NULL);
    236         //TODO: possible problem.
     233       
    237234        if(!created)
    238235        {
     
    267264        A reference to a pointer to the OrxonoxClass that is to be duplicated.
    268265    */
    269     //TODO: Specify how the implementation must be done in detail.
    270266    void Pickupable::clone(OrxonoxClass*& item)
    271267    {
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r6539 r6540  
    5151        Damian 'Mozork' Frick
    5252    */
    53     //TODO: Add stuff like weight/space ?
    5453    class _OrxonoxExport Pickupable : virtual public OrxonoxClass
    5554    {
     55        protected:
     56            Pickupable(); //!< Default constructor.
    5657       
    5758        public:
    58             Pickupable(); //!< Default constructor.
    5959            virtual ~Pickupable(); //!< Default destructor.
    6060           
     
    113113                { return this->pickupIdentifier_; }
    114114               
    115             //TODO: Make them work as protected.
    116115            bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input.
    117116            bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up.
     
    131130            @return Returns true if a spawner was created, false if not.
    132131            */
    133             virtual bool createSpawner(const Vector3& position) = 0;
     132            virtual bool createSpawner(void) = 0;
    134133           
    135             //TODO: Move to private and create get method in protected.
    136134            PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.
    137135           
  • code/trunk/src/orxonox/items/Engine.cc

    r6524 r6540  
    3535#include "Scene.h"
    3636#include "worldentities/pawns/SpaceShip.h"
    37 //TODO: Remove.
    38 //#include "pickup/ModifierType.h"
    3937#include "tools/Shader.h"
    4038
     
    194192        }
    195193
    196         //TODO: Correct?
    197194        this->ship_->setAcceleration(this->ship_->getOrientation() * acceleration);
    198195
  • code/trunk/src/orxonox/pickup/PickupIdentifier.cc

    r6524 r6540  
    2626 *
    2727 */
     28
     29/**
     30    @file PickupIdentifier.cc
     31    @brief Implementation of the PickupIdentifier class.
     32*/
    2833
    2934#include "PickupIdentifier.h"
  • code/trunk/src/orxonox/pickup/PickupIdentifier.h

    r6524 r6540  
    2626 *
    2727 */
     28
     29/**
     30    @file PickupIdentifier.h
     31    @brief Definition of the PickupIdentifier class.
     32*/
    2833
    2934#ifndef _PickupIdentifier_H__
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r6524 r6540  
    7171        this->aimPosition_ = Vector3::ZERO;
    7272
    73         //TODO: Remove.
    74         //this->getPickups().setOwner(this);
    75 
    7673        if (GameMode::isMaster())
    7774        {
     
    297294    }
    298295
    299 //TODO: Remove.
    300 //     void Pawn::dropItems()
    301 //     {
    302 //         this->getPickups().clear();
    303 //     }
    304 
    305 
    306296    /* WeaponSystem:
    307297    *   functions load Slot, Set, Pack from XML and make sure all parent-pointers are set.
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.h

    r6524 r6540  
    109109                { return this->numexplosionchunks_; }
    110110
    111 //TODO: Remove.
    112 //             virtual void dropItems();
    113 //             inline PickupCollection& getPickups()
    114 //                 { return this->pickups_; }
    115 //             virtual void useItem()
    116 //                 { this->pickups_.useItem(); }
    117 
    118111            virtual void startLocalHumanControl();
    119112
     
    122115            Vector3 getAimPosition()
    123116                { return this->aimPosition_; }
     117               
     118            virtual const Vector3& getCarrierPosition(void)
     119                { return this->getWorldPosition(); };
    124120
    125121        protected:
     
    136132            bool bAlive_;
    137133
    138             //TODO: Remove.
    139             //PickupCollection pickups_;
    140134            virtual std::list<PickupCarrier*>* getCarrierChildren(void)
    141135                { return new std::list<PickupCarrier*>(); }
    142136            virtual PickupCarrier* getCarrierParent(void)
    143137                { return NULL; }
    144             virtual const Vector3& getCarrierPosition(void)
    145                 { return this->getWorldPosition(); };
    146138
    147139            float health_;
Note: See TracChangeset for help on using the changeset viewer.