Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6698 was 6540, checked in by dafrick, 15 years ago

Removed some TODO's. Finished up documenting pickup module.

File size: 5.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*/
33
34#ifndef _Pickup_H__
35#define _Pickup_H__
36
37#include "pickup/PickupPrereqs.h"
38
39#include "core/BaseObject.h"
40#include "core/XMLPort.h"
41
42#include "interfaces/Pickupable.h"
43
44namespace orxonox
45{
46
47    //! Enum for the activation type.
48    namespace pickupActivationType
49    {
50        enum Value
51        {
52            immediate,
53            onUse,
54        };
55    }
56   
57    //! Enum for the duration tyoe.
58    namespace pickupDurationType
59    {
60        enum Value
61        {
62            once,
63            continuous,
64        };
65    }
66   
67    /**
68    @brief
69        Pickup class. Offers base functionality for a wide range of pickups.
70        Pickups ingeriting from this class cann choose an activation type and a duration type.
71    @author
72        Damian 'Mozork' Frick
73    */
74    class _PickupExport Pickup : public Pickupable, public BaseObject
75    {
76       
77        protected:
78            Pickup(BaseObject* creator); //!< Constructor.
79       
80        public:
81            virtual ~Pickup(); //!< Destructor.
82           
83            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
84           
85            /**
86            @brief Get the activation type of the pickup.
87            @return Returns the activation type of the pickup.
88            */
89            inline pickupActivationType::Value getActivationTypeDirect(void)
90                { return this->activationType_; }
91            /**
92            @brief Get the duration type of the pickup.
93            @return Returns the duration type of the pickup.
94            */
95            inline pickupDurationType::Value getDurationTypeDirect(void)
96                { return this->durationType_; }
97           
98            const std::string& getActivationType(void); //!< Get the activation type of the pickup.
99            const std::string& getDurationType(void); //!< Get the duration type of the pickup.
100           
101            /**
102            @brief Get whether the activation type is 'immediate'.
103            @return Returns true if the activation type is 'immediate'.
104            */
105            inline bool isImmediate(void)
106                { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
107            /**
108            @brief Get whether the activation type is 'onUse'.
109            @return Returns true if the activation type is 'onUse'.
110            */
111            inline bool isOnUse(void)
112                { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
113            /**
114            @brief Get whether the duration type is 'once'.
115            @return Returns true if the duration type is 'once'.
116            */
117            inline bool isOnce(void)
118                { return this->getDurationTypeDirect() == pickupDurationType::once; }
119            /**
120            @brief Get whether the duration type is 'continuous'.
121            @return Returns true if the duration type is 'continuous'.
122            */
123            inline bool isContinuous(void)
124                { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
125           
126            virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
127                                   
128            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
129               
130        protected:
131            void initializeIdentifier(void);
132           
133            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
134           
135            /**
136            @brief Set the activation type of the pickup.
137            @param type The activation type of the pickup.
138            */
139            inline void setActivationTypeDirect(pickupActivationType::Value type)
140                { this->activationType_ = type; }
141            /**
142            @brief Set the duration type of the pickup.
143            @param type The duration type of the pickup.
144            */
145            inline void setDurationTypeDirect(pickupDurationType::Value type)
146                { this->durationType_ = type; }
147               
148            void setActivationType(const std::string& type); //!< Set the activation type of the pickup.
149            void setDurationType(const std::string& type); //!< Set the duration type of the pickup
150               
151        private:
152            void initialize(void); //!< Initializes the member variables.
153           
154            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
155            pickupDurationType::Value durationType_; //!< The duration type of the pickup.
156           
157            static const std::string activationTypeImmediate_s;
158            static const std::string activationTypeOnUse_s;
159            static const std::string durationTypeOnce_s;
160            static const std::string durationTypeContinuous_s;
161       
162    };
163   
164}
165#endif // _Pickup_H__
Note: See TracBrowser for help on using the repository browser.