Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 16, 2010, 12:37:09 PM (14 years ago)
Author:
dafrick
Message:

Documenting and cleanup.

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

Legend:

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

    r7533 r7547  
    6767            @return Returns true if the CollectiblePickup is part of a PickupCollection.
    6868            */
    69             bool isInCollection(void)
     69            bool isInCollection(void) const
    7070                { return this->isInCollection_; }
    7171
  • code/trunk/src/modules/pickup/Pickup.cc

    r7533 r7547  
    119119        Returns a string containing the activation type.
    120120    */
    121     const std::string& Pickup::getActivationType(void)
     121    const std::string& Pickup::getActivationType(void) const
    122122    {
    123123        switch(this->activationType_)
     
    138138        Returns a string containing the duration type.
    139139    */
    140     const std::string& Pickup::getDurationType(void)
     140    const std::string& Pickup::getDurationType(void) const
    141141    {
    142142        switch(this->durationType_)
  • code/trunk/src/modules/pickup/Pickup.h

    r7533 r7547  
    4040#include "core/BaseObject.h"
    4141#include "core/XMLPort.h"
     42#include "tools/Timer.h"
    4243
    4344#include "CollectiblePickup.h"
    44 
    45 #include "tools/Timer.h"
    4645
    4746namespace orxonox
     
    8382
    8483        Pickups ingeriting from this class can choose an activation type and a duration type.
    85         - 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.
    86         - 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.
     84        - The <b>activationType</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. Default is <em>immediate</em>.
     85        - The <b>durationType</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. Default is <em>once</em>.
    8786
    8887        If it were not an abstract class it could for example be used as follows in XML.
     
    110109            @return Returns the activation type of the Pickup.
    111110            */
    112             inline pickupActivationType::Value getActivationTypeDirect(void)
     111            inline pickupActivationType::Value getActivationTypeDirect(void) const
    113112                { return this->activationType_; }
    114113            /**
     
    116115            @return Returns the duration type of the Pickup.
    117116            */
    118             inline pickupDurationType::Value getDurationTypeDirect(void)
     117            inline pickupDurationType::Value getDurationTypeDirect(void) const
    119118                { return this->durationType_; }
    120119
    121             const std::string& getActivationType(void); //!< Get the activation type of the Pickup.
    122             const std::string& getDurationType(void); //!< Get the duration type of the Pickup.
     120            const std::string& getActivationType(void) const; //!< Get the activation type of the Pickup.
     121            const std::string& getDurationType(void) const; //!< Get the duration type of the Pickup.
    123122
    124123            /**
     
    126125            @return Returns true if the activation type is 'immediate'.
    127126            */
    128             inline bool isImmediate(void)
     127            inline bool isImmediate(void) const
    129128                { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
    130129            /**
     
    132131            @return Returns true if the activation type is 'onUse'.
    133132            */
    134             inline bool isOnUse(void)
     133            inline bool isOnUse(void) const
    135134                { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
    136135            /**
     
    138137            @return Returns true if the duration type is 'once'.
    139138            */
    140             inline bool isOnce(void)
     139            inline bool isOnce(void) const
    141140                { return this->getDurationTypeDirect() == pickupDurationType::once; }
    142141            /**
     
    144143            @return Returns true if the duration type is 'continuous'.
    145144            */
    146             inline bool isContinuous(void)
     145            inline bool isContinuous(void) const
    147146                { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
    148147
    149148            virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
    150 
    151149            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the OrxonoxClass.
    152150
  • code/trunk/src/modules/pickup/PickupCollection.cc

    r7533 r7547  
    235235        Returns true if the PickupCarrier identified by the input PickupIdentififer it is a target of this PickupCollection, false if not.
    236236    */
    237     bool PickupCollection::isTarget(PickupCarrier* carrier) const
     237    bool PickupCollection::isTarget(const PickupCarrier* carrier) const
    238238    {
    239239        for(std::vector<CollectiblePickup*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     
    253253        Returns a pointer to the PickupIdentifier of this PickupCollection.
    254254    */
    255     const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
     255    const PickupIdentifier* PickupCollection::getPickupIdentifier(void) const
    256256    {
    257257        return this->pickupCollectionIdentifier_;
     
    284284        Returns a pointer to the Pickupable at the index given by index.
    285285    */
    286     const Pickupable* PickupCollection::getPickupable(unsigned int index)
     286    const Pickupable* PickupCollection::getPickupable(unsigned int index) const
    287287    {
    288288        return this->pickups_[index];
  • code/trunk/src/modules/pickup/PickupCollection.h

    r7533 r7547  
    3838#include "PickupPrereqs.h"
    3939
     40#include <list>
     41
     42#include "CollectiblePickup.h"
    4043#include "core/BaseObject.h"
    41 #include "CollectiblePickup.h"
    42 
    43 #include <list>
    4444
    4545namespace orxonox
     
    8383            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input pickup.
    8484
    85             virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
     85            virtual bool isTarget(const PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
    8686
    87             virtual const PickupIdentifier* getPickupIdentifier(void); //!< Get the PickupIdentifier of this PickupCollection.
     87            virtual const PickupIdentifier* getPickupIdentifier(void) const; //!< Get the PickupIdentifier of this PickupCollection.
    8888
    8989            bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.
    90             const Pickupable* getPickupable(unsigned int index); //!< Get the Pickupable at the given index.
     90            const Pickupable* getPickupable(unsigned int index) const; //!< Get the Pickupable at the given index.
    9191
    9292            void pickupChangedUsed(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its used status to the input value.
  • code/trunk/src/modules/pickup/PickupManager.cc

    r7539 r7547  
    389389    @param pickup
    390390        A number identifying the Pickupable that changed its pickedUp status.
    391     @param unusable
    392         Whether the Pickupable's used status can be changed to unused in the PickupInventory.
     391    @param usable
     392        Whether the Pickupable's used status can be changed to used in the PickupInventory.
    393393    @param representationObjectId
    394394        The objectId identifying (over the network) the PickupRepresentation that represents this Pickupable.
  • code/trunk/src/modules/pickup/PickupManager.h

    r7540 r7547  
    3939
    4040#include <map>
    41 
    4241#include "core/WeakPtr.h"
    4342
     
    7574        The PickupManager class manages @ref orxonox::Pickupable "Pickupables".
    7675
    77         It has in essence two tasks to fulfill. Firstly it must link @ref orxonox::Pickupable "Pickupables" (through their @ref orxonox::PickupIdentifier "PickupIdentifiers") to their respective @ref orxonox:PickupRepresentation "PickupRepresentations". Secondly it manages the PickupInventory. (The PickupInventory is the GUI that displays @ref roxonox::Pickupable "Pickupables" for the covenience of the user.)
     76        It has in essence two tasks to fulfill. Firstly it must link @ref orxonox::Pickupable "Pickupables" (through their @ref orxonox::PickupIdentifier "PickupIdentifiers") to their respective @ref orxonox::PickupRepresentation "PickupRepresentations". Secondly it manages the PickupInventory. (The PickupInventory is the GUI that displays @ref orxonox::Pickupable "Pickupables" for the covenience of the user.)
    7877
    7978        @section PickupManagerTechnicalDetails Technical details
     
    8988        - The @ref orxonox::PickupManager::representations_ "representations_" list links @ref orxonox::PickupRepresentation "PickupRepresentations" with @ref orxonox::PickupIdentifier "PickupIdentifiers" and can be used to get the @ref orxonox::PickupRepresentation "PickupRepresentation" for a given @ref orxonox::Pickupable "Pickupable". It is only populated on the server (or in standalone mode). Each @ref orxonox::PickupRepresentation "PickupRepresentation" that is generated through XML registers itself with the PickupManager and is thereby added to the list.
    9089        - The @ref orxonox::PickupManager::representationsNetworked_ "representationsNetworked_" list is the networked (hence the name) equivalent to the @ref orxonox::PickupManager::representations_ "representations_" list. It links an objectId of a @ref orxonox::PickupRepresentation "PickupRepresentation" to a @ref orxonox::PickupRepresentation "PickupRepresentation". This list is maintained on all hosts, each representation registers itself (in its constructor) with the PickupManager. Since the representations are synchronised they are created on each host. The "same" instance on each host is identified by the same objectId and that is why we store the representations with the objectId as key. We can then use this list to get a @ref orxonox::PickupRepresentation "PickupRepresentation" for a specific @ref orxonox::Pickupable "Pickupable" (or more precisely a number identifiying that particular pickup, but we'll see that, when we look at the next list) on a client to be used in the PickupInventory.
    91         - The @ref orxonox::PickupManager::pickupInventoryContainers_ "pickupInventoryContainers_" list links a number identifying a @ref orxonox::Pickupable "Pickupable" to a data structure (the @ref orxonox::PickupInventoryContainer "PickupInventoryContainer"), which contains all necessary information about that @ref orxonox::Pickupable "Pickupable". This list is maintained on all hosts, a new container is inserted when a @ref orxonox::Pickupable "Pickupable" is picked up, but only if it has been picked up by the repsective host. This list is then used by the PickupInventory to access the required information and to get the correct @ref orxonox:.PickupRepresentation "PickupRepresentation".
     90        - The @ref orxonox::PickupManager::pickupInventoryContainers_ "pickupInventoryContainers_" list links a number identifying a @ref orxonox::Pickupable "Pickupable" to a data structure (the @ref orxonox::PickupInventoryContainer "PickupInventoryContainer"), which contains all necessary information about that @ref orxonox::Pickupable "Pickupable". This list is maintained on all hosts, a new container is inserted when a @ref orxonox::Pickupable "Pickupable" is picked up, but only if it has been picked up by the repsective host. This list is then used by the PickupInventory to access the required information and to get the correct @ref orxonox::PickupRepresentation "PickupRepresentation".
    9291        - The @ref orxonox::PickupManager::pickups_ "pickups_" list links a number identifiying a @ref orxonox::Pickupable "Pickupable" to a (weak pointer to a) @ref orxonox::Pickupable "Pickupable". It is only maintained by the server (or in standalone mode), to be able to use, unuse and drop @ref orxonox::Pickupable "Pickupables" through the PickupInventory. Since @ref orxonox::Pickupable "Pickupables" only exist on the server a client that wants to change a pickups status has so send a request over the network (with the number identifying the pickup) to the server and then the server facilitates the change, using this list to map from the identifyer to the actual @ref orxonox::Pickupable "Pickupable".
    9392        - The @ref orxonox::PickupManager::indexes_ "indexes_" list links a @ref orxonox::Pickupable "Pickupable" to the number identifying it. This is only maintained on the server (or in standalone mode), and is used for the inverse mapping of the previous list, which means the server uses it identify pickups on clients when it communicates changes in pickups to clients.
     
    139138            @return Returns the next PickupInventoryContainer in the list.
    140139            */
    141             orxonox::PickupInventoryContainer* popPickup(void)
     140            const orxonox::PickupInventoryContainer* popPickup(void)
    142141                { return (this->pickupsIterator_++)->second; }
    143142
     
    149148            @return Returns true if the input Pickupable is still valid, false if not.
    150149            */
    151             bool isValidPickup(uint32_t pickup)
     150            const bool isValidPickup(uint32_t pickup) const
    152151                { return this->pickups_.find(pickup) != this->pickups_.end(); }
    153152            // tolua_end
  • code/trunk/src/modules/pickup/PickupRepresentation.h

    r7540 r7547  
    3939
    4040#include "core/XMLPort.h"
     41
    4142#include "interfaces/Pickupable.h"
    4243#include "pickup/PickupIdentifier.h"
     
    5354    /**
    5455    @brief
    55         The PickupRepresentation class represents a specific pickup type (identified by its @ref orxonox::PickupIdentififer "PickupIdentifier"). It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like.
     56        The PickupRepresentation class represents a specific pickup type (identified by its @ref orxonox::PickupIdentifier "PickupIdentifier"). It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like.
    5657        They are created through XML and are registered with the @ref orxonox::PickupManager "PickupManager".
    5758
     
    7172        As you might have noticed, there is a parameter called <em>spawnerTemplate</em> and also another parameter called <em>inventoryRepresentation</em>. Let's first explain the second one, <em>inventoryRepresentation</em>.
    7273        - The <b>inventoryRepresentation</b> specifies the image that is displayed in the PickupInventory for the specific type of @ref orxonox::Pickupable "Pickupable". More technically, it is the name of an image located in the <code>PickupInventory.imageset</code>, which in turn is located in <code>data_extern/gui/imagesets/</code>.
    73         - The <b>spawnerTemplate</b> specifies how the type of @ref orxonox::Pickupable "Pickupable" (or more precisely the @ref orxonox::PickupSpawner "PickupSpawner", that spawns that type of @ref orxonox::Pickupable "Pickupable") is displayed ingame. It is a @ref orxnox::Template "Template" defined in XML. The <em>spawnerTemplate</em> can be specified as follows (keep in mind, that the template needs to have been specified before the definition of the PickupRepresentation that uses it).
     74        - The <b>spawnerTemplate</b> specifies how the type of @ref orxonox::Pickupable "Pickupable" (or more precisely the @ref orxonox::PickupSpawner "PickupSpawner", that spawns that type of @ref orxonox::Pickupable "Pickupable") is displayed ingame. It is a @ref orxonox::Template "Template" defined in XML. The <em>spawnerTemplate</em> can be specified as follows (keep in mind, that the template needs to have been specified before the definition of the PickupRepresentation that uses it).
    7475        @code
    7576        <Template name="awesomePickupRepresentation">
     
    105106
    106107            /**
     108            @brief Get the name of the Pickupable represented by this PickupRepresentation.
     109            @return Returns the name.
     110            */
     111            inline const std::string& getPickupName(void) const { return this->name_; } // tolua_export
     112            /**
     113            @brief Get the description of the Pickupable represented by this PickupRepresentation.
     114            @return Returns the description.
     115            */
     116            inline const std::string& getPickupDescription(void) const { return this->description_; } // tolua_export
     117            /**
     118            @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
     119            @return Returns the name of the spawnerTemplate.
     120            */
     121            inline const std::string& getSpawnerTemplate(void) const
     122                { return this->spawnerTemplate_; }
     123            /**
     124            @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
     125            @param index The index.
     126            @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.
     127            */
     128            inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) const
     129                { if(index == 0) return this->spawnerRepresentation_; return NULL; }
     130            /**
     131            @brief Get the name of the image representing the pickup in the PickupInventory.
     132            @return Returns the name of the image as a string.
     133            */
     134            inline const std::string& getInventoryRepresentation(void) const { return this->inventoryRepresentation_; } // tolua_export
     135            /**
     136            @brief Get the Pickupable represented by this PickupRepresentation.
     137            @param index The index.
     138            @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
     139            */
     140            inline const Pickupable* getPickup(unsigned int index) const
     141                { if(index == 0) return this->pickup_; return NULL; }
     142
     143            StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
     144
     145        protected:
     146            /**
    107147            @brief Set the name of the Pickupable represented by this PickupRepresentation.
    108148            @param name The name.
     
    142182            inline void setPickup(Pickupable* pickup)
    143183                { this->pickup_ = pickup; }
    144 
    145             /**
    146             @brief Get the name of the Pickupable represented by this PickupRepresentation.
    147             @return Returns the name.
    148             */
    149             inline const std::string& getPickupName(void) { return this->name_; } // tolua_export
    150             /**
    151             @brief Get the description of the Pickupable represented by this PickupRepresentation.
    152             @return Returns the description.
    153             */
    154             inline const std::string& getPickupDescription(void) { return this->description_; } // tolua_export
    155             /**
    156             @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
    157             @return Returns the name of the spawnerTemplate.
    158             */
    159             inline const std::string& getSpawnerTemplate(void)
    160                 { return this->spawnerTemplate_; }
    161             /**
    162             @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
    163             @param index The index.
    164             @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.
    165             */
    166             inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
    167                 { if(index == 0) return this->spawnerRepresentation_; return NULL; }
    168             /**
    169             @brief Get the name of the image representing the pickup in the PickupInventory.
    170             @return Returns the name of the image as a string.
    171             */
    172             inline const std::string& getInventoryRepresentation(void) { return this->inventoryRepresentation_; } // tolua_export
    173             /**
    174             @brief Get the Pickupable represented by this PickupRepresentation.
    175             @param index The index.
    176             @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
    177             */
    178             inline const Pickupable* getPickup(unsigned int index)
    179                 { if(index == 0) return this->pickup_; return NULL; }
    180 
    181             StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
    182184
    183185        private:
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r7540 r7547  
    3838#include "core/Template.h"
    3939#include "core/XMLPort.h"
     40
    4041#include "worldentities/pawns/Pawn.h"
     42
    4143#include "PickupManager.h"
    4244#include "PickupRepresentation.h"
     
    187189                PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
    188190                // If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
    189                 if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_))
     191                if (distance.length() < this->triggerDistance_ && carrier != NULL)
    190192                {
    191                     this->trigger(*it);
     193                    if(carrier->isTarget(this->pickup_))
     194                        this->trigger(*it);
    192195                }
    193196            }
     
    270273        Returns the Pickupable that is spawned by this PickupSpawner.
    271274    */
    272     const Pickupable* PickupSpawner::getPickupable(void)
     275    const Pickupable* PickupSpawner::getPickupable(void) const
    273276    {
    274277        return this->pickup_;
  • code/trunk/src/modules/pickup/PickupSpawner.h

    r7540 r7547  
    3939
    4040#include <string>
    41 
    4241#include "tools/Timer.h"
    4342
     
    9291                { return this->triggerDistance_; }
    9392            /**
    94             @brief Set the distance in which to trigger.
    95             @param value The new distance in which to trigger.
    96             */
    97             inline void setTriggerDistance(float value)
    98                 { this->triggerDistance_ = value; }
    99 
    100             /**
    10193            @brief Get the time to respawn.
    10294            @returns Returns the time after which this gets re-actived.
     
    10597                { return this->respawnTime_; }
    10698            /**
     99            @brief Get the maximum number of items that will be spawned by this PickupSpawner.
     100            @return Returns the maximum number of items spawned by this PickupSpawner.
     101            */
     102            inline int getMaxSpawnedItems(void) const
     103                { return this->maxSpawnedItems_; }
     104           
     105
     106        protected:
     107            void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
     108            void startRespawnTimer(void);
     109
     110            /**
     111            @brief Set the distance in which to trigger.
     112            @param value The new distance in which to trigger.
     113            */
     114            inline void setTriggerDistance(float value)
     115                { this->triggerDistance_ = value; }
     116            /**
    107117            @brief Set the time to respawn.
    108118            @param time New time after which this gets re-actived.
     
    110120            inline void setRespawnTime(float time)
    111121                { this->respawnTime_ = time; }
    112 
    113             /**
    114             @brief Get the maximum number of items that will be spawned by this PickupSpawner.
    115             @return Returns the maximum number of items spawned by this PickupSpawner.
    116             */
    117             inline int getMaxSpawnedItems(void)
    118                 { return this->maxSpawnedItems_; }
    119122            void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.
    120 
    121         protected:
    122             void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
    123 
    124             void startRespawnTimer(void);
    125123
    126124            virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
    127125
    128126            void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
    129             const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
     127            const Pickupable* getPickupable(void) const; //!< Get the Pickupable that is spawned by this PickupSpawner.
    130128
    131129            Pickupable* pickup_; //!< The pickup to be spawned.
  • code/trunk/src/modules/pickup/items/DronePickup.cc

    r7541 r7547  
    3535
    3636#include <sstream>
    37 
    3837#include "core/CoreIncludes.h"
    3938#include "core/XMLPort.h"
    40 #include "util/StringUtils.h"
    4139
    4240#include "controllers/DroneController.h"
    4341#include "pickup/PickupIdentifier.h"
     42#include "worldentities/Drone.h"
    4443#include "worldentities/pawns/Pawn.h"
    45 #include "worldentities/Drone.h"
    46 #include "worldentities/StaticEntity.h"
    4744
    4845namespace orxonox
  • code/trunk/src/modules/pickup/items/DronePickup.h

    r7541 r7547  
    4848    @brief
    4949        The DronePickup adds a Drone to the Pawn upon being picked up.
     50
    5051        It can be used in XML as follows:
    5152        @code
     
    7172            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    7273
    73             void setDroneTemplate(std::string templatename); //!< Set the droneTemplate.
    7474            const std::string& getDroneTemplate() const; //!< Get the name of the droneTemplate.
    7575
    7676        protected:
    7777            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
     78
     79            void setDroneTemplate(std::string templatename); //!< Set the droneTemplate.
    7880
    7981        private:
  • code/trunk/src/modules/pickup/items/HealthPickup.cc

    r7541 r7547  
    3434#include "HealthPickup.h"
    3535
     36#include <sstream>
    3637#include "core/CoreIncludes.h"
    3738#include "core/XMLPort.h"
    38 #include "util/StringUtils.h"
    39 
     39
     40#include "pickup/PickupIdentifier.h"
    4041#include "worldentities/pawns/Pawn.h"
    41 #include "pickup/PickupIdentifier.h"
    42 
    43 #include <sstream>
    4442
    4543namespace orxonox
     
    307305        Returns the health type as a string.
    308306    */
    309     const std::string& HealthPickup::getHealthType(void)
     307    const std::string& HealthPickup::getHealthType(void) const
    310308    {
    311309        switch(this->getHealthTypeDirect())
  • code/trunk/src/modules/pickup/items/HealthPickup.h

    r7541 r7547  
    3939
    4040#include <string>
    41 #include <worldentities/pawns/Pawn.h>
    42 #include "worldentities/StaticEntity.h"
    4341
    4442#include "pickup/Pickup.h"
     
    6563    /**
    6664    @brief
    67         The Health Pickup is a Pickupable that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
    68         There are 4 parameters that can be chosen:
    69         - The <b>health</b> The amount of health that (in a way dependent on the other parameters) is transferred to the Pawn.
    70         - The <b>activation type</b> It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the health is transferred, either immediately after being picked up or only after the player uses it.
    71         - The <b>duration type</b> It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the specified health is transferred once to the Pawn, for <em>continuous</em> the set health is transferred over a span of time at a rate defined by the health rate parameter.
    72         - The <b>health type</b> The health type can be chosen to be <em>limited</em>, <em>temporary</em> or <em>permanent</em>. <em>limited</em> means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. <em>permanent</em> means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
     65        The HealthPickup is a Pickupable that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
     66        There are 5 parameters that can be chosen:
     67        - The @b activationType It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the health is transferred, either immediately after being picked up or only after the player uses it. The default is <em>immediate</em>.
     68        - The @b durationType It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the specified health is transferred once to the Pawn, for <em>continuous</em> the set health is transferred over a span of time at a rate defined by the health rate parameter. The default is <em>once</em>.
     69        - The @b health The amount of health that (in a way dependent on the other parameters) is transferred to the Pawn. Default is 0.
     70        - The @b healthType The health type can be chosen to be <em>limited</em>, <em>temporary</em> or <em>permanent</em>. <em>limited</em> means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. <em>permanent</em> means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way. The default is <em>limited</em>.
     71        - The @b healthRate If set to continuous, the health that is transferred per second is the <em>healthRate</em>. There is health transferred until the health set by <em>health</em> is depleted. The default is 0.
    7372
    74         An examle of a XML implementation of a HealthPickup would be:
     73        An example of a XML implementation of a HealthPickup would be:
    7574        @code
    7675        <HealthPickup
     
    104103            @return Returns the health.
    105104            */
    106             inline float getHealth(void)
     105            inline float getHealth(void) const
    107106                { return this->health_; }
    108107            /**
     
    110109            @return Returns the rate.
    111110            */
    112             inline float getHealthRate(void)
     111            inline float getHealthRate(void) const
    113112                { return this->healthRate_; }
    114113
     
    117116            @return Returns the health type as an enum.
    118117            */
    119             inline pickupHealthType::Value getHealthTypeDirect(void)
     118            inline pickupHealthType::Value getHealthTypeDirect(void) const
    120119                { return this->healthType_; }
    121             const std::string& getHealthType(void); //!< Get the health type of this pickup.
     120            const std::string& getHealthType(void) const; //!< Get the health type of this pickup.
    122121
    123122        protected:
  • code/trunk/src/modules/pickup/items/InvisiblePickup.cc

    r7546 r7547  
    3535
    3636#include <sstream>
    37 #include <OgreEntity.h>
    38 #include <OgreAnimationState.h>
    39 
    40 #include "util/StringUtils.h"
     37//#include <OgreEntity.h>
     38//#include <OgreAnimationState.h>
    4139#include "core/CoreIncludes.h"
    4240#include "core/XMLPort.h"
    4341
     42#include "pickup/PickupIdentifier.h"
    4443#include "worldentities/pawns/Pawn.h"
    45 #include "pickup/PickupIdentifier.h"
    4644
    4745namespace orxonox
     
    6866    }
    6967
    70 
     68    /**
     69    @brief
     70    Initializes the member variables.
     71    */
     72    void InvisiblePickup::initialize(void)
     73    {
     74        this->duration_ = 0.0f;
     75        // Defines who is allowed to pick up the pickup.
     76        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     77    }
     78
     79    /**
     80    @brief
     81        Initializes the PickupIdentifier of this pickup.
     82    */
    7183    void InvisiblePickup::initializeIdentifier(void)
    7284    {
     
    8092    /**
    8193    @brief
    82     Initializes the member variables.
    83     */
    84     void InvisiblePickup::initialize(void)
    85     {
    86         this->duration_ = 0.0f;
    87         // Defines who is allowed to pick up the pickup.
    88         this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
    89     }
    90 
    91     /**
    92     @brief
    9394        Method for creating a HealthPickup object through XML.
    9495    */
     
    113114            return;
    114115
     116        // If the pickup has transited to used.
    115117        if (this->isUsed())
    116118        {
     119            // If its durationType is continuous, we set a Timer to be reminded, when the time has run out.
    117120            if(this->isContinuous())
    118121            {
     
    134137            this->setInvisible(false);
    135138
     139            // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded.
    136140            if((!this->isContinuous() && this->isImmediate()) || (this->isContinuous() && !this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()))
    137141            {
    138142                this->Pickupable::destroy();
    139143            }
     144            // We pause the Timer if the pickup is continuous and the duration is not yet exceeded,
    140145            else if(this->isContinuous() && this->durationTimer_.isActive())
    141146            {
     
    143148            }
    144149        }
    145 
    146     }
    147 
    148     /**
    149     @brief
    150         Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    151     @return
    152         A pointer to the Pawn, or NULL if the conversion failed.
    153     */
    154     Pawn* InvisiblePickup::carrierToPawnHelper(void)
    155     {
    156         PickupCarrier* carrier = this->getCarrier();
    157         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
    158 
    159         if(pawn == NULL)
    160         {
    161             COUT(1) << "Invalid PickupCarrier in InvisiblePickup." << std::endl;
    162         }
    163         return pawn;
    164150    }
    165151
     
    212198    /**
    213199    @brief
     200        Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
     201    @return
     202        A pointer to the Pawn, or NULL if the conversion failed.
     203    */
     204    Pawn* InvisiblePickup::carrierToPawnHelper(void)
     205    {
     206        PickupCarrier* carrier = this->getCarrier();
     207        Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     208
     209        if(pawn == NULL)
     210        {
     211            COUT(1) << "Invalid PickupCarrier in InvisiblePickup." << std::endl;
     212        }
     213        return pawn;
     214    }
     215
     216    /**
     217    @brief
    214218        Sets the time the InvisibilityPickup will last.
    215219    @param duration
  • code/trunk/src/modules/pickup/items/InvisiblePickup.h

    r7545 r7547  
    4040#include <string>
    4141
    42 #include <worldentities/pawns/Pawn.h>
    43 #include "worldentities/StaticEntity.h"
    4442#include "pickup/Pickup.h"
    4543
     
    4947    @brief
    5048        A pickup that makes the Pawn invisible.
    51         There are 2 parameters that can be chosen:
    52         - The <b>activation type</b> It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
    53         - The <b>duration type</b> It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the InvisiblePickup just makes the Pawn invisible for as long as it is used, for <em>continuous</em> the Pawn is invisible for the specified duration.
    54         - The <b>duration</b> Specifies how long (in seconds) the invisibility lasts.
     49        There are 3 parameters that can be chosen:
     50        - The @b activationType It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it. The default is <em>immediate</em>.
     51        - The @b durationType< It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the InvisiblePickup just makes the Pawn invisible for as long as it is used, for <em>continuous</em> the Pawn is invisible for the specified duration. The default is <em>once</em>.
     52        - The @b duration Specifies how long (in seconds) the invisibility lasts. The default is 0.
    5553
    56         An examle of a XML implementation of a InvisiblePickup would be:
     54        An example of a XML implementation of a InvisiblePickup would be:
    5755        @code
    58         <HealthPickup
     56        <InvisiblePickup
    5957            activationType = "immediate"
    6058            durationType = "continuous"
     
    8381            @return Returns if the Pawn is invisible.
    8482            */
    85             inline bool getInvisibility(bool)
     83            inline bool getInvisibility(bool) const
    8684                { return this->invisible_; }
    8785            /**
     
    8987            @return Returns the time in seconds the InvisibiltyPickup lasts.
    9088            */
    91             inline float getDuration(void)
     89            inline float getDuration(void) const
    9290                { return this->duration_; }
    9391
    9492        protected:
    95             void initializeIdentifier(void);
     93            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    9694
    9795            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
  • code/trunk/src/modules/pickup/items/MetaPickup.cc

    r7533 r7547  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
    36 #include "worldentities/pawns/Pawn.h"
     36
    3737#include "interfaces/PickupCarrier.h"
    3838#include "pickup/PickupIdentifier.h"
     39#include "worldentities/pawns/Pawn.h"
    3940
    4041#include "MetaPickup.h"
     
    7980        this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
    8081
    81         this->setActivationTypeDirect(pickupActivationType::immediate);
    8282        this->setDurationTypeDirect(pickupDurationType::once);
    8383        this->metaType_ = pickupMetaType::none;
     
    117117        SUPER(MetaPickup, changedUsed);
    118118
    119         //! If the MetaPickup transited to used.
    120         if(this->isUsed())
     119        // If the MetaPickup transited to used, and the metaType is not none.
     120        if(this->isUsed() && this->metaType_ != pickupMetaType::none)
    121121        {
    122122            PickupCarrier* carrier = this->getCarrier();
    123123            if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
    124124            {
     125                // If the metaType is destroyCarrier, then the PickupCarrier is destroyed.
    125126                if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier)
    126127                {
     
    131132                }
    132133                std::set<Pickupable*> pickups = carrier->getPickups();
    133                 //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending on the meta type.
     134                // Iterate over all Pickupables of the PickupCarrier.
    134135                for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++)
    135136                {
    136                     Pickup* pickup = dynamic_cast<Pickup*>(*it);
    137                     if(this->getMetaTypeDirect() == pickupMetaType::use)
     137                    Pickupable* pickup = (*it);
     138                    if(pickup == NULL || pickup == this)
     139                        continue;
     140
     141                    // If the metaType is use, then the Pickupable is set to used.
     142                    if(this->getMetaTypeDirect() == pickupMetaType::use && !pickup->isUsed())
    138143                    {
    139                         if(pickup != NULL && pickup != this && pickup->isOnUse() && !pickup->isUsed())
    140                         {
    141                             pickup->setUsed(true);
    142                         }
     144                        pickup->setUsed(true);
    143145                    }
    144                     if(this->getMetaTypeDirect() == pickupMetaType::drop)
     146                    // If the metaType is drop, then the Pickupable is dropped.
     147                    else if(this->getMetaTypeDirect() == pickupMetaType::drop)
    145148                    {
    146                         if(pickup != NULL && pickup != this)
    147                         {
    148                             pickup->drop();
    149                         }
     149                        pickup->drop();
    150150                    }
    151                     if(this->getMetaTypeDirect() == pickupMetaType::destroy)
     151                    // If the metaType is destroy, then the Pickupable is destroyed.
     152                    else if(this->getMetaTypeDirect() == pickupMetaType::destroy)
    152153                    {
    153                         if(pickup != NULL && pickup != this)
    154                         {
    155                             pickup->Pickupable::destroy();
    156                         }
     154                        pickup->Pickupable::destroy();
    157155                    }
    158156                }
     
    187185        Returns a string with the meta type of the MetaPickup.
    188186    */
    189     const std::string& MetaPickup::getMetaType(void)
     187    const std::string& MetaPickup::getMetaType(void) const
    190188    {
    191189        switch(this->getMetaTypeDirect())
  • code/trunk/src/modules/pickup/items/MetaPickup.h

    r7533 r7547  
    4242namespace orxonox {
    4343
    44     //! The meta type, deciding what the pickup does exactly.
     44    /**
     45    @brief
     46        The meta type, specifying what the @ref orxonox::MetaPickup "MetaPickup" does exactly.
     47
     48    @ingroup PickupItems
     49    */
    4550    namespace pickupMetaType
    4651    {
    4752        enum Value
    4853        {
    49             none,
    50             use,
    51             drop,
    52             destroy,
    53             destroyCarrier
     54            none, //!< The @ref orxonox::MetaPickup "MetaPickup" does nothing.
     55            use, //!< The @ref orxonox::MetaPickup "MetaPickup" uses all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
     56            drop, //!< The @ref orxonox::MetaPickup "MetaPickup" drops all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
     57            destroy, //!< The @ref orxonox::MetaPickup "MetaPickup" destroys all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
     58            destroyCarrier //!< The @ref orxonox::MetaPickup "MetaPickup" destroys the @ref orxonox::PickupCarrier "PickupCarrier".
    5459        };
    5560    }
     
    5762    /**
    5863    @brief
    59         The MetaPickup is a pickup that can, depending on the parameter 'metaType', do different things. If the 'metaType' is set to
    60         - @b use All the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup.
    61         - @b drop All the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup.
    62         - @b destroy All the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup.
    63         - @b destroyCarrier The PickupCarrier is immediately destroyed upon pickup of the MetaPickup.
     64        The MetaPickup is a Pickupable that can, depending on the parameter <em>metaTye</em>, do different things. If the <em>metaTye</em> is set to
     65        - @b use All the @ref orxonox::Pickupable "Pickupables", the PickupCarrier has, are immediately set to used upon using the MetaPickup.
     66        - @b drop All the @ref orxonox::Pickupable "Pickupables", the PickupCarrier has, are immediately dropped upon using the MetaPickup.
     67        - @b destroy All the @ref orxonox::Pickupable "Pickupables", the PickupCarrier has, are immediately destroyed upon using the MetaPickup.
     68        - @b destroyCarrier The PickupCarrier is immediately destroyed upon using the MetaPickup.
     69
     70        The default value is <em>none</em>, which basically does nothing.
     71       
     72        The parameter <b>activation type</b> can be used to specify, whether the MetaPickup is used upon pickup (<em>immediate</em>) or not (<em>onUse</em>). With <em>immediate</em> being the default.
     73
     74        An example of a XML implementation of a MetaPickup would be:
     75        @code
     76        <MetaPickup
     77            activationType = "immediate"
     78            metaType = "use"
     79        />
     80        @endcode
     81
    6482    @author
    6583        Damian 'Mozork' Frick
     84
     85    @ingroup PickupItems
    6686    */
    6787    class _PickupExport MetaPickup : public Pickup
     
    81101            @return Returns an enum with the meta type of the MetaPickup.
    82102            */
    83             inline pickupMetaType::Value getMetaTypeDirect(void)
     103            inline pickupMetaType::Value getMetaTypeDirect(void) const
    84104                { return this->metaType_; }
    85             const std::string& getMetaType(void); //!< Get the meta type of this MetaPickup.
     105            const std::string& getMetaType(void) const; //!< Get the meta type of this MetaPickup.
    86106
    87107        protected:
  • code/trunk/src/modules/pickup/items/ShieldPickup.cc

    r7208 r7547  
    3434#include "ShieldPickup.h"
    3535
     36#include <sstream>
    3637#include "core/CoreIncludes.h"
    3738#include "core/XMLPort.h"
    38 #include "util/StringUtils.h"
    39 
    40 #include "worldentities/pawns/SpaceShip.h"
    41 #include "items/Engine.h"
     39
    4240#include "pickup/PickupIdentifier.h"
    43 
    44 #include <sstream>
    45 
     41#include "worldentities/pawns/Pawn.h"
    4642
    4743namespace orxonox
     
    6763    {
    6864
    69     }
    70 
    71     /**
    72     @brief
    73     Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    74     @return
    75     A pointer to the Pawn, or NULL if the conversion failed.
    76     */
    77     Pawn* ShieldPickup::carrierToPawnHelper(void)
    78     {
    79         PickupCarrier* carrier = this->getCarrier();
    80         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
    81 
    82         if(pawn == NULL)
    83         {
    84             COUT(1) << "Invalid PickupCarrier in ShieldPickup." << std::endl;
    85         }
    86         return pawn;
    8765    }
    8866
     
    134112        SUPER(ShieldPickup, XMLPort, xmlelement, mode);
    135113
    136         XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode);
    137114        XMLPortParam(ShieldPickup, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode);
    138115        XMLPortParam(ShieldPickup, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode);
     116        XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode);
    139117
    140118        this->initializeIdentifier();
     
    149127        SUPER(ShieldPickup, changedUsed);
    150128
    151         //! If the pickup is not picked up nothing must be done.
     129        // If the pickup is not picked up nothing must be done.
    152130        if(!this->isPickedUp())
    153131            return;
     
    157135            this->Pickupable::destroy();
    158136
    159         //! If the pickup has transited to used.
     137        // If the pickup has transited to used.
    160138        if(this->isUsed())
    161139        {
    162             if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
     140            // If its durationType is continuous, we set a Timer to be reminded, when the time has run out.
     141            if(this->isContinuous())
    163142            {
    164                 this->durationTimer_.unpauseTimer();
    165             }
    166             else
    167             {
    168                 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&ShieldPickup::pickupTimerCallback, this)));
     143                if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
     144                {
     145                    this->durationTimer_.unpauseTimer();
     146                }
     147                else
     148                {
     149                    this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&ShieldPickup::pickupTimerCallback, this)));
     150                }
    169151            }
    170152            pawn->setShieldAbsorption(this->getShieldAbsorption());
     
    177159            pawn->setShieldHealth(0.0f);
    178160
    179             if(this->isOnce())
     161            // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded.
     162            if((!this->isContinuous() && this->isImmediate()) || (this->isContinuous() && !this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()))
    180163            {
    181                 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
    182                 {
    183                     this->Pickupable::destroy();
    184                 }
    185                 else
    186                 {
    187                     this->durationTimer_.pauseTimer();
    188                 }
     164                this->Pickupable::destroy();
    189165            }
    190         }
     166            // We pause the Timer if the pickup is continuous and the duration is not yet exceeded,
     167            else if(this->isContinuous() && this->durationTimer_.isActive())
     168            {
     169                this->durationTimer_.pauseTimer();
     170            }
     171        }
     172    }
     173
     174    /**
     175    @brief
     176    Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
     177    @return
     178    A pointer to the Pawn, or NULL if the conversion failed.
     179    */
     180    Pawn* ShieldPickup::carrierToPawnHelper(void)
     181    {
     182        PickupCarrier* carrier = this->getCarrier();
     183        Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     184
     185        if(pawn == NULL)
     186        {
     187            COUT(1) << "Invalid PickupCarrier in ShieldPickup." << std::endl;
     188        }
     189        return pawn;
    191190    }
    192191
     
    213212    /**
    214213    @brief
    215     Sets the percentage the shield absorbs of the dealt damage.
     214        Sets the duration.
     215    @param duration
     216        The duration in seconds.
     217    */
     218    void ShieldPickup::setDuration(float duration)
     219    {
     220        if(duration >= 0.0f)
     221        {
     222            this->duration_ = duration;
     223        }
     224        else
     225        {
     226            COUT(1) << "Invalid duration in ShieldPickup." << std::endl;
     227            this->duration_ = 0.0f;
     228        }
     229    }
     230
     231    /**
     232    @brief
     233        Sets the health of the shield.
     234    @param shieldHealth
     235        The shieldHealth.
     236    */
     237    void ShieldPickup::setShieldHealth(float shieldHealth)
     238    {
     239        if (shieldHealth>=0)
     240        {
     241            this->shieldHealth_=shieldHealth;
     242        }
     243        else
     244        {
     245            COUT(1) << "Invalid Shieldhealth in ShieldPickup." << std::endl;
     246            this->shieldHealth_=0;
     247        }
     248    }
     249
     250    /**
     251    @brief
     252        Sets the percentage the shield absorbs of the dealt damage.
    216253    @param shieldAbsorption
    217     The shieldAbsorption. Has to be between 0 and 1
     254        The shieldAbsorption. Has to be between 0 and 1.
    218255    */
    219256    void ShieldPickup::setShieldAbsorption(float shieldAbsorption)
     
    232269    /**
    233270    @brief
    234     Sets the health of the shield.
    235     @param shieldHealth
    236     The shieldHealth
    237     */
    238     void ShieldPickup::setShieldHealth(float shieldHealth)
    239     {
    240         if (shieldHealth>=0)
    241         {
    242             this->shieldHealth_=shieldHealth;
    243         }
    244         else
    245         {
    246             COUT(1) << "Invalid Shieldhealth in ShieldPickup." << std::endl;
    247             this->shieldHealth_=0;
    248         }
    249     }
    250 
    251     /**
    252     @brief
    253         Sets the duration.
    254     @param duration
    255         The duration
    256     */
    257     void ShieldPickup::setDuration(float duration)
    258     {
    259         if(duration >= 0.0f)
    260         {
    261             this->duration_ = duration;
    262         }
    263         else
    264         {
    265             COUT(1) << "Invalid duration in ShieldPickup." << std::endl;
    266             this->duration_ = 0.0f;
    267         }
    268     }
    269 
     271        Helper method. Is called by the Timer as soon as it expires.
     272    */
    270273    void ShieldPickup::pickupTimerCallback(void)
    271274    {
  • code/trunk/src/modules/pickup/items/ShieldPickup.h

    r7493 r7547  
    4040
    4141#include <string>
    42 #include "worldentities/pawns/Pawn.h"
    43 #include "worldentities/StaticEntity.h"
    4442
    4543#include "pickup/Pickup.h"
     
    5149        A Pickup which can add a Shield to the Pawn.
    5250
    53         There are 4 parameters that can be cosen.
    54         - The @b percentage The percentage the shield takes from the damage dealt to a Pawn
    55         - The @b hit @b points The amount of damage points a shield can teake before collapsing
    56         - The @b activation @b type 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
    57         - The @b duration the activation time of the pickup.
     51        There are 5 parameters that can be cosen.
     52        - The @b shieldhealth< The amount of damage points a shield can take before collapsing. The default is 0.
     53        - The @b shieldabsorption The percentage the shield takes from the damage dealt to a Pawn. The default is 0.
     54        - The @b activationType, <em>immediate</em> or <em>onUse</em>. defines if the ShiedlPickup is used when it's picked up or only after the player chooses to use it. The default is <em>immediate</em>.
     55        - The @b durationType, <em>once</em> means, that the shield will stay until it collapses, <em>continuous</em> means, that the shield only stays for a limited amount of time, specifiey by the duration. The default is <em>once</em>.
     56        - The @b duration the time in seconds the shield is active at the most. The default is 0.
     57
     58        An example of a XML implementation of a ShieldPickup would be:
     59        @code
     60        <ShieldPickup
     61            shieldhealth = 30
     62            shieldabsorption = 0.8
     63            activationType = "immediate"
     64            durationtype = "continuous"
     65            duration = 20.0
     66        />
     67        @endcode
    5868
    5969    @author
    6070        Eric Beier
     71
     72    @ingroup PickupItems
    6173    */
    6274    class _PickupExport ShieldPickup : public Pickup
     
    7284            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    7385
    74             inline float getDuration(void)
     86            /**
     87            @brief Get the duration, the time the shield is actvie at the most.
     88            @return Returns the duration in seconds.
     89            */
     90            inline float getDuration(void) const
    7591                { return this->duration_; }
    76             inline float getShieldHealth()
     92            /**
     93            @brief Get the shield health, the amount of damage the shield can sustain.
     94            @return Returns the shield health.
     95            */
     96            inline float getShieldHealth() const
    7797                { return this->shieldHealth_; }
    78             inline float getShieldAbsorption()
     98            /**
     99            @brief Get the shield absorption, the percentage of damage that is absorbed by the shield.
     100            @return Returns the shield absorption.
     101            */
     102            inline float getShieldAbsorption() const
    79103                { return this->shieldAbsorption_; }
    80104
    81105        protected:
    82106            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
     107            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
    83108
    84             void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    85 
    86             void setDuration(float duration);
    87             void setShieldHealth(float shieldHealth);
    88             void setShieldAbsorption(float shieldAbsorption);
     109            void setDuration(float duration); //!< Sets the duration.
     110            void setShieldHealth(float shieldHealth); //!< Sets the health of the shield.
     111            void setShieldAbsorption(float shieldAbsorption); //!< Sets the percentage the shield absorbs of the dealt damage.
    89112
    90113        private:
     
    95118
    96119            float duration_; //!< The health that is transferred to the Pawn.
    97             float shieldHealth_;
    98             float shieldAbsorption_; // Has to be between 0 and 1
     120            float shieldHealth_; //!< The amount of damage the shield can sustain.
     121            float shieldAbsorption_; //!< The percentage of damage that is absorbed by the shield.
    99122
    100123    };
  • code/trunk/src/modules/pickup/items/SpeedPickup.cc

    r7401 r7547  
    3434#include "SpeedPickup.h"
    3535
     36#include <sstream>
    3637#include "core/CoreIncludes.h"
    3738#include "core/XMLPort.h"
    38 #include "util/StringUtils.h"
    39 
    40 #include "worldentities/pawns/SpaceShip.h"
     39
    4140#include "items/Engine.h"
    4241#include "pickup/PickupIdentifier.h"
    43 
    44 #include <sstream>
    45 
     42#include "worldentities/pawns/SpaceShip.h"
    4643
    4744namespace orxonox
     
    130127        SUPER(SpeedPickup, changedUsed);
    131128
    132         //! If the pickup is not picked up nothing must be done.
     129        // If the pickup is not picked up nothing must be done.
    133130        if(!this->isPickedUp())
    134131            return;
    135132
    136133        Engine* engine = this->carrierToEngineHelper();
    137         if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
     134        if(engine == NULL) // If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
    138135            this->Pickupable::destroy();
    139136
    140         //! If the pickup has transited to used.
     137        // If the pickup has transited to used.
    141138        if(this->isUsed())
    142139        {
    143             if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
     140            // If its durationType is continuous, we set a Timer to be reminded, when the time has run out.
     141            if(this->isContinuous())
    144142            {
    145                 this->durationTimer_.unpauseTimer();
    146             }
    147             else
    148             {
    149                 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this)));
    150             }
    151             engine->setSpeedAdd(this->getSpeedAdd());
    152             engine->setSpeedMultiply(this->getSpeedMultiply());
    153         }
    154         else
    155         {
    156             engine->setSpeedAdd(0.0f);
    157             engine->setSpeedMultiply(1.0f);
    158 
    159             if(this->isOnce())
    160             {
    161                 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
     143                if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
    162144                {
    163                     this->Pickupable::destroy();
     145                    this->durationTimer_.unpauseTimer();
    164146                }
    165147                else
    166148                {
    167                     this->durationTimer_.pauseTimer();
     149                    this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this)));
    168150                }
     151            }
     152
     153            engine->setSpeedAdd(this->getSpeedAdd());
     154            engine->setSpeedMultiply(this->getSpeedMultiply());
     155        }
     156        else
     157        {
     158            engine->setSpeedAdd(0.0f);
     159            engine->setSpeedMultiply(1.0f);
     160
     161            // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded.
     162            if((!this->isContinuous() && this->isImmediate()) || (this->isContinuous() && !this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()))
     163            {
     164                this->Pickupable::destroy();
     165            }
     166            // We pause the Timer if the pickup is continuous and the duration is not yet exceeded,
     167            else if(this->isContinuous() && this->durationTimer_.isActive())
     168            {
     169                this->durationTimer_.pauseTimer();
    169170            }
    170171        }
     
    213214    /**
    214215    @brief
    215         Sets the duration.
     216        Sets the duration for which the SpeedPickup stays active.
    216217    @param duration
    217         The duration
     218        The duration in seconds.
    218219    */
    219220    void SpeedPickup::setDuration(float duration)
     
    232233    /**
    233234    @brief
    234         Sets the SpeedAdd
     235        Sets the speedAdd, the value that is added to the speed of the Pawn.
    235236    @param speedAdd
    236         The added Speed
     237        The added speed.
    237238    */
    238239    void SpeedPickup::setSpeedAdd(float speedAdd)
     
    251252    /**
    252253    @brief
    253         Sets the SpeedMultiply
     254        Sets the speedMultiply, the factor by which the speed of the Pawn is multiplied.
    254255    @param speedMultiply
    255         The multiplied Speed
     256        The factor by which the speed is mutiplied.
    256257    */
    257258    void SpeedPickup::setSpeedMultiply(float speedMultiply)
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r7493 r7547  
    3939
    4040#include <string>
    41 #include "worldentities/pawns/Pawn.h"
    42 #include "worldentities/StaticEntity.h"
    4341
    4442#include "pickup/Pickup.h"
     
    5048        A Pickup which can manipulate the Speed of a Pawn.
    5149
    52         There are 4 parameters that can be cosen:
    53         - The @b speed @b multiplier
    54         - The @b additional (forward) @b speed
    55         - The @b activation @b type 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
    56         - The @b duration The activation time of the pickup.
     50        There are 5 parameters that can be cosen:
     51        - The @b speedMultiply, specifies a factor by which the Spaceships speed is multiplied. The default is 1.
     52        - The @b speedAdd, specifies a value that is added to the speed of the Spaceship. The default is 0.
     53        - The @b activationType <em>immediate</em> or <em>onUse</em>, defines if the SpeedPickup is used when it's picked up or only after the player chooses to use it. The default is <em>immediate</em>.
     54        - The @b durationType Can be either <em>once</em> or <em>continuous</em>. For <em>once</em> the SpeedPickup is just active for as long as it is used, for <em>continuous</em> the SpeedPickup is active only for the specified duration. The default is <em>once</em>.
     55        - The @b duration The time in seconds the SpeedPickup is active at the most. The default is 0.
     56
     57        An example, how a SpeedPickup could be defined in XML could be:
     58        @code
     59        <SpeedPickup
     60            speedMultiply = 2.0
     61            speedAdd = 10.0
     62            activationType = "immediate"
     63            durationType = "continuous"
     64            duration = 30.0
     65        />
     66        @endcode
    5767
    5868    @author
    5969        Eric Beier
     70
     71    @ingroup PickupItems
    6072    */
    6173    class _PickupExport SpeedPickup : public Pickup
     
    7183            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    7284
    73             inline float getDuration(void)
     85            /**
     86            @brief Get the duration, the time the SpeedPickup is active.
     87            @return Returns the duration in seconds.
     88            */
     89            inline float getDuration(void) const
    7490                { return this->duration_; }
    75             inline float getSpeedAdd(void)
     91            /**
     92            @brief Get the value that is added to the speed of the Pawn.
     93            @return Returns the speedAdd.
     94            */
     95            inline float getSpeedAdd(void) const
    7696                { return this->speedAdd_; }
    77             inline float getSpeedMultiply(void)
     97            /**
     98            @brief Get the factor by wich the speed of the Pawn is multplied.
     99            @return Returns the speedMultiply.
     100            */
     101            inline float getSpeedMultiply(void) const
    78102                { return this->speedMultiply_; }
    79103
    80104        protected:
    81105            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    82 
    83106            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    84107
    85             void setDuration(float duration);
    86             void setSpeedAdd(float speedAdd);
    87             void setSpeedMultiply(float speedMultiply);
     108            void setDuration(float duration); //!< Sets the duration.
     109            void setSpeedAdd(float speedAdd); //!< Sets the SpeedAdd, the value that is added to the speed of the Pawn.
     110            void setSpeedMultiply(float speedMultiply); //!< Sets the speedMultiply, the factor by which the speed of the Pawn is multiplied.
    88111
    89112        private:
     
    93116            Timer durationTimer_; //!< Timer.
    94117
    95             float duration_; //!< The health that is transferred to the Pawn.
    96             float speedAdd_;
    97             float speedMultiply_;
     118            float duration_; //!< The time in seconds for which the SpeedPickup stays active.
     119            float speedAdd_; //!< The value that is added to the speed of the Pawn.
     120            float speedMultiply_; //!< The factor by which the speed of the Pawn is multiplied.
    98121    };
    99122}
Note: See TracChangeset for help on using the changeset viewer.