Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7207 was 7163, checked in by dafrick, 14 years ago

Merged presentation3 branch into trunk.

  • Property svn:eol-style set to native
File size: 6.4 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.
32*/
33
[6474]34#ifndef _Pickup_H__
[6475]35#define _Pickup_H__
[6474]36
37#include "pickup/PickupPrereqs.h"
38
39#include "core/BaseObject.h"
40#include "core/XMLPort.h"
41
[7163]42#include "CollectiblePickup.h"
[6475]43
[6709]44#include "tools/Timer.h"
45
[6474]46namespace orxonox
47{
48
49    //! Enum for the activation type.
50    namespace pickupActivationType
51    {
52        enum Value
53        {
54            immediate,
55            onUse,
56        };
57    }
[6709]58
[6474]59    //! Enum for the duration tyoe.
60    namespace pickupDurationType
61    {
62        enum Value
63        {
64            once,
65            continuous,
66        };
67    }
[6709]68
[6475]69    /**
70    @brief
71        Pickup class. Offers base functionality for a wide range of pickups.
72        Pickups ingeriting from this class cann choose an activation type and a duration type.
73    @author
74        Damian 'Mozork' Frick
75    */
[7163]76    class _PickupExport Pickup : public CollectiblePickup, public BaseObject
[6474]77    {
[6709]78
[7163]79        public:
[6540]80            Pickup(BaseObject* creator); //!< Constructor.
[6475]81            virtual ~Pickup(); //!< Destructor.
[6709]82
[6474]83            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
[6709]84
[6474]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_; }
[6709]97
[6474]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.
[6709]100
[6475]101            /**
102            @brief Get whether the activation type is 'immediate'.
103            @return Returns true if the activation type is 'immediate'.
104            */
[6474]105            inline bool isImmediate(void)
106                { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
[6475]107            /**
108            @brief Get whether the activation type is 'onUse'.
109            @return Returns true if the activation type is 'onUse'.
110            */
[6474]111            inline bool isOnUse(void)
112                { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
[6475]113            /**
114            @brief Get whether the duration type is 'once'.
115            @return Returns true if the duration type is 'once'.
116            */
[6474]117            inline bool isOnce(void)
118                { return this->getDurationTypeDirect() == pickupDurationType::once; }
[6475]119            /**
120            @brief Get whether the duration type is 'continuous'.
121            @return Returns true if the duration type is 'continuous'.
122            */
[6474]123            inline bool isContinuous(void)
124                { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
[6709]125
[6521]126            virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
[6709]127
[6497]128            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
[6709]129
[6474]130        protected:
131            void initializeIdentifier(void);
[6709]132
[6540]133            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
[6709]134
[6728]135            bool startPickupTimer(float durationTime); //!< Starts the pickup duration timer.
136            /**
137            @brief Get your Timer.
138            @return Returns a pointer to the Timer.
139            */
140            inline Timer* getTimer(void)
141                { return &this->durationTimer_; }
[6709]142
[6728]143            /**
144            @brief The callback method for the Timer.
145                   Can be overloaded to implement desired functionality.
146            */
[6709]147            virtual void pickupTimerCallback(void) {}
148
[6474]149            /**
150            @brief Set the activation type of the pickup.
151            @param type The activation type of the pickup.
152            */
153            inline void setActivationTypeDirect(pickupActivationType::Value type)
154                { this->activationType_ = type; }
155            /**
156            @brief Set the duration type of the pickup.
157            @param type The duration type of the pickup.
158            */
159            inline void setDurationTypeDirect(pickupDurationType::Value type)
160                { this->durationType_ = type; }
[6709]161
[6474]162            void setActivationType(const std::string& type); //!< Set the activation type of the pickup.
163            void setDurationType(const std::string& type); //!< Set the duration type of the pickup
[6709]164
[6474]165        private:
[6475]166            void initialize(void); //!< Initializes the member variables.
[7163]167
[6709]168            //TODO: Problems, when there are more Timers needed? Solutions?
169            Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup.
170
[6474]171            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
172            pickupDurationType::Value durationType_; //!< The duration type of the pickup.
[6709]173
[6728]174            //! Strings for the activation and duration types.
[6474]175            static const std::string activationTypeImmediate_s;
176            static const std::string activationTypeOnUse_s;
177            static const std::string durationTypeOnce_s;
178            static const std::string durationTypeContinuous_s;
179    };
[6709]180
[6474]181}
182#endif // _Pickup_H__
Note: See TracBrowser for help on using the repository browser.