Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/Pickup.h @ 12189

Last change on this file since 12189 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 7.8 KB
RevLine 
[6474]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27*/
28
[6540]29/**
30    @file Pickup.h
31    @brief Declaration of the Pickup class.
[7456]32    @ingroup Pickup
[6540]33*/
34
[6474]35#ifndef _Pickup_H__
[6475]36#define _Pickup_H__
[6474]37
38#include "pickup/PickupPrereqs.h"
39
40#include "core/BaseObject.h"
41#include "core/XMLPort.h"
[7547]42#include "tools/Timer.h"
[6474]43
[7163]44#include "CollectiblePickup.h"
[6475]45
[6474]46namespace orxonox
47{
48
[7533]49    /**
50    @brief
51        Enum for the @ref orxonox::Pickup "Pickup" activation type.
52
53    @ingroup Pickup
54    */
[11071]55    enum class PickupActivationType
[6474]56    {
[11071]57        immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup.
58        onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence.
59    };
[6709]60
[7533]61    /**
62    @brief
63        Enum for the @ref orxonox::Pickup "Pickup" duration type.
64
65    @ingroup Pickup
66    */
[11071]67    enum class PickupDurationType
[6474]68    {
[11071]69        once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant.
70        continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan.
71    };
[6709]72
[6475]73    /**
74    @brief
[7494]75        The Pickup class offers (useful) base functionality for a wide range of pickups.
76
[8108]77        Pickups inheriting from this class can choose an activation type and a duration type.
[7547]78        - 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>.
79        - 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>.
[7494]80
81        If it were not an abstract class it could for example be used as follows in XML.
82        @code
83        <Pickup activationType="onUse" durationType="continuous" />
84        @endcode
85        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.
86
[6475]87    @author
88        Damian 'Mozork' Frick
[7533]89
90    @ingroup Pickup
[6475]91    */
[7163]92    class _PickupExport Pickup : public CollectiblePickup, public BaseObject
[6474]93    {
[6709]94
[7163]95        public:
[9667]96            Pickup(Context* context); //!< Constructor.
[6475]97            virtual ~Pickup(); //!< Destructor.
[6709]98
[11071]99            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
[6709]100
[11071]101            virtual const std::string& getRepresentationName() const override
[9348]102                { return this->representationName_; }
103
[6474]104            /**
[7494]105            @brief Get the activation type of the Pickup.
106            @return Returns the activation type of the Pickup.
[6474]107            */
[11071]108            inline PickupActivationType getActivationType(void) const
[6474]109                { return this->activationType_; }
110            /**
[7494]111            @brief Get the duration type of the Pickup.
112            @return Returns the duration type of the Pickup.
[6474]113            */
[11071]114            inline PickupDurationType getDurationType(void) const
[6474]115                { return this->durationType_; }
[6709]116
[9348]117            const std::string& getActivationTypeAsString(void) const; //!< Get the activation type of the Pickup.
118            const std::string& getDurationTypeAsString(void) const; //!< Get the duration type of the Pickup.
[6709]119
[6475]120            /**
121            @brief Get whether the activation type is 'immediate'.
122            @return Returns true if the activation type is 'immediate'.
123            */
[7547]124            inline bool isImmediate(void) const
[11071]125                { return this->getActivationType() == PickupActivationType::immediate; }
[6475]126            /**
127            @brief Get whether the activation type is 'onUse'.
128            @return Returns true if the activation type is 'onUse'.
129            */
[7547]130            inline bool isOnUse(void) const
[11071]131                { return this->getActivationType() == PickupActivationType::onUse; }
[6475]132            /**
133            @brief Get whether the duration type is 'once'.
134            @return Returns true if the duration type is 'once'.
135            */
[7547]136            inline bool isOnce(void) const
[11071]137                { return this->getDurationType() == PickupDurationType::once; }
[6475]138            /**
139            @brief Get whether the duration type is 'continuous'.
140            @return Returns true if the duration type is 'continuous'.
141            */
[7547]142            inline bool isContinuous(void) const
[11071]143                { return this->getDurationType() == PickupDurationType::continuous; }
[6709]144
[11071]145            virtual void changedPickedUp(void) override; //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
[6709]146
[6474]147        protected:
[11071]148            virtual bool createSpawner(void) override; //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
[6709]149
[6728]150            /**
[9348]151            @brief Sets the representation name which refers to the name of the PickupRepresentation that is used to represent this pickup.
152            */
153            inline void setRepresentationName(const std::string& name)
154                { this->representationName_ = name; }
155
156            /**
[7494]157            @brief Set the activation type of the Pickup.
158            @param type The activation type of the Pickup.
[6474]159            */
[11071]160            inline void setActivationType(PickupActivationType type)
[6474]161                { this->activationType_ = type; }
162            /**
[7494]163            @brief Set the duration type of the Pickup.
164            @param type The duration type of the Pickup.
[6474]165            */
[11071]166            inline void setDurationType(PickupDurationType type)
[6474]167                { this->durationType_ = type; }
[6709]168
[9348]169            void setActivationTypeAsString(const std::string& type); //!< Set the activation type of the Pickup.
170            void setDurationTypeAsString(const std::string& type); //!< Set the duration type of the Pickup.
[6709]171
[6474]172        private:
[6475]173            void initialize(void); //!< Initializes the member variables.
[7163]174
[9348]175            std::string representationName_; //!< The name of the associated PickupRepresentation.
[11071]176            PickupActivationType activationType_; //!< The activation type of the Pickup.
177            PickupDurationType durationType_; //!< The duration type of the Pickup.
[6709]178
[6728]179            //! Strings for the activation and duration types.
[6474]180            static const std::string activationTypeImmediate_s;
181            static const std::string activationTypeOnUse_s;
182            static const std::string durationTypeOnce_s;
183            static const std::string durationTypeContinuous_s;
184    };
[6709]185
[6474]186}
187#endif // _Pickup_H__
Note: See TracBrowser for help on using the repository browser.