| [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 |  | 
|---|
 | 46 | namespace orxonox | 
|---|
 | 47 | { | 
|---|
 | 48 |     /** | 
|---|
| [5947] | 49 |     @brief Class for a (temporary) modifier effect. | 
|---|
 | 50 |     @author Daniel 'Huty' Haggenmueller | 
|---|
| [2917] | 51 |     */ | 
|---|
| [5947] | 52 |     //TODO: More elaborate comments. | 
|---|
| [2917] | 53 |     class _OrxonoxExport ModifierPickup : public PassiveItem | 
|---|
 | 54 |     { | 
|---|
| [5947] | 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 |  | 
|---|
| [5947] | 61 |             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file. | 
|---|
| [2917] | 62 |  | 
|---|
| [5947] | 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 |  | 
|---|
| [5947] | 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 |  | 
|---|
| [5947] | 70 |             /** | 
|---|
| [2917] | 71 |             @brief Get the duration of this pickup. | 
|---|
 | 72 |             @return Returns how long the effect holds on. | 
|---|
| [5947] | 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. | 
|---|
| [5947] | 79 |             */ | 
|---|
 | 80 |             //TODO: Better be private? | 
|---|
 | 81 |             inline void setDuration(float duration) | 
|---|
 | 82 |                 { this->duration_ = duration; } | 
|---|
| [2917] | 83 |  | 
|---|
| [5947] | 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. | 
|---|
| [5947] | 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. | 
|---|
| [5947] | 99 |             */ | 
|---|
 | 100 |             inline float getMultiplicativeDamage() const | 
|---|
 | 101 |                 { return this->getMultiplicativeModifier(ModifierType::Damage); } | 
|---|
| [2917] | 102 |  | 
|---|
| [5947] | 103 |             /** | 
|---|
| [2917] | 104 |             @brief Set the amount of damage this pickup adds. | 
|---|
 | 105 |             @param value How much damage this pickup adds. | 
|---|
| [5947] | 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. | 
|---|
| [5947] | 112 |             */ | 
|---|
 | 113 |             inline void setMultiplicativeDamage(float value) | 
|---|
 | 114 |                 { this->setMultiplicativeModifier(ModifierType::Damage, value); } | 
|---|
| [2917] | 115 |  | 
|---|
| [5947] | 116 |             /** | 
|---|
| [2917] | 117 |             @brief Get the amount of acceleration this pickup adds. | 
|---|
 | 118 |             @return Returns how much acceleration this pickup adds. | 
|---|
| [5947] | 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. | 
|---|
| [5947] | 125 |             */ | 
|---|
 | 126 |             inline float getMultiplicativeAcceleration() const | 
|---|
 | 127 |                 { return this->getMultiplicativeModifier(ModifierType::Acceleration); } | 
|---|
| [2917] | 128 |  | 
|---|
| [5947] | 129 |             /** | 
|---|
| [2917] | 130 |             @brief Set the amount of acceleration this pickup adds. | 
|---|
 | 131 |             @param value How much acceleration this pickup adds. | 
|---|
| [5947] | 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. | 
|---|
| [5947] | 138 |             */ | 
|---|
 | 139 |             inline void setMultiplicativeAcceleration(float value) | 
|---|
 | 140 |                 { this->setMultiplicativeModifier(ModifierType::Acceleration, value); } | 
|---|
| [2917] | 141 |  | 
|---|
| [5947] | 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 | 
|---|
| [2917] | 149 |  | 
|---|
| [5947] | 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. | 
|---|
| [2917] | 152 |  | 
|---|
| [5947] | 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. | 
|---|
| [2917] | 155 |     }; | 
|---|
 | 156 | } | 
|---|
 | 157 |  | 
|---|
 | 158 | #endif /* _ModifierPickup_H__ */ | 
|---|