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