[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 PickupRepresentation.h |
---|
| 31 | @brief Definition of the PickupRepresentation class. |
---|
[7456] | 32 | @ingroup Pickup |
---|
[6540] | 33 | */ |
---|
| 34 | |
---|
[6474] | 35 | #ifndef _PickupRepresentation_H__ |
---|
| 36 | #define _PickupRepresentation_H__ |
---|
| 37 | |
---|
| 38 | #include "PickupPrereqs.h" |
---|
| 39 | |
---|
| 40 | #include "core/XMLPort.h" |
---|
[6475] | 41 | #include "interfaces/Pickupable.h" |
---|
[6474] | 42 | #include "pickup/PickupIdentifier.h" |
---|
| 43 | #include "worldentities/StaticEntity.h" |
---|
[6475] | 44 | #include "PickupSpawner.h" |
---|
[6474] | 45 | |
---|
[6475] | 46 | #include "core/BaseObject.h" |
---|
| 47 | |
---|
[6711] | 48 | namespace orxonox // tolua_export |
---|
| 49 | { // tolua_export |
---|
[6474] | 50 | |
---|
[6475] | 51 | /** |
---|
| 52 | @brief |
---|
| 53 | The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like. |
---|
| 54 | They are created through XML and are registered with the PickupManager. |
---|
| 55 | */ |
---|
[6711] | 56 | class _PickupExport PickupRepresentation // tolua_export |
---|
| 57 | : public BaseObject |
---|
| 58 | { // tolua_export |
---|
[7163] | 59 | |
---|
[6474] | 60 | public: |
---|
[6475] | 61 | PickupRepresentation(); //!< Constructor |
---|
| 62 | PickupRepresentation(BaseObject* creator); //!< Default constructor. |
---|
| 63 | virtual ~PickupRepresentation(); //!< Destructor. |
---|
[7163] | 64 | |
---|
[6474] | 65 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[7163] | 66 | |
---|
[6475] | 67 | /** |
---|
| 68 | @brief Set the name of the Pickupable represented by this PickupRepresentation. |
---|
| 69 | @param name The name. |
---|
| 70 | */ |
---|
[6711] | 71 | inline void setPickupName(const std::string& name) |
---|
[6474] | 72 | { this->name_ = name; } |
---|
[6475] | 73 | /** |
---|
| 74 | @brief Set the description of the Pickupable represented by this PickupRepresentation. |
---|
| 75 | @param description The Description. |
---|
| 76 | */ |
---|
[6711] | 77 | inline void setPickupDescription(const std::string& description) |
---|
[6474] | 78 | { this->description_ = description; } |
---|
[6475] | 79 | /** |
---|
| 80 | @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation. |
---|
| 81 | The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. |
---|
| 82 | @param spawnerTemplate The name of the template. |
---|
| 83 | */ |
---|
[6474] | 84 | inline void setSpawnerTemplate(const std::string& spawnerTemplate) |
---|
| 85 | { this->spawnerTemplate_ = spawnerTemplate; } |
---|
[6475] | 86 | /** |
---|
| 87 | @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. |
---|
| 88 | This will be set by the spawnerTemplate. Setting it when creating the PickupRepresentation without creating a template and specifying its name will be futile, because through the course of the game many PickupSpawners for one specific pickup type may have to be created, thus the StaticEntity that is the spawnerRepresentation has to be generated (with the template) for every new PickupSpawner spawning the Pickupable represented by this PickupRepresentation. The spawnerRepresentation that is set here, however can only be used once. |
---|
| 89 | @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. |
---|
| 90 | */ |
---|
[6474] | 91 | inline void setSpawnerRepresentation(StaticEntity* representation) |
---|
| 92 | { this->spawnerRepresentation_ = representation; } |
---|
[6475] | 93 | /** |
---|
[6711] | 94 | @brief Set the image representing the pickup in the PickupInventory. |
---|
| 95 | @param image A string with the name of the image representing the pickup. |
---|
| 96 | */ |
---|
| 97 | inline void setInventoryRepresentation(const std::string& image) |
---|
| 98 | { this->inventoryRepresentation_ = image; } |
---|
| 99 | /** |
---|
[6475] | 100 | @brief Set the Pickupable that is represented by this PickupRepresentation. |
---|
| 101 | @param pickup A pointer to the Pickupable. |
---|
| 102 | */ |
---|
[6474] | 103 | inline void setPickup(Pickupable* pickup) |
---|
| 104 | { this->pickup_ = pickup; } |
---|
[7163] | 105 | |
---|
[6475] | 106 | /** |
---|
| 107 | @brief Get the name of the Pickupable represented by this PickupRepresentation. |
---|
| 108 | @return Returns the name. |
---|
| 109 | */ |
---|
[6711] | 110 | inline const std::string& getPickupName(void) { return this->name_; } // tolua_export |
---|
[6475] | 111 | /** |
---|
| 112 | @brief Get the description of the Pickupable represented by this PickupRepresentation. |
---|
| 113 | @return Returns the description. |
---|
| 114 | */ |
---|
[6711] | 115 | inline const std::string& getPickupDescription(void) { return this->description_; } // tolua_export |
---|
[6475] | 116 | /** |
---|
| 117 | @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation. |
---|
| 118 | @return Returns the name of the spawnerTemplate. |
---|
| 119 | */ |
---|
[6474] | 120 | inline const std::string& getSpawnerTemplate(void) |
---|
| 121 | { return this->spawnerTemplate_; } |
---|
[6475] | 122 | /** |
---|
| 123 | @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. |
---|
| 124 | @param index The index. |
---|
| 125 | @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL. |
---|
| 126 | */ |
---|
[6474] | 127 | inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) |
---|
| 128 | { if(index == 0) return this->spawnerRepresentation_; return NULL; } |
---|
[6475] | 129 | /** |
---|
[6711] | 130 | @brief Get the name of the image representing the pickup in the PickupInventory. |
---|
| 131 | @return Returns the name of the image as a string. |
---|
| 132 | */ |
---|
| 133 | inline const std::string& getInventoryRepresentation(void) { return this->inventoryRepresentation_; } // tolua_export |
---|
| 134 | /** |
---|
[6475] | 135 | @brief Get the Pickupable represented by this PickupRepresentation. |
---|
| 136 | @param index The index. |
---|
| 137 | @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL. |
---|
| 138 | */ |
---|
[6474] | 139 | inline const Pickupable* getPickup(unsigned int index) |
---|
| 140 | { if(index == 0) return this->pickup_; return NULL; } |
---|
[7163] | 141 | |
---|
[6475] | 142 | StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner. |
---|
[7163] | 143 | |
---|
[6474] | 144 | private: |
---|
[6475] | 145 | void initialize(void); //!< Initializes the member variables of this PickupRepresentation. |
---|
| 146 | StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner. |
---|
[7163] | 147 | |
---|
[6475] | 148 | std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation. |
---|
| 149 | std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation. |
---|
| 150 | std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. |
---|
| 151 | StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. |
---|
[7163] | 152 | std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. |
---|
| 153 | |
---|
[6475] | 154 | Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation. |
---|
[7163] | 155 | |
---|
[6711] | 156 | }; // tolua_export |
---|
[6474] | 157 | |
---|
[6711] | 158 | } // tolua_export |
---|
[7163] | 159 | |
---|
[6474] | 160 | #endif // _PickupRepresentation_H__ |
---|