Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/modules/pickup/Pickup.h @ 6496

Last change on this file since 6496 was 6475, checked in by dafrick, 15 years ago

Additional documentation, code niceifying and potential bug fixing. Also: Renamed DroppedItem to DroppedPickup.

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