Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/levelKaan/src/modules/pickup/Pickup.h @ 10121

Last change on this file since 10121 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 7.9 KB
Line 
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
29/**
30    @file Pickup.h
31    @brief Declaration of the Pickup class.
32    @ingroup Pickup
33*/
34
35#ifndef _Pickup_H__
36#define _Pickup_H__
37
38#include "pickup/PickupPrereqs.h"
39
40#include "core/BaseObject.h"
41#include "core/XMLPort.h"
42#include "tools/Timer.h"
43
44#include "CollectiblePickup.h"
45
46namespace orxonox
47{
48
49    /**
50    @brief
51        Enum for the @ref orxonox::Pickup "Pickup" activation type.
52
53    @ingroup Pickup
54    */
55    namespace pickupActivationType
56    {
57        enum Value
58        {
59            immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup.
60            onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence.
61        };
62    }
63
64    /**
65    @brief
66        Enum for the @ref orxonox::Pickup "Pickup" duration type.
67
68    @ingroup Pickup
69    */
70    namespace pickupDurationType
71    {
72        enum Value
73        {
74            once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant.
75            continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan.
76        };
77    }
78
79    /**
80    @brief
81        The Pickup class offers (useful) base functionality for a wide range of pickups.
82
83        Pickups inheriting from this class can choose an activation type and a duration type.
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>.
86
87        If it were not an abstract class it could for example be used as follows in XML.
88        @code
89        <Pickup activationType="onUse" durationType="continuous" />
90        @endcode
91        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.
92
93    @author
94        Damian 'Mozork' Frick
95
96    @ingroup Pickup
97    */
98    class _PickupExport Pickup : public CollectiblePickup, public BaseObject
99    {
100
101        public:
102            Pickup(Context* context); //!< Constructor.
103            virtual ~Pickup(); //!< Destructor.
104
105            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
106
107            virtual const std::string& getRepresentationName() const
108                { return this->representationName_; }
109
110            /**
111            @brief Get the activation type of the Pickup.
112            @return Returns the activation type of the Pickup.
113            */
114            inline pickupActivationType::Value getActivationType(void) const
115                { return this->activationType_; }
116            /**
117            @brief Get the duration type of the Pickup.
118            @return Returns the duration type of the Pickup.
119            */
120            inline pickupDurationType::Value getDurationType(void) const
121                { return this->durationType_; }
122
123            const std::string& getActivationTypeAsString(void) const; //!< Get the activation type of the Pickup.
124            const std::string& getDurationTypeAsString(void) const; //!< Get the duration type of the Pickup.
125
126            /**
127            @brief Get whether the activation type is 'immediate'.
128            @return Returns true if the activation type is 'immediate'.
129            */
130            inline bool isImmediate(void) const
131                { return this->getActivationType() == pickupActivationType::immediate; }
132            /**
133            @brief Get whether the activation type is 'onUse'.
134            @return Returns true if the activation type is 'onUse'.
135            */
136            inline bool isOnUse(void) const
137                { return this->getActivationType() == pickupActivationType::onUse; }
138            /**
139            @brief Get whether the duration type is 'once'.
140            @return Returns true if the duration type is 'once'.
141            */
142            inline bool isOnce(void) const
143                { return this->getDurationType() == pickupDurationType::once; }
144            /**
145            @brief Get whether the duration type is 'continuous'.
146            @return Returns true if the duration type is 'continuous'.
147            */
148            inline bool isContinuous(void) const
149                { return this->getDurationType() == pickupDurationType::continuous; }
150
151            virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
152
153        protected:
154            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
155
156            /**
157            @brief Sets the representation name which refers to the name of the PickupRepresentation that is used to represent this pickup.
158            */
159            inline void setRepresentationName(const std::string& name)
160                { this->representationName_ = name; }
161
162            /**
163            @brief Set the activation type of the Pickup.
164            @param type The activation type of the Pickup.
165            */
166            inline void setActivationType(pickupActivationType::Value type)
167                { this->activationType_ = type; }
168            /**
169            @brief Set the duration type of the Pickup.
170            @param type The duration type of the Pickup.
171            */
172            inline void setDurationType(pickupDurationType::Value type)
173                { this->durationType_ = type; }
174
175            void setActivationTypeAsString(const std::string& type); //!< Set the activation type of the Pickup.
176            void setDurationTypeAsString(const std::string& type); //!< Set the duration type of the Pickup.
177
178        private:
179            void initialize(void); //!< Initializes the member variables.
180
181            std::string representationName_; //!< The name of the associated PickupRepresentation.
182            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
183            pickupDurationType::Value durationType_; //!< The duration type of the Pickup.
184
185            //! Strings for the activation and duration types.
186            static const std::string activationTypeImmediate_s;
187            static const std::string activationTypeOnUse_s;
188            static const std::string durationTypeOnce_s;
189            static const std::string durationTypeContinuous_s;
190    };
191
192}
193#endif // _Pickup_H__
Note: See TracBrowser for help on using the repository browser.