[2864] | 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 "PassiveItem.h" |
---|
| 40 | #include "ModifierType.h" |
---|
| 41 | #include "orxonox/tools/timer.h" |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | /** |
---|
| 46 | @brief Class for a (temporary) modifier effect. |
---|
| 47 | @author Daniel 'Huty' Haggenmueller |
---|
| 48 | */ |
---|
| 49 | class _OrxonoxExport ModifierPickup : public PassiveItem |
---|
| 50 | { |
---|
| 51 | public: |
---|
| 52 | ModifierPickup(BaseObject* creator); |
---|
| 53 | virtual ~ModifierPickup(); |
---|
| 54 | |
---|
| 55 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file. |
---|
| 56 | |
---|
| 57 | virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method. |
---|
| 58 | virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method |
---|
| 59 | |
---|
[2900] | 60 | virtual int getMaxCarryAmount(){ return INT_MAX; } //!< Allow the player to carry infinite ModPickups |
---|
| 61 | |
---|
[2864] | 62 | /** |
---|
| 63 | @brief Get the duration of this pickup. |
---|
| 64 | @return Returns how long the effect holds on. |
---|
| 65 | */ |
---|
| 66 | inline float getDuration() const |
---|
| 67 | { return this->duration_; } |
---|
| 68 | /** |
---|
| 69 | @brief Set the duration of this pickup. |
---|
| 70 | @param duration How long the effect should hold. |
---|
| 71 | */ |
---|
| 72 | inline void setDuration(float duration) |
---|
| 73 | { this->duration_ = duration; } |
---|
| 74 | |
---|
| 75 | /** |
---|
| 76 | @brief Get the amount of damage this pickup adds. |
---|
| 77 | @return Returns how much damage this pickup adds. |
---|
| 78 | */ |
---|
| 79 | inline float getAdditiveDamage() const |
---|
| 80 | { return this->getAdditiveModifier(ModifierType::Damage); } |
---|
| 81 | /** |
---|
| 82 | @brief Get the factor by which this pickup multiplies the damage. |
---|
| 83 | @return Returns the factor by which to multiply damage. |
---|
| 84 | */ |
---|
| 85 | inline float getMultiplicativeDamage() const |
---|
| 86 | { return this->getMultiplicativeModifier(ModifierType::Damage); } |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | @brief Set the amount of damage this pickup adds. |
---|
| 90 | @param value How much damage this pickup adds. |
---|
| 91 | */ |
---|
| 92 | inline void setAdditiveDamage(float value) |
---|
| 93 | { this->setAdditiveModifier(ModifierType::Damage, value); } |
---|
| 94 | /** |
---|
| 95 | @brief Set the factor by which this pickup multiplies the damage. |
---|
| 96 | @param value Factor by which to multiply damage. |
---|
| 97 | */ |
---|
| 98 | inline void setMultiplicativeDamage(float value) |
---|
| 99 | { this->setMultiplicativeModifier(ModifierType::Damage, value); } |
---|
| 100 | |
---|
[2900] | 101 | /** |
---|
| 102 | @brief Get the amount of acceleration this pickup adds. |
---|
| 103 | @return Returns how much acceleration this pickup adds. |
---|
| 104 | */ |
---|
| 105 | inline float getAdditiveAcceleration() const |
---|
| 106 | { return this->getAdditiveModifier(ModifierType::Acceleration); } |
---|
| 107 | /** |
---|
| 108 | @brief Get the factor by which this pickup multiplies the acceleration. |
---|
| 109 | @return Returns the factor by which to multiply acceleration. |
---|
| 110 | */ |
---|
| 111 | inline float getMultiplicativeAcceleration() const |
---|
| 112 | { return this->getMultiplicativeModifier(ModifierType::Acceleration); } |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | @brief Set the amount of acceleration this pickup adds. |
---|
| 116 | @param value How much acceleration this pickup adds. |
---|
| 117 | */ |
---|
| 118 | inline void setAdditiveAcceleration(float value) |
---|
| 119 | { this->setAdditiveModifier(ModifierType::Acceleration, value); } |
---|
| 120 | /** |
---|
| 121 | @brief Set the factor by which this pickup multiplies the acceleration. |
---|
| 122 | @param value Factor by which to multiply acceleration. |
---|
| 123 | */ |
---|
| 124 | inline void setMultiplicativeAcceleration(float value) |
---|
| 125 | { this->setMultiplicativeModifier(ModifierType::Acceleration, value); } |
---|
| 126 | |
---|
[2864] | 127 | void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. |
---|
| 128 | private: |
---|
| 129 | float getAdditiveModifier(ModifierType::Enum type) const; //!< Get the additive modifier for a given ModifierType. |
---|
| 130 | float getMultiplicativeModifier(ModifierType::Enum type) const; //!< Get the multiplicative modifier for a given ModifierType. |
---|
| 131 | void setAdditiveModifier(ModifierType::Enum type, float value); //!< Set the additive modifier for a given ModifierType. |
---|
| 132 | void setMultiplicativeModifier(ModifierType::Enum type, float value); //!< Set the multiplicative modifier for a given ModifierType |
---|
| 133 | |
---|
| 134 | std::map<ModifierType::Enum, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType. |
---|
| 135 | std::map<ModifierType::Enum, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType. |
---|
| 136 | |
---|
| 137 | float duration_; //!< Duration of this pickup's effect (0 for unlimited). |
---|
| 138 | Timer<ModifierPickup> timer_; //!< Timer used if the pickup's effect has a time limit. |
---|
| 139 | }; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | #endif /* _ModifierPickup_H__ */ |
---|