[6474] | 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 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[6540] | 29 | /** |
---|
| 30 | @file Pickup.h |
---|
| 31 | @brief Declaration of the Pickup class. |
---|
[7456] | 32 | @ingroup Pickup |
---|
[6540] | 33 | */ |
---|
| 34 | |
---|
[6474] | 35 | #ifndef _Pickup_H__ |
---|
[6475] | 36 | #define _Pickup_H__ |
---|
[6474] | 37 | |
---|
| 38 | #include "pickup/PickupPrereqs.h" |
---|
| 39 | |
---|
| 40 | #include "core/BaseObject.h" |
---|
| 41 | #include "core/XMLPort.h" |
---|
| 42 | |
---|
[7163] | 43 | #include "CollectiblePickup.h" |
---|
[6475] | 44 | |
---|
[6709] | 45 | #include "tools/Timer.h" |
---|
| 46 | |
---|
[6474] | 47 | namespace orxonox |
---|
| 48 | { |
---|
| 49 | |
---|
[7533] | 50 | /** |
---|
| 51 | @brief |
---|
| 52 | Enum for the @ref orxonox::Pickup "Pickup" activation type. |
---|
| 53 | |
---|
| 54 | @ingroup Pickup |
---|
| 55 | */ |
---|
[6474] | 56 | namespace pickupActivationType |
---|
| 57 | { |
---|
| 58 | enum Value |
---|
| 59 | { |
---|
[7494] | 60 | immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup. |
---|
| 61 | onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence. |
---|
[6474] | 62 | }; |
---|
| 63 | } |
---|
[6709] | 64 | |
---|
[7533] | 65 | /** |
---|
| 66 | @brief |
---|
| 67 | Enum for the @ref orxonox::Pickup "Pickup" duration type. |
---|
| 68 | |
---|
| 69 | @ingroup Pickup |
---|
| 70 | */ |
---|
[6474] | 71 | namespace pickupDurationType |
---|
| 72 | { |
---|
| 73 | enum Value |
---|
| 74 | { |
---|
[7494] | 75 | once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant. |
---|
| 76 | continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan. |
---|
[6474] | 77 | }; |
---|
| 78 | } |
---|
[6709] | 79 | |
---|
[6475] | 80 | /** |
---|
| 81 | @brief |
---|
[7494] | 82 | The Pickup class offers (useful) base functionality for a wide range of pickups. |
---|
| 83 | |
---|
| 84 | Pickups ingeriting from this class can choose an activation type and a duration type. |
---|
| 85 | - The <b>activation type</b> deals with what happens to the Pickup as soon as it is picked up. It can either be set to <em>immediate</em>, which means that the Pickup is activated/used immediately upon being picked up. Or to <em>onUse</em>, which means, that the Pickup will be activated/used if some outside entity (most commonly the player through the PickupInventory) decides to use it. |
---|
| 86 | - The <b>duration type</b> deals with whether the Pickup has a continuous effect or whether its effect is focused on a singular instant. It can either be set to <em>once</em>, which means, that the Pickup just has an effect (at a singular instant in time) and is done once that effect has been applied. Or to <em>continuous</em>, which means that the effect of the Pickup unfolds over some timespan. |
---|
| 87 | |
---|
| 88 | If it were not an abstract class it could for example be used as follows in XML. |
---|
| 89 | @code |
---|
| 90 | <Pickup activationType="onUse" durationType="continuous" /> |
---|
| 91 | @endcode |
---|
| 92 | In reality you can (naturally) use the parameters <b>activation type</b> and <b>duration type</b> in any pickup inheriting from Pickup, unless the pickup already specifies one (or both) of the parameters. |
---|
| 93 | |
---|
[6475] | 94 | @author |
---|
| 95 | Damian 'Mozork' Frick |
---|
[7533] | 96 | |
---|
| 97 | @ingroup Pickup |
---|
[6475] | 98 | */ |
---|
[7163] | 99 | class _PickupExport Pickup : public CollectiblePickup, public BaseObject |
---|
[6474] | 100 | { |
---|
[6709] | 101 | |
---|
[7163] | 102 | public: |
---|
[6540] | 103 | Pickup(BaseObject* creator); //!< Constructor. |
---|
[6475] | 104 | virtual ~Pickup(); //!< Destructor. |
---|
[6709] | 105 | |
---|
[6474] | 106 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[6709] | 107 | |
---|
[6474] | 108 | /** |
---|
[7494] | 109 | @brief Get the activation type of the Pickup. |
---|
| 110 | @return Returns the activation type of the Pickup. |
---|
[6474] | 111 | */ |
---|
| 112 | inline pickupActivationType::Value getActivationTypeDirect(void) |
---|
| 113 | { return this->activationType_; } |
---|
| 114 | /** |
---|
[7494] | 115 | @brief Get the duration type of the Pickup. |
---|
| 116 | @return Returns the duration type of the Pickup. |
---|
[6474] | 117 | */ |
---|
| 118 | inline pickupDurationType::Value getDurationTypeDirect(void) |
---|
| 119 | { return this->durationType_; } |
---|
[6709] | 120 | |
---|
[7494] | 121 | const std::string& getActivationType(void); //!< Get the activation type of the Pickup. |
---|
| 122 | const std::string& getDurationType(void); //!< Get the duration type of the Pickup. |
---|
[6709] | 123 | |
---|
[6475] | 124 | /** |
---|
| 125 | @brief Get whether the activation type is 'immediate'. |
---|
| 126 | @return Returns true if the activation type is 'immediate'. |
---|
| 127 | */ |
---|
[6474] | 128 | inline bool isImmediate(void) |
---|
| 129 | { return this->getActivationTypeDirect() == pickupActivationType::immediate; } |
---|
[6475] | 130 | /** |
---|
| 131 | @brief Get whether the activation type is 'onUse'. |
---|
| 132 | @return Returns true if the activation type is 'onUse'. |
---|
| 133 | */ |
---|
[6474] | 134 | inline bool isOnUse(void) |
---|
| 135 | { return this->getActivationTypeDirect() == pickupActivationType::onUse; } |
---|
[6475] | 136 | /** |
---|
| 137 | @brief Get whether the duration type is 'once'. |
---|
| 138 | @return Returns true if the duration type is 'once'. |
---|
| 139 | */ |
---|
[6474] | 140 | inline bool isOnce(void) |
---|
| 141 | { return this->getDurationTypeDirect() == pickupDurationType::once; } |
---|
[6475] | 142 | /** |
---|
| 143 | @brief Get whether the duration type is 'continuous'. |
---|
| 144 | @return Returns true if the duration type is 'continuous'. |
---|
| 145 | */ |
---|
[6474] | 146 | inline bool isContinuous(void) |
---|
| 147 | { return this->getDurationTypeDirect() == pickupDurationType::continuous; } |
---|
[6709] | 148 | |
---|
[6521] | 149 | virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around. |
---|
[6709] | 150 | |
---|
[7494] | 151 | virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the OrxonoxClass. |
---|
[6709] | 152 | |
---|
[6474] | 153 | protected: |
---|
| 154 | void initializeIdentifier(void); |
---|
[6709] | 155 | |
---|
[6540] | 156 | virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. |
---|
[6709] | 157 | |
---|
[6728] | 158 | /** |
---|
[7494] | 159 | @brief Set the activation type of the Pickup. |
---|
| 160 | @param type The activation type of the Pickup. |
---|
[6474] | 161 | */ |
---|
| 162 | inline void setActivationTypeDirect(pickupActivationType::Value type) |
---|
| 163 | { this->activationType_ = type; } |
---|
| 164 | /** |
---|
[7494] | 165 | @brief Set the duration type of the Pickup. |
---|
| 166 | @param type The duration type of the Pickup. |
---|
[6474] | 167 | */ |
---|
| 168 | inline void setDurationTypeDirect(pickupDurationType::Value type) |
---|
| 169 | { this->durationType_ = type; } |
---|
[6709] | 170 | |
---|
[7494] | 171 | void setActivationType(const std::string& type); //!< Set the activation type of the Pickup. |
---|
| 172 | void setDurationType(const std::string& type); //!< Set the duration type of the Pickup. |
---|
[6709] | 173 | |
---|
[6474] | 174 | private: |
---|
[6475] | 175 | void initialize(void); //!< Initializes the member variables. |
---|
[7163] | 176 | |
---|
[6474] | 177 | pickupActivationType::Value activationType_; //!< The activation type of the Pickup. |
---|
[7494] | 178 | pickupDurationType::Value durationType_; //!< The duration type of the Pickup. |
---|
[6709] | 179 | |
---|
[6728] | 180 | //! Strings for the activation and duration types. |
---|
[6474] | 181 | static const std::string activationTypeImmediate_s; |
---|
| 182 | static const std::string activationTypeOnUse_s; |
---|
| 183 | static const std::string durationTypeOnce_s; |
---|
| 184 | static const std::string durationTypeContinuous_s; |
---|
| 185 | }; |
---|
[6709] | 186 | |
---|
[6474] | 187 | } |
---|
| 188 | #endif // _Pickup_H__ |
---|