| [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 BaseItem (base-class for items/pickups). | 
|---|
 | 32 | */ | 
|---|
 | 33 |  | 
|---|
 | 34 | #ifndef _BaseItem_H__ | 
|---|
 | 35 | #define _BaseItem_H__ | 
|---|
 | 36 |  | 
|---|
 | 37 | #include "OrxonoxPrereqs.h" | 
|---|
 | 38 |  | 
|---|
| [3196] | 39 | #include <string> | 
|---|
| [2917] | 40 | #include "core/BaseObject.h" | 
|---|
 | 41 |  | 
|---|
| [2972] | 42 | // tolua_begin | 
|---|
| [2917] | 43 | namespace orxonox | 
|---|
 | 44 | { | 
|---|
 | 45 |     /** | 
|---|
| [5947] | 46 |     @brief | 
|---|
 | 47 |         Base class for all items/pickups. | 
|---|
| [2917] | 48 |  | 
|---|
| [5947] | 49 |         Provides common methods to be used in derived classes. | 
|---|
 | 50 |     @author | 
|---|
 | 51 |         Daniel 'Huty' Haggenmueller | 
|---|
| [2917] | 52 |     */ | 
|---|
| [3370] | 53 |     class _OrxonoxExport BaseItem : public BaseObject | 
|---|
| [2917] | 54 |     { | 
|---|
| [2972] | 55 | // tolua_end | 
|---|
| [5947] | 56 |         public: | 
|---|
 | 57 |             BaseItem(BaseObject* creator); | 
|---|
 | 58 |             virtual ~BaseItem(); | 
|---|
| [2917] | 59 |  | 
|---|
| [5947] | 60 |             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< XMLPort | 
|---|
| [2972] | 61 |  | 
|---|
| [5947] | 62 |             /** | 
|---|
| [2917] | 63 |             @brief Checks how many instances of this item can be carried at a time. | 
|---|
 | 64 |             @return How many of this item can be carried. | 
|---|
| [5947] | 65 |             */ | 
|---|
 | 66 |             virtual int getMaxCarryAmount() const //TODO: Maybe, better to just be virtual. | 
|---|
 | 67 |                 { return BaseItem::MAX_CARRY_AMOUNT; } | 
|---|
| [2917] | 68 |  | 
|---|
| [5947] | 69 |             //TODO: Need to be public? | 
|---|
 | 70 |             bool addTo(Pawn* pawn);             //!< Add the item to a pawn. | 
|---|
 | 71 |             bool removeFrom(Pawn* pawn);        //!< Removes the item from a pawn. | 
|---|
 | 72 |             /** | 
|---|
| [2917] | 73 |             @brief | 
|---|
 | 74 |                 Method invoked when the item gets picked up. | 
|---|
 | 75 |  | 
|---|
 | 76 |                 Has to be overridden for an item to work, | 
|---|
 | 77 |                 should contain a call to addTo(). | 
|---|
 | 78 |  | 
|---|
 | 79 |             @param pawn Pawn who picks up the item. | 
|---|
 | 80 |             @return Returns whether the pawn was able to pick up the item. | 
|---|
| [5947] | 81 |             */ | 
|---|
 | 82 |             virtual bool pickedUp(Pawn* pawn) //TODO: Maybe better to be just virtual. | 
|---|
 | 83 |                 { return false; } | 
|---|
 | 84 |             /** | 
|---|
| [2917] | 85 |             @brief | 
|---|
 | 86 |                 Method invoked when the item is dropped from a player. | 
|---|
 | 87 |  | 
|---|
 | 88 |                 Should be overridden by derived classes, | 
|---|
 | 89 |                 should also contain a call to removeFrom(). | 
|---|
 | 90 |  | 
|---|
 | 91 |             @param pawn Pawn which dropped the item. | 
|---|
 | 92 |             @return Returns whether the item was able to get dropped by the pawn. | 
|---|
| [5947] | 93 |             */ | 
|---|
 | 94 |             virtual bool dropped(Pawn* pawn) | 
|---|
 | 95 |                 { return false; } | 
|---|
| [2917] | 96 |  | 
|---|
| [5947] | 97 |             /** | 
|---|
| [2917] | 98 |             @brief Gets the current owner of the pickup. | 
|---|
 | 99 |             @return Returns the current owner. | 
|---|
| [5947] | 100 |             */ | 
|---|
 | 101 |             inline Pawn* getOwner() const | 
|---|
 | 102 |                 { return this->owner_; } | 
|---|
 | 103 |             /** | 
|---|
| [2917] | 104 |             @brief Sets the owner of the pickup. | 
|---|
 | 105 |             @param owner New owner for the pickup. | 
|---|
| [5947] | 106 |             */ | 
|---|
 | 107 |             inline void setOwner(Pawn* owner) | 
|---|
 | 108 |                 { this->owner_ = owner; } | 
|---|
| [2917] | 109 |  | 
|---|
| [5947] | 110 |             /** | 
|---|
| [2917] | 111 |             @brief Gets the pickupIdentifier of the item. | 
|---|
 | 112 |             @return Returns the pickupIdentifier of the item. | 
|---|
 | 113 |             @see pickupIdentifier_ | 
|---|
| [5947] | 114 |             */ | 
|---|
 | 115 |             inline const std::string& getPickupIdentifier() const | 
|---|
 | 116 |                 { return this->pickupIdentifier_; } | 
|---|
 | 117 |             /** | 
|---|
| [2917] | 118 |             @brief Sets the pickupIdentifier for the item. | 
|---|
 | 119 |             @param identifier New pickupIdentifier for the item. | 
|---|
 | 120 |             @see pickupIdentifier_ | 
|---|
| [5947] | 121 |             */ | 
|---|
 | 122 |             //TODO: Needs to be public? | 
|---|
 | 123 |             inline void setPickupIdentifier(const std::string& identifier) | 
|---|
 | 124 |                 { this->pickupIdentifier_ = identifier; } | 
|---|
| [2972] | 125 |  | 
|---|
| [5947] | 126 |             // GUI stuff | 
|---|
 | 127 |             //TODO: Comment. Maybe seperate GUI from Pickup, e.g. ItemDescription... | 
|---|
 | 128 |             virtual const std::string& getGUIText() const; // tolua_export | 
|---|
 | 129 |             inline void setGUIText(const std::string& text) | 
|---|
 | 130 |                 { this->guiText_ = text; } | 
|---|
| [2972] | 131 |  | 
|---|
| [5947] | 132 |             virtual const std::string& getGUIImage() const | 
|---|
 | 133 |                 { return this->guiImage_; } | 
|---|
 | 134 |             inline void setGUIImage(const std::string& image) | 
|---|
 | 135 |                 { this->guiImage_ = image; } | 
|---|
 | 136 |         private: | 
|---|
 | 137 |             static const int MAX_CARRY_AMOUNT = 1; | 
|---|
| [2917] | 138 |  | 
|---|
| [5947] | 139 |             Pawn* owner_;   //!< The current owner of the item. | 
|---|
 | 140 |  | 
|---|
 | 141 |             /** | 
|---|
| [2917] | 142 |             @brief | 
|---|
 | 143 |                 The pickupIdentifier of the item.. | 
|---|
 | 144 |  | 
|---|
 | 145 |                 Usually set to the template name used by a PickupSpawner, | 
|---|
 | 146 |                 used to index items in the PickupCollection. | 
|---|
| [5947] | 147 |             */ | 
|---|
 | 148 |             std::string pickupIdentifier_; //TODO: Remove, when always just this->getName(). | 
|---|
| [2972] | 149 |  | 
|---|
| [5947] | 150 |             //TODO: Comment. | 
|---|
 | 151 |             std::string guiText_; | 
|---|
 | 152 |             std::string guiImage_; | 
|---|
| [3001] | 153 |     }; // tolua_export | 
|---|
 | 154 | } // tolua_export | 
|---|
| [2917] | 155 |  | 
|---|
 | 156 | #endif /* _BaseItem_H__ */ | 
|---|