| 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 |  | 
|---|
| 37 | #include "OrxonoxPrereqs.h" | 
|---|
| 38 |  | 
|---|
| 39 | #include <climits> | 
|---|
| 40 | #include <map> | 
|---|
| 41 |  | 
|---|
| 42 | #include "tools/Timer.h" | 
|---|
| 43 | #include "ModifierType.h" | 
|---|
| 44 | #include "PassiveItem.h" | 
|---|
| 45 |  | 
|---|
| 46 | namespace orxonox | 
|---|
| 47 | { | 
|---|
| 48 |     /** | 
|---|
| 49 |     @brief Class for a (temporary) modifier effect. | 
|---|
| 50 |     @author Daniel 'Huty' Haggenmueller | 
|---|
| 51 |     */ | 
|---|
| 52 |     //TODO: More elaborate comments. | 
|---|
| 53 |     class _OrxonoxExport ModifierPickup : public PassiveItem | 
|---|
| 54 |     { | 
|---|
| 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(); | 
|---|
| 60 |  | 
|---|
| 61 |             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file. | 
|---|
| 62 |  | 
|---|
| 63 |             virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method. | 
|---|
| 64 |             virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method | 
|---|
| 65 |  | 
|---|
| 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; } | 
|---|
| 69 |  | 
|---|
| 70 |             /** | 
|---|
| 71 |             @brief Get the duration of this pickup. | 
|---|
| 72 |             @return Returns how long the effect holds on. | 
|---|
| 73 |             */ | 
|---|
| 74 |             inline float getDuration() const | 
|---|
| 75 |                 { return this->duration_; } | 
|---|
| 76 |             /** | 
|---|
| 77 |             @brief Set the duration of this pickup. | 
|---|
| 78 |             @param duration How long the effect should hold. | 
|---|
| 79 |             */ | 
|---|
| 80 |             //TODO: Better be private? | 
|---|
| 81 |             inline void setDuration(float duration) | 
|---|
| 82 |                 { this->duration_ = duration; } | 
|---|
| 83 |  | 
|---|
| 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 |             /** | 
|---|
| 91 |             @brief Get the amount of damage this pickup adds. | 
|---|
| 92 |             @return Returns how much damage this pickup adds. | 
|---|
| 93 |             */ | 
|---|
| 94 |             inline float getAdditiveDamage() const | 
|---|
| 95 |                 { return this->getAdditiveModifier(ModifierType::Damage); } | 
|---|
| 96 |             /** | 
|---|
| 97 |             @brief Get the factor by which this pickup multiplies the damage. | 
|---|
| 98 |             @return Returns the factor by which to multiply damage. | 
|---|
| 99 |             */ | 
|---|
| 100 |             inline float getMultiplicativeDamage() const | 
|---|
| 101 |                 { return this->getMultiplicativeModifier(ModifierType::Damage); } | 
|---|
| 102 |  | 
|---|
| 103 |             /** | 
|---|
| 104 |             @brief Set the amount of damage this pickup adds. | 
|---|
| 105 |             @param value How much damage this pickup adds. | 
|---|
| 106 |             */ | 
|---|
| 107 |             inline void setAdditiveDamage(float value) | 
|---|
| 108 |                 { this->setAdditiveModifier(ModifierType::Damage, value); } | 
|---|
| 109 |             /** | 
|---|
| 110 |             @brief Set the factor by which this pickup multiplies the damage. | 
|---|
| 111 |             @param value Factor by which to multiply damage. | 
|---|
| 112 |             */ | 
|---|
| 113 |             inline void setMultiplicativeDamage(float value) | 
|---|
| 114 |                 { this->setMultiplicativeModifier(ModifierType::Damage, value); } | 
|---|
| 115 |  | 
|---|
| 116 |             /** | 
|---|
| 117 |             @brief Get the amount of acceleration this pickup adds. | 
|---|
| 118 |             @return Returns how much acceleration this pickup adds. | 
|---|
| 119 |             */ | 
|---|
| 120 |             inline float getAdditiveAcceleration() const | 
|---|
| 121 |                 { return this->getAdditiveModifier(ModifierType::Acceleration); } | 
|---|
| 122 |             /** | 
|---|
| 123 |             @brief Get the factor by which this pickup multiplies the acceleration. | 
|---|
| 124 |             @return Returns the factor by which to multiply acceleration. | 
|---|
| 125 |             */ | 
|---|
| 126 |             inline float getMultiplicativeAcceleration() const | 
|---|
| 127 |                 { return this->getMultiplicativeModifier(ModifierType::Acceleration); } | 
|---|
| 128 |  | 
|---|
| 129 |             /** | 
|---|
| 130 |             @brief Set the amount of acceleration this pickup adds. | 
|---|
| 131 |             @param value How much acceleration this pickup adds. | 
|---|
| 132 |             */ | 
|---|
| 133 |             inline void setAdditiveAcceleration(float value) | 
|---|
| 134 |                 { this->setAdditiveModifier(ModifierType::Acceleration, value); } | 
|---|
| 135 |             /** | 
|---|
| 136 |             @brief Set the factor by which this pickup multiplies the acceleration. | 
|---|
| 137 |             @param value Factor by which to multiply acceleration. | 
|---|
| 138 |             */ | 
|---|
| 139 |             inline void setMultiplicativeAcceleration(float value) | 
|---|
| 140 |                 { this->setMultiplicativeModifier(ModifierType::Acceleration, value); } | 
|---|
| 141 |  | 
|---|
| 142 |             //TODO: Make private? | 
|---|
| 143 |             void timerCallback(Pawn* pawn);     //!< Method called when the timer runs out. | 
|---|
| 144 |         private: | 
|---|
| 145 |             float getAdditiveModifier(ModifierType::Value type) const;               //!< Get the additive modifier for a given ModifierType. | 
|---|
| 146 |             float getMultiplicativeModifier(ModifierType::Value type) const;         //!< Get the multiplicative modifier for a given ModifierType. | 
|---|
| 147 |             void setAdditiveModifier(ModifierType::Value type, float value);         //!< Set the additive modifier for a given ModifierType. | 
|---|
| 148 |             void setMultiplicativeModifier(ModifierType::Value type, float value);   //!< Set the multiplicative modifier for a given ModifierType | 
|---|
| 149 |  | 
|---|
| 150 |             std::map<ModifierType::Value, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType. | 
|---|
| 151 |             std::map<ModifierType::Value, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType. | 
|---|
| 152 |  | 
|---|
| 153 |             float duration_;                                                         //!< Duration of this pickup's effect (0 for unlimited). | 
|---|
| 154 |             Timer timer_;                                                            //!< Timer used if the pickup's effect has a time limit. | 
|---|
| 155 |     }; | 
|---|
| 156 | } | 
|---|
| 157 |  | 
|---|
| 158 | #endif /* _ModifierPickup_H__ */ | 
|---|