Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/orxonox/pickup/ModifierPickup.h @ 6419

Last change on this file since 6419 was 6419, checked in by rgrieder, 14 years ago

Merged pickup2 into pickup3.

  • Property svn:eol-style set to native
File size: 7.2 KB
RevLine 
[2917]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 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Definition of ModifierPickup (temporary(?) pickup for testing).
32*/
33
34#ifndef _ModifierPickup_H__
35#define _ModifierPickup_H__
36
[3196]37#include "OrxonoxPrereqs.h"
38
[3042]39#include <climits>
[3196]40#include <map>
[3042]41
[5717]42#include "tools/Timer.h"
[3196]43#include "ModifierType.h"
[2917]44#include "PassiveItem.h"
45
46namespace orxonox
47{
48    /**
[6419]49    @brief Class for a (temporary) modifier effect.
50    @author Daniel 'Huty' Haggenmueller
[2917]51    */
[6419]52    //TODO: More elaborate comments.
[2917]53    class _OrxonoxExport ModifierPickup : public PassiveItem
54    {
[6419]55        //TODO: What does being derived from PassiveItem add exactly? Probably better to kill PassiveItem and just derive from BaseItem.
56        //Include ModifierType here, no additional header file needed for that, imo.
57        public:
58            ModifierPickup(BaseObject* creator);
59            virtual ~ModifierPickup();
[2917]60
[6419]61            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file.
[2917]62
[6419]63            virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method.
64            virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method
[2917]65
[6419]66            //TODO: Where does this INT_MAX come from? Comment.
67            virtual int getMaxCarryAmount() //!< Allow the player to carry infinite ModPickups
68                { return INT_MAX; }
[2917]69
[6419]70            /**
[2917]71            @brief Get the duration of this pickup.
72            @return Returns how long the effect holds on.
[6419]73            */
74            inline float getDuration() const
75                { return this->duration_; }
76            /**
[2917]77            @brief Set the duration of this pickup.
78            @param duration How long the effect should hold.
[6419]79            */
80            //TODO: Better be private?
81            inline void setDuration(float duration)
82                { this->duration_ = duration; }
[2917]83
[6419]84            //TODO: Shouldn't these all be seperate pickup items? But, then, would this class really be needed? What does it actually add?
85            //Duration! Thus create two virtual functions addEffect() and removeEffect().
86            //Export the ideas here into seperate, individual subclasses.
87            //Shouldn't this, as an item be in the items folder? or is it, as merely the equivalent of an abstract class not specific enough?
88            //Specify what ModifierItem should do exactly. If the limited duration is the core functionality, another name would probably more fitting.
89            //Perhaps, limited effect duration could also just be another feature of BaseItem...
90            /**
[2917]91            @brief Get the amount of damage this pickup adds.
92            @return Returns how much damage this pickup adds.
[6419]93            */
94            inline float getAdditiveDamage() const
95                { return this->getAdditiveModifier(ModifierType::Damage); }
96            /**
[2917]97            @brief Get the factor by which this pickup multiplies the damage.
98            @return Returns the factor by which to multiply damage.
[6419]99            */
100            inline float getMultiplicativeDamage() const
101                { return this->getMultiplicativeModifier(ModifierType::Damage); }
[2917]102
[6419]103            /**
[2917]104            @brief Set the amount of damage this pickup adds.
105            @param value How much damage this pickup adds.
[6419]106            */
107            inline void setAdditiveDamage(float value)
108                { this->setAdditiveModifier(ModifierType::Damage, value); }
109            /**
[2917]110            @brief Set the factor by which this pickup multiplies the damage.
111            @param value Factor by which to multiply damage.
[6419]112            */
113            inline void setMultiplicativeDamage(float value)
114                { this->setMultiplicativeModifier(ModifierType::Damage, value); }
[2917]115
[6419]116            /**
[2917]117            @brief Get the amount of acceleration this pickup adds.
118            @return Returns how much acceleration this pickup adds.
[6419]119            */
120            inline float getAdditiveAcceleration() const
121                { return this->getAdditiveModifier(ModifierType::Acceleration); }
122            /**
[2917]123            @brief Get the factor by which this pickup multiplies the acceleration.
124            @return Returns the factor by which to multiply acceleration.
[6419]125            */
126            inline float getMultiplicativeAcceleration() const
127                { return this->getMultiplicativeModifier(ModifierType::Acceleration); }
[2917]128
[6419]129            /**
[2917]130            @brief Set the amount of acceleration this pickup adds.
131            @param value How much acceleration this pickup adds.
[6419]132            */
133            inline void setAdditiveAcceleration(float value)
134                { this->setAdditiveModifier(ModifierType::Acceleration, value); }
135            /**
[2917]136            @brief Set the factor by which this pickup multiplies the acceleration.
137            @param value Factor by which to multiply acceleration.
[6419]138            */
139            inline void setMultiplicativeAcceleration(float value)
140                { this->setMultiplicativeModifier(ModifierType::Acceleration, value); }
[2917]141
[6419]142            //TODO: Make private?
143            void timerCallback(Pawn* pawn);     //!< Method called when the timer runs out.
[6417]144
[6419]145        private:
146            float getAdditiveModifier(ModifierType::Value type) const;               //!< Get the additive modifier for a given ModifierType.
147            float getMultiplicativeModifier(ModifierType::Value type) const;         //!< Get the multiplicative modifier for a given ModifierType.
148            void setAdditiveModifier(ModifierType::Value type, float value);         //!< Set the additive modifier for a given ModifierType.
149            void setMultiplicativeModifier(ModifierType::Value type, float value);   //!< Set the multiplicative modifier for a given ModifierType
[2917]150
[6419]151            std::map<ModifierType::Value, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType.
152            std::map<ModifierType::Value, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType.
[2917]153
[6419]154            float duration_;                                                         //!< Duration of this pickup's effect (0 for unlimited).
155            Timer timer_;                                                            //!< Timer used if the pickup's effect has a time limit.
[2917]156    };
157}
158
159#endif /* _ModifierPickup_H__ */
Note: See TracBrowser for help on using the repository browser.