Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/environment/src/modules/pickup/Pickup.h @ 8236

Last change on this file since 8236 was 7494, checked in by dafrick, 14 years ago

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

  • Property svn:eol-style set to native
File size: 7.4 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
43#include "CollectiblePickup.h"
44
45#include "tools/Timer.h"
46
47namespace orxonox
48{
49
50    //! Enum for the @ref orxonox::Pickup "Pickup" activation type.
51    namespace pickupActivationType
52    {
53        enum Value
54        {
55            immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup.
56            onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence.
57        };
58    }
59
60    //! Enum for the @ref orxonox::Pickup "Pickup" duration type.
61    namespace pickupDurationType
62    {
63        enum Value
64        {
65            once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant.
66            continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan.
67        };
68    }
69
70    /**
71    @brief
72        The Pickup class offers (useful) base functionality for a wide range of pickups.
73
74        Pickups ingeriting from this class can choose an activation type and a duration type.
75        - The <b>activation type</b> deals with what happens to the Pickup as soon as it is picked up. It can either be set to <em>immediate</em>, which means that the Pickup is activated/used immediately upon being picked up. Or to <em>onUse</em>, which means, that the Pickup will be activated/used if some outside entity (most commonly the player through the PickupInventory) decides to use it.
76        - The <b>duration type</b> deals with whether the Pickup has a continuous effect or whether its effect is focused on a singular instant. It can either be set to <em>once</em>, which means, that the Pickup just has an effect (at a singular instant in time) and is done once that effect has been applied. Or to <em>continuous</em>, which means that the effect of the Pickup unfolds over some timespan.
77
78        If it were not an abstract class it could for example be used as follows in XML.
79        @code
80        <Pickup activationType="onUse" durationType="continuous" />
81        @endcode
82        In reality you can (naturally) use the parameters <b>activation type</b> and <b>duration type</b> in any pickup inheriting from Pickup, unless the pickup already specifies one (or both) of the parameters.
83
84    @author
85        Damian 'Mozork' Frick
86    */
87    class _PickupExport Pickup : public CollectiblePickup, public BaseObject
88    {
89
90        public:
91            Pickup(BaseObject* creator); //!< Constructor.
92            virtual ~Pickup(); //!< Destructor.
93
94            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
95
96            /**
97            @brief Get the activation type of the Pickup.
98            @return Returns the activation type of the Pickup.
99            */
100            inline pickupActivationType::Value getActivationTypeDirect(void)
101                { return this->activationType_; }
102            /**
103            @brief Get the duration type of the Pickup.
104            @return Returns the duration type of the Pickup.
105            */
106            inline pickupDurationType::Value getDurationTypeDirect(void)
107                { return this->durationType_; }
108
109            const std::string& getActivationType(void); //!< Get the activation type of the Pickup.
110            const std::string& getDurationType(void); //!< Get the duration type of the Pickup.
111
112            /**
113            @brief Get whether the activation type is 'immediate'.
114            @return Returns true if the activation type is 'immediate'.
115            */
116            inline bool isImmediate(void)
117                { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
118            /**
119            @brief Get whether the activation type is 'onUse'.
120            @return Returns true if the activation type is 'onUse'.
121            */
122            inline bool isOnUse(void)
123                { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
124            /**
125            @brief Get whether the duration type is 'once'.
126            @return Returns true if the duration type is 'once'.
127            */
128            inline bool isOnce(void)
129                { return this->getDurationTypeDirect() == pickupDurationType::once; }
130            /**
131            @brief Get whether the duration type is 'continuous'.
132            @return Returns true if the duration type is 'continuous'.
133            */
134            inline bool isContinuous(void)
135                { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
136
137            virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
138
139            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the OrxonoxClass.
140
141        protected:
142            void initializeIdentifier(void);
143
144            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
145
146            /**
147            @brief Set the activation type of the Pickup.
148            @param type The activation type of the Pickup.
149            */
150            inline void setActivationTypeDirect(pickupActivationType::Value type)
151                { this->activationType_ = type; }
152            /**
153            @brief Set the duration type of the Pickup.
154            @param type The duration type of the Pickup.
155            */
156            inline void setDurationTypeDirect(pickupDurationType::Value type)
157                { this->durationType_ = type; }
158
159            void setActivationType(const std::string& type); //!< Set the activation type of the Pickup.
160            void setDurationType(const std::string& type); //!< Set the duration type of the Pickup.
161
162        private:
163            void initialize(void); //!< Initializes the member variables.
164
165            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
166            pickupDurationType::Value durationType_; //!< The duration type of the Pickup.
167
168            //! Strings for the activation and duration types.
169            static const std::string activationTypeImmediate_s;
170            static const std::string activationTypeOnUse_s;
171            static const std::string durationTypeOnce_s;
172            static const std::string durationTypeContinuous_s;
173    };
174
175}
176#endif // _Pickup_H__
Note: See TracBrowser for help on using the repository browser.