Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7494


Ignore:
Timestamp:
Sep 28, 2010, 5:31:59 PM (14 years ago)
Author:
dafrick
Message:

Some documenting and cleaning up/re-organization in pickups module.

Location:
code/trunk/src
Files:
1 added
18 edited

Legend:

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

    r7285 r7494  
    3535
    3636#include "core/CoreIncludes.h"
     37
    3738#include "PickupCollection.h"
    3839
  • code/trunk/src/modules/pickup/CollectiblePickup.h

    r7493 r7494  
    4646        The CollectiblePickup class encompasses all @ref orxonox::Pickupable "Pickupables" that can be added to a @ref orxonox::PickupCollection "PickupCollection" and thus be part of such.
    4747
    48         All you need to do to make your @ref orxonox:.Pickupable "Pickupable" a CollectiblePickup is to, in some way, inherit from it. (The @ref orxonox::Pickup Pickup class, for example, is already a CollectiblePickup).
     48        All you need to do to make your @ref orxonox::Pickupable "Pickupable" a CollectiblePickup is to, in some way, inherit from it. (The @ref orxonox::Pickup "Pickup" class, for example, is already a CollectiblePickup).
    4949
    5050    @author
     
    6363            /**
    6464            @brief Check whether the given CollectiblePickup is par of a PickupCollection.
    65             @return Returns true if the ColelctiblePickup is part of a PickupCollection.
     65            @return Returns true if the CollectiblePickup is part of a PickupCollection.
    6666            */
    6767            bool isInCollection(void)
    6868                { return this->isInCollection_; }
    69            
     69
    7070            bool addToCollection(PickupCollection* collection); //!< Adds this CollectiblePickup to the input PickupCollection.
    7171            bool removeFromCollection(void); //!< Removes this CollectiblePickup from its PickupCollection.
     
    7575        protected:
    7676            virtual void preDestroy(void); //!< Is called by OrxonoxClass::destroy() before the object is actually destroyed.
    77             virtual void destroyPickup(void); //!< //!< Destroys a Pickupable.
     77            virtual void destroyPickup(void); //!< Destroys a Pickupable.
    7878
    7979        private:
  • code/trunk/src/modules/pickup/DroppedPickup.cc

    r7493 r7494  
    3535
    3636#include "core/CoreIncludes.h"
     37
    3738#include "interfaces/Pickupable.h"
    3839#include "interfaces/PickupCarrier.h"
    39 #include "graphics/Model.h"
    4040
    4141namespace orxonox
  • code/trunk/src/modules/pickup/Pickup.cc

    r7401 r7494  
    3636#include "core/CoreIncludes.h"
    3737#include "util/StringUtils.h"
     38
    3839#include "pickup/PickupIdentifier.h"
     40
    3941#include "DroppedPickup.h"
    40 
    41 #include "tools/Timer.h"
    4242
    4343namespace orxonox
     
    5151    CreateUnloadableFactory(Pickup);
    5252
     53    /**
     54    @brief
     55        Constructor. Registers and initializes the object.
     56    @param creator
     57        The objects creator.
     58    */
    5359    Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
    5460    {
     
    5864    }
    5965
     66    /**
     67    @brief
     68        Destructor.
     69    */
    6070    Pickup::~Pickup()
    6171    {
     
    158168        else
    159169        {
    160             COUT(1) << "Invalid activationType in pickup." << std::endl;
     170            COUT(1) << "Invalid activationType '" << type << "' in pickup." << std::endl;
    161171        }
    162172    }
     
    180190        else
    181191        {
    182             COUT(1) << "Invalid durationType in pickup." << std::endl;
     192            COUT(1) << "Invalid durationType '" << type << "' in pickup." << std::endl;
    183193        }
    184194    }
     
    193203        SUPER(Pickup, changedPickedUp);
    194204
    195         //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
     205        // Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
    196206        if(this->isPickedUp() && this->isImmediate())
    197         {
    198207            this->setUsed(true);
    199         }
    200     }
    201 
    202     /**
    203     @brief
    204         Creates a duplicate of the Pickup.
    205     @return
    206         Returns the clone of this pickup as a pointer to a Pickupable.
     208    }
     209
     210    /**
     211    @brief
     212        Creates a duplicate of the OrxonoxClass.
     213    @param item
     214        A reference to the pointer of the item that we're duplicating.
    207215    */
    208216    void Pickup::clone(OrxonoxClass*& item)
  • code/trunk/src/modules/pickup/Pickup.h

    r7456 r7494  
    4848{
    4949
    50     //! Enum for the activation type.
     50    //! Enum for the @ref orxonox::Pickup "Pickup" activation type.
    5151    namespace pickupActivationType
    5252    {
    5353        enum Value
    5454        {
    55             immediate,
    56             onUse,
     55            immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup.
     56            onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence.
    5757        };
    5858    }
    5959
    60     //! Enum for the duration tyoe.
     60    //! Enum for the @ref orxonox::Pickup "Pickup" duration type.
    6161    namespace pickupDurationType
    6262    {
    6363        enum Value
    6464        {
    65             once,
    66             continuous,
     65            once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant.
     66            continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan.
    6767        };
    6868    }
     
    7070    /**
    7171    @brief
    72         Pickup class. Offers base functionality for a wide range of pickups.
    73         Pickups ingeriting from this class cann choose an activation type and a duration type.
     72        The Pickup class offers (useful) base functionality for a wide range of pickups.
     73
     74        Pickups ingeriting from this class can choose an activation type and a duration type.
     75        - The <b>activation type</b> deals with what happens to the Pickup as soon as it is picked up. It can either be set to <em>immediate</em>, which means that the Pickup is activated/used immediately upon being picked up. Or to <em>onUse</em>, which means, that the Pickup will be activated/used if some outside entity (most commonly the player through the PickupInventory) decides to use it.
     76        - The <b>duration type</b> deals with whether the Pickup has a continuous effect or whether its effect is focused on a singular instant. It can either be set to <em>once</em>, which means, that the Pickup just has an effect (at a singular instant in time) and is done once that effect has been applied. Or to <em>continuous</em>, which means that the effect of the Pickup unfolds over some timespan.
     77
     78        If it were not an abstract class it could for example be used as follows in XML.
     79        @code
     80        <Pickup activationType="onUse" durationType="continuous" />
     81        @endcode
     82        In reality you can (naturally) use the parameters <b>activation type</b> and <b>duration type</b> in any pickup inheriting from Pickup, unless the pickup already specifies one (or both) of the parameters.
     83
    7484    @author
    7585        Damian 'Mozork' Frick
     
    8595
    8696            /**
    87             @brief Get the activation type of the pickup.
    88             @return Returns the activation type of the pickup.
     97            @brief Get the activation type of the Pickup.
     98            @return Returns the activation type of the Pickup.
    8999            */
    90100            inline pickupActivationType::Value getActivationTypeDirect(void)
    91101                { return this->activationType_; }
    92102            /**
    93             @brief Get the duration type of the pickup.
    94             @return Returns the duration type of the pickup.
     103            @brief Get the duration type of the Pickup.
     104            @return Returns the duration type of the Pickup.
    95105            */
    96106            inline pickupDurationType::Value getDurationTypeDirect(void)
    97107                { return this->durationType_; }
    98108
    99             const std::string& getActivationType(void); //!< Get the activation type of the pickup.
    100             const std::string& getDurationType(void); //!< Get the duration type of the pickup.
     109            const std::string& getActivationType(void); //!< Get the activation type of the Pickup.
     110            const std::string& getDurationType(void); //!< Get the duration type of the Pickup.
    101111
    102112            /**
     
    127137            virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
    128138
    129             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
     139            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the OrxonoxClass.
    130140
    131141        protected:
     
    135145
    136146            /**
    137             @brief Set the activation type of the pickup.
    138             @param type The activation type of the pickup.
     147            @brief Set the activation type of the Pickup.
     148            @param type The activation type of the Pickup.
    139149            */
    140150            inline void setActivationTypeDirect(pickupActivationType::Value type)
    141151                { this->activationType_ = type; }
    142152            /**
    143             @brief Set the duration type of the pickup.
    144             @param type The duration type of the pickup.
     153            @brief Set the duration type of the Pickup.
     154            @param type The duration type of the Pickup.
    145155            */
    146156            inline void setDurationTypeDirect(pickupDurationType::Value type)
    147157                { this->durationType_ = type; }
    148158
    149             void setActivationType(const std::string& type); //!< Set the activation type of the pickup.
    150             void setDurationType(const std::string& type); //!< Set the duration type of the pickup
     159            void setActivationType(const std::string& type); //!< Set the activation type of the Pickup.
     160            void setDurationType(const std::string& type); //!< Set the duration type of the Pickup.
    151161
    152162        private:
     
    154164
    155165            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
    156             pickupDurationType::Value durationType_; //!< The duration type of the pickup.
     166            pickupDurationType::Value durationType_; //!< The duration type of the Pickup.
    157167
    158168            //! Strings for the activation and duration types.
  • code/trunk/src/modules/pickup/PickupCollection.cc

    r7401 r7494  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
     36
    3637#include "interfaces/PickupCarrier.h"
     38
    3739#include "CollectiblePickup.h"
    3840#include "DroppedPickup.h"
     
    4951    @brief
    5052        Default Constructor.
     53    @param creator
     54        The creator of the object.
    5155    */
    5256    PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator)
     
    201205    /**
    202206    @brief
    203         Creates a duplicate of the input OrxonoxClass.
     207        Creates a duplicate of the input Pickupable.
    204208        This method needs to be implemented by any Class inheriting from Pickupable.
    205209    @param item
  • code/trunk/src/modules/pickup/PickupCollection.h

    r7456 r7494  
    4848    /**
    4949    @brief
    50         The PickupCollection combines different Pickupables to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one Pickupable.
     50        The PickupCollection combines different @ref orxonox::Pickupable "Pickupables" (more precisely @ref orxonox::CollectiblePickup "CollectiblePickups") to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one @ref orxonox::Pickupable "Pickupable".
     51
     52        To differentiate between different types of @ref orxonox::PickupCollection "PickupCollections" (just as we differentiate between different types of @ref orxonox::Pickupable "Pickupables") we define a new identifyer called the @ref orxonox::PickupCollectionIdentifier "PickupCollectionIdentifier" which has pretty much the same properties as the @ref orxonox::PickupIdentifier "PickupIdentifier" but extende to @ref orxonox::PickupCollection "PickupCollections".
     53
     54        A PickupCollection can be created in XML as follows:
     55        @code
     56        <PickupCollection>
     57            <pickupables>
     58                <CollectiblePickup ... />
     59                ...
     60                <CollectiblePickup ... />
     61            </pickupables>
     62        </PickupCollection>
     63        @endcode
     64
    5165    @author
    5266        Damian 'Mozork' Frick
     
    6579            virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around.
    6680
    67             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
     81            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input pickup.
    6882
    6983            virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
     
    88102            void changedUsedAction(void); //!< Helper method.
    89103            void changedPickedUpAction(void); //!< Helper method.
    90            
     104
    91105            std::vector<CollectiblePickup*> pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid.
    92106
  • code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc

    r7401 r7494  
    6767    int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const
    6868    {
     69        assert(identifier);
     70
    6971        // Slight un-niceity to cast the PickupIdentifier to a PickupCollectionIdentifier.
    7072        PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier);
    71         const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp);
     73        const PickupCollectionIdentifier* collectionIdentifier = orxonox_cast<PickupCollectionIdentifier*>(temp);
    7274
    7375        // If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared.
     
    9294        }
    9395
    94         //! Means they are equal.
     96        // Means they are equal.
    9597        return 0;
    9698    }
  • code/trunk/src/modules/pickup/PickupCollectionIdentifier.h

    r7456 r7494  
    3838#include "PickupPrereqs.h"
    3939
     40#include <set>
     41
    4042#include "pickup/PickupIdentifier.h"
    41 
    42 #include <set>
    4343
    4444namespace orxonox
     
    4747    /**
    4848    @brief
    49         The PickupCollectionIdentifier is the specialization of the PickupIdentifier for the PickupCollection class.
    50         It identifies PickupCollections based on the different Pickupables they consist of.
    51         Pickupables can be added to the PickupCollectionIdentifier via the addPickup method.
     49        The PickupCollectionIdentifier is the specialization of the PickupIdentifier for the @ref orxonox::PickupCollection "PickupCollection" class.
     50        It identifies @ref orxonox::PickupCollection "PickupCollections" based on the different @ref orxonox::CollectiblePickup "CollectiblePickups" they consist of.
     51
     52        @ref orxonox::Pickupable "Pickupables" (resp. @ref orxonox::CollectiblePickup "CollectiblePickups") can be added to the PickupCollectionIdentifier via the addPickup method.
    5253    @author
    5354        Damian 'Mozork' Frick
     
    6263            virtual int compare(const PickupIdentifier* identifier) const; //!< Compares a PickupCollectionIdentifier with a PickupIdentifier.
    6364
    64             void addPickup(const PickupIdentifier* identifier); //!< Add a Pickupable to the PickupCollectionIdentifier.
     65            void addPickup(const PickupIdentifier* identifier); //!< Add a @ref orxonox::Pickupable "Pickupable" to the PickupCollectionIdentifier.
    6566
    6667        private:
    67             std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; //!< The set of PickupIdentifiers of the Pickupables the PickupCollection with this PickupCollectionIdentifier consists of, ordered by the rule set by PickupIdentifierCompare.
     68            std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; //!< The set of PickupIdentifiers of the @ref orxonox::Pickupable "Pickupables", the @ref orxonox::PickupCollection "PickupCollection" with this PickupCollectionIdentifier consists of, ordered by the rule set by @ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare".
    6869
    6970    };
  • code/trunk/src/modules/pickup/PickupManager.cc

    r7284 r7494  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Damian 'Mozork' Frick
    2424 *   Co-authors:
    2525 *      ...
     
    100100    bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    101101    {
    102         if(identifier == NULL || representation == NULL || this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a Representation registered.
     102        assert(identifier);
     103        assert(representation);
     104
     105        if(this->representations_.find(identifier) != this->representations_.end()) // If the Pickupable already has a Representation registered.
    103106            return false;
    104107
    105108        this->representations_[identifier] = representation;
    106109
    107         COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl;
     110        COUT(4) << "PickupRepresentation &" << representation << " registered with the PickupManager." << std::endl;
    108111        return true;
    109112    }
     
    121124    bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    122125    {
    123         if(identifier == NULL || representation == NULL)
    124             return false;
     126        assert(identifier);
     127        assert(representation);
    125128
    126129        std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
     
    130133        this->representations_.erase(it);
    131134
    132         COUT(4) << "PickupRepresentation " << representation << " unregistered with the PickupManager." << std::endl;
     135        COUT(4) << "PickupRepresentation &" << representation << " unregistered with the PickupManager." << std::endl;
    133136        return true;
    134137    }
     
    167170        if(pickup != NULL)
    168171            return this->getRepresentation(pickup->getPickupIdentifier());
    169        
     172
    170173        return NULL;
    171174    }
     
    268271        if(pickup == NULL)
    269272            return;
    270        
     273
    271274        std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); // Get the WeakPointer of the Pickupable.
    272275        // If either the input Pickupable is not in the PickupManagers list or it no longer exists, the method returns.
  • code/trunk/src/modules/pickup/PickupSpawner.h

    r7456 r7494  
    5151            The PickupSpawner class is responsible for spawning pickups of a specific type.
    5252            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.
     53
    5354        @author
    5455            Daniel 'Huty' Haggenmueller
     56        @author
    5557            Damian 'Mozork' Frick
    5658    */
  • code/trunk/src/orxonox/interfaces/CMakeLists.txt

    r6524 r7494  
    22  InterfaceCompilation.cc
    33  Pickupable.cc
     4  PickupCarrier.cc
    45  RadarViewable.cc
    56)
  • code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc

    r7163 r7494  
    3434
    3535#include "GametypeMessageListener.h"
    36 #include "PickupCarrier.h"
    3736#include "PlayerTrigger.h"
    3837#include "RadarListener.h"
     
    5150    {
    5251        RegisterRootObject(GametypeMessageListener);
    53     }
    54 
    55     //----------------------------
    56     // PickupCarrier
    57     //----------------------------
    58     PickupCarrier::PickupCarrier()
    59     {
    60         RegisterRootObject(PickupCarrier);
    61     }
    62 
    63     PickupCarrier::~PickupCarrier()
    64     {
    65 
    66     }
    67 
    68     void PickupCarrier::preDestroy(void)
    69     {
    70         std::set<Pickupable*>::iterator it = this->pickups_.begin();
    71         std::set<Pickupable*>::iterator temp;
    72         while(it != this->pickups_.end())
    73         {
    74             (*it)->carrierDestroyed();
    75             temp = it;
    76             it = this->pickups_.begin();
    77             if(it == temp) // Infinite loop avoidance, in case the pickup wasn't removed from the carrier somewhere in the carrierDestroy() procedure.
    78             {
    79                 COUT(2) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << (*temp) << ") didn't unregister itself as it should have." << std::endl;;
    80                 it++;
    81             }
    82         }
    83 
    84         this->pickups_.clear();
    8552    }
    8653
  • code/trunk/src/orxonox/interfaces/PickupCarrier.h

    r7456 r7494  
    3838#include "OrxonoxPrereqs.h"
    3939
    40 #include <list>
    4140#include <set>
    42 #include "Pickupable.h"
    43 #include "core/Identifier.h"
    44 #include "core/WeakPtr.h"
     41#include <vector>
    4542
    4643#include "core/OrxonoxClass.h"
     
    4946{
    5047
    51     //! Forward-declarations.
     48    // Forward-declarations.
    5249    class PickupManager;
    5350    class Pickup;
     
    6057    /**
    6158    @brief
    62         The PickupCarrier interface provides the means, for any class implementing it, to possess Pickupables.
     59        The PickupCarrier interface provides the means, for any class implementing it, to possess @ref orxonox::Pickupable "Pickupables".
     60
     61        For a class to use the PickupCarrier interface it must implement the follwing three methods:
     62        - <b>getCarrierPosition()</b> The getCarrierPosition() method returns the absolute position (in space) of the PickupCarrier.
     63
     64        Different PickupCarriers are structured hierarchically, a pickup can be picked up by a PickupCarrier that can't really carry that particular pickup but one of its children (or one of their children) can, and thus it gets "handed down" until it is at the right place.
     65        But this structure has to be established first.
     66        - <b>getCarrierChildren()</b> To this end a PickupCarrier needs to implement getCarrierChildren() which returns a list of its direct PickupCarrier children. If you need an example, have a look at @ref orxonox::Pawn "Pawn" and @ref orxonx::Engine "Engine".
     67        - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or NULL if the PickupCarrier is a root node in this hierarchy.
     68
    6369    @author
    6470        Damian 'Mozork' Frick
     
    6672    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
    6773    {
    68         //! So that the different Pickupables have full access to their PickupCarrier.
     74        // So that the different Pickupables have full access to their PickupCarrier.
    6975        friend class Pickupable;
    7076        friend class PickupManager;
    71         //! Friends.
     77        // Friends.
    7278        friend class Pickup;
    7379        friend class HealthPickup;
     
    8086            PickupCarrier(); //!< Constructor.
    8187            virtual ~PickupCarrier(); //!< Destructor.
    82             void preDestroy(void);
     88            void preDestroy(void); //!< Is called before the PickupCarrier is effectively destroyed.
    8389
    84             /**
    85             @brief Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
    86             @param pickup A pointer to the Pickupable.
    87             @return Returns true if the PickupCarrier or one of its children is a target, false if not.
    88             */
    89             bool isTarget(const Pickupable* pickup)
    90                 {
    91                     if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
    92                         return true;
    93 
    94                     //! Go recursively through all children to check whether they are a target.
    95                     std::vector<PickupCarrier*>* children = this->getCarrierChildren();
    96                     for(std::vector<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
    97                     {
    98                         if((*it)->isTarget(pickup))
    99                             return true;
    100                     }
    101 
    102                     children->clear();
    103                     delete children;
    104 
    105                     return false;
    106                 }
    107 
    108             /**
    109             @brief Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable.
    110             @param pickup A pounter to the Pickupable.
    111             @return Returns a pointer to the PickupCarrier that is the target of the input Pickupable.
    112             */
    113             PickupCarrier* getTarget(const Pickupable* pickup)
    114                 {
    115                     if(!this->isTarget(pickup))
    116                         return NULL;
    117 
    118                     if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
    119                         return this;
    120 
    121                     //! Go recursively through all children to check whether they are the target.
    122                     std::vector<PickupCarrier*>* children = this->getCarrierChildren();
    123                     for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
    124                     {
    125                         if(pickup->isTarget(*it))
    126                             return *it;
    127                     }
    128 
    129                     children->clear();
    130                     delete children;
    131 
    132                     return NULL;
    133                 }
     90            bool isTarget(const Pickupable* pickup); //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
     91            PickupCarrier* getTarget(const Pickupable* pickup); //!< Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable.
    13492
    13593            /**
     
    149107            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) = 0;
    150108            /**
    151             @brief Get the parent of this PickupSpawner
     109            @brief Get the parent of this PickupSpawner.
    152110                   This method needs to be implemented by any direct derivative class of PickupCarrier.
    153111            @return Returns a pointer to the parent.
     
    165123            std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
    166124
    167             /**
    168             @brief Adds a Pickupable to the list of pickups that are carried by this PickupCarrier.
    169             @param pickup A pointer to the pickup to be added.
    170             @return Returns true if successfull, false if the Pickupable was already present.
    171             */
    172             bool addPickup(Pickupable* pickup)
    173                 {
    174                     COUT(4) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << std::endl;
    175                     return this->pickups_.insert(pickup).second;
    176                 }
    177 
    178             /**
    179             @brief Removes a Pickupable from the list of pickups that are carried by thsi PickupCarrier.
    180             @param pickup A pointer to the pickup to be removed.
    181             @return Returns true if successfull, false if the Pickupable was not present in the list.
    182             */
    183             bool removePickup(Pickupable* pickup)
    184                 {
    185                     COUT(4) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << std::endl;
    186                     return this->pickups_.erase(pickup) == 1;
    187                 }
     125            bool addPickup(Pickupable* pickup); //!< Adds a Pickupable to the list of pickups that are carried by this PickupCarrier.
     126            bool removePickup(Pickupable* pickup); //!< Removes a Pickupable from the list of pickups that are carried by this PickupCarrier.
    188127
    189128    };
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    r7493 r7494  
    3939#include "core/CoreIncludes.h"
    4040#include "util/Convert.h"
     41
    4142#include "infos/PlayerInfo.h"
    4243#include "pickup/PickupIdentifier.h"
    4344#include "worldentities/pawns/Pawn.h"
     45
    4446#include "PickupCarrier.h"
    4547
     
    130132        this->changedUsed();
    131133
     134        //TODO: Synchronize & make safe for dedicated server.
    132135        GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
    133136        return true;
     
    277280            this->getCarrier()->removePickup(this);
    278281        this->changedPickedUp();
     282
     283        //TODO: Synchronize & make safe for dedicated server.
    279284        GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()");
    280285        return true;
     
    303308                return false;
    304309        }
    305        
     310
    306311        this->carrier_ = carrier;
    307312        this->changedCarrier();
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r7456 r7494  
    5050    @brief
    5151        An Interface (or more precisely an abstract class) to model and represent different (all kinds of) pickups.
     52
     53        Pickups (@ref orxonox:Pickupable "Pickupables") are objects that (quite unsurprisingly) can be picked up. Additionally they can be used and unused (transition from used to not used), and also dropped.
     54
     55        A class of Pickups can incorporate many different types of pickups (see @ref orxonox::PickupIdentifier "PickupIdentifier"), each type is uniquely defined by a @ref orxonox::PickupIdentifier "PickupIdentifier". Each pickup has such an identifier identiying its type. This means that two pickups of the same type have identifiers which are equal.
     56
    5257    @author
    5358        Damian 'Mozork' Frick
     
    6368
    6469            /**
    65             @brief Get whether the pickup is currently in use or not.
    66             @return Returns true if the pickup is currently in use.
     70            @brief Get whether the Pickupable is currently in use or not.
     71            @return Returns true if the Pickupable is currently in use.
    6772            */
    6873            inline bool isUsed(void) { return this->used_; }  // tolua_export
    6974            /**
    70             @brief  Should be called when the pickup has transited from used to unused or the other way around.
     75            @brief  Should be called when the Pickupable has transited from used to unused or the other way around.
    7176                    Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method.
    7277            */
     
    7479
    7580            /**
    76             @brief Get the carrier of the pickup.
    77             @return Returns a pointer to the carrier of the pickup.
     81            @brief Get the carrier of the Pickupable.
     82            @return Returns a pointer to the carrier of the Pickupable.
    7883            */
    7984            inline PickupCarrier* getCarrier(void)
    8085                { return this->carrier_; }
    8186            /**
    82             @brief Should be called when the pickup has changed its PickupCarrier.
     87            @brief Should be called when the Pickupable has changed its PickupCarrier.
    8388                   Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method.
    8489            */
     
    9196            inline bool isPickedUp(void) { return this->pickedUp_; }  // tolua_export
    9297            /**
    93             @brief  Should be called when the pickup has transited from picked up to dropped or the other way around.
     98            @brief  Should be called when the Pickupable has transited from picked up to dropped or the other way around.
    9499                    Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method.
    95100            */
     
    119124            bool drop(bool createSpawner = true); //!< Can be called to drop a Pickupable.
    120125
    121             virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup.
     126            virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this Pickupable.
    122127            bool isTarget(const Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this Pickupable.
    123             bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup.
    124             bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup.
     128            bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this Pickupable.
     129            bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this Pickupable.
    125130
    126131            Pickupable* clone(void); //!< Creates a duplicate of the Pickupable.
     
    137142            bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up.
    138143            //TODO: private?
    139             bool setCarrier(PickupCarrier* carrier, bool tell = true); //!< Sets the carrier of the pickup.
     144            bool setCarrier(PickupCarrier* carrier, bool tell = true); //!< Sets the carrier of the Pickupable.
    140145
    141146            //TODO: private?
    142147            virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed.
    143148
    144             void destroy(void); //!< Is called internally within the pickup module to destroy pickups.
     149            void destroy(void); //!< Is called internally within the Pickupable module to destroy pickups.
    145150
    146151        protected:
     
    187192    };  // tolua_export
    188193
     194    //! SUPER functions.
    189195    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
    190196    SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
  • code/trunk/src/orxonox/pickup/PickupIdentifier.cc

    r7163 r7494  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/Identifier.h"
     38
    3739#include "interfaces/Pickupable.h"
    3840
     
    6971    int PickupIdentifier::compare(const PickupIdentifier* identifier) const
    7072    {
    71         if(identifier == NULL)
    72         {
    73             return 1;
    74             COUT(1) << "Error in PickupIdentifier::compare: Input Identifier is NULL." << std::endl;
    75         }
     73        assert(identifier);
     74        assert(identifier->pickup_);
     75        assert(this->pickup_);
    7676
    77         if(identifier->pickup_ == NULL && this->pickup_ == NULL)
    78         {
    79             return 0;
    80             COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
    81         }
    82 
    83         if(identifier->pickup_ == NULL)
    84         {
    85             return 1;
    86             COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
    87         }
    88 
    89         if(this->pickup_ == NULL)
    90         {
    91             return -1;
    92             COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
    93         }
    94 
    95         //! If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
     77        // If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
    9678        if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
    9779            return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
    9880
    99         //! If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
    100         //! If the two have a different number of parameters then obviusly something is very wrong.
     81        // If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
     82        // If the two have a different number of parameters then obviously something is very wrong.
    10183        if(!(this->parameters_.size() == identifier->parameters_.size()))
    10284        {
     
    10587        }
    10688
    107         //! We iterate through all parameters and compare their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.
     89        // We iterate through all parameters and compare their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.
    10890        for(std::map<std::string, std::string>::const_iterator it = this->parameters_.begin(); it != this->parameters_.end(); it++)
    10991        {
    110             //!< If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
     92            // If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
    11193            if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
    11294            {
  • code/trunk/src/orxonox/pickup/PickupIdentifier.h

    r7456 r7494  
    4040#include <map>
    4141#include <string>
    42 #include "core/Identifier.h"
    4342
    4443#include "core/OrxonoxClass.h"
     
    4948    /**
    5049    @brief
    51         The purpose of the PickupIdentifier class is to identify different types of pickups allthough they are of the same class.
    52         This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes. An example is the HealthPickup class that encompasses a wide variety of different types of health pickups, e.g a HealthPickup that adds 10 health every second for 10 seconds or a HealthPickup that adds 100 health as soon as it is picked up, a.s.o.
    53         To that purpose this class provides functionality to compare two PickupIdentifier (and since all Pickupables have an Identifier through that Pickupables can be compared). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class.
    54         Lastly a struct is provided that can be used in stl containers to establish a strictly lesser ordering between PickupIdentifiers (and thus Pickupables).
     50        The purpose of the PickupIdentifier class is to identify (or differentiate between) different types of pickups although they are of the same class.
     51
     52        This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes.
     53
     54        An example is the @ref orxonox::HealthPickup "HealthPickup" class that encompasses a wide variety of different types of health pickups, e.g a @ref orxonox::HealthPickup "HealthPickup" that adds 10 health every second for 10 seconds or a @ref orxonox::HealthPickup "HealthPickup" that adds 100 health as soon as it is picked up, a.s.o.
     55
     56        To that purpose this class provides functionality to compare two @ref orxonox::PickupIdentifier "PickupIdentifiers" (and since all @ref orxonox::Pickupable "Pickupables" have an identifier, we can use it to compare pickups). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class.
     57
     58        Lastly a struct (@ref orxonox::PickupIdentifierCompare "PickupIdentifierCompare") is provided that can be used in stl containers to establish a strictly lesser ordering between @ref orxonox::PickupIdentifier "PickupIdentifiers" (and thus @ref orxonox::Pickupable "Pickupables").
    5559    @author
    5660        Damian 'Mozork' Frick
     
    7579    /**
    7680    @brief
    77         Struct that overloads the compare operation between two PickupIdentifier pointers.
     81        Struct that overloads the compare operation between two @ref orxonox::PickupIdentifier "PickupIdentifier" pointers.
    7882    */
    7983    struct PickupIdentifierCompare
Note: See TracChangeset for help on using the changeset viewer.