[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" |
---|
[7547] | 41 | |
---|
[6475] | 42 | #include "interfaces/Pickupable.h" |
---|
[6474] | 43 | #include "worldentities/StaticEntity.h" |
---|
[7540] | 44 | |
---|
[6475] | 45 | #include "PickupSpawner.h" |
---|
[6474] | 46 | |
---|
[6475] | 47 | #include "core/BaseObject.h" |
---|
[7504] | 48 | #include "network/synchronisable/Synchronisable.h" |
---|
[6475] | 49 | |
---|
[6711] | 50 | namespace orxonox // tolua_export |
---|
| 51 | { // tolua_export |
---|
[6474] | 52 | |
---|
[6475] | 53 | /** |
---|
| 54 | @brief |
---|
[9318] | 55 | The PickupRepresentation class represents a specific pickup type. It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like. |
---|
[7540] | 56 | They are created through XML and are registered with the @ref orxonox::PickupManager "PickupManager". |
---|
[7539] | 57 | |
---|
[7540] | 58 | Creating a PickupRepresentation in XML could look as follows: |
---|
| 59 | @code |
---|
| 60 | <PickupRepresentation |
---|
| 61 | name = "My awesome Pickup" |
---|
| 62 | description = "This is the most awesome Pickup ever to exist." |
---|
| 63 | spawnerTemplate = "awesomePickupRepresentation" |
---|
| 64 | inventoryRepresentation = "AwesomePickup" |
---|
[9318] | 65 | /> |
---|
[7540] | 66 | @endcode |
---|
| 67 | As you might have noticed, there is a parameter called <em>spawnerTemplate</em> and also another parameter called <em>inventoryRepresentation</em>. Let's first explain the second one, <em>inventoryRepresentation</em>. |
---|
| 68 | - The <b>inventoryRepresentation</b> specifies the image that is displayed in the PickupInventory for the specific type of @ref orxonox::Pickupable "Pickupable". More technically, it is the name of an image located in the <code>PickupInventory.imageset</code>, which in turn is located in <code>data_extern/gui/imagesets/</code>. |
---|
[7547] | 69 | - The <b>spawnerTemplate</b> specifies how the type of @ref orxonox::Pickupable "Pickupable" (or more precisely the @ref orxonox::PickupSpawner "PickupSpawner", that spawns that type of @ref orxonox::Pickupable "Pickupable") is displayed ingame. It is a @ref orxonox::Template "Template" defined in XML. The <em>spawnerTemplate</em> can be specified as follows (keep in mind, that the template needs to have been specified before the definition of the PickupRepresentation that uses it). |
---|
[7540] | 70 | @code |
---|
| 71 | <Template name="awesomePickupRepresentation"> |
---|
| 72 | <PickupRepresentation> |
---|
| 73 | <spawner-representation> |
---|
| 74 | <StaticEntity> |
---|
| 75 | <attached> |
---|
| 76 | <!-- Here you can put all the objects which define the look of the spawner. --> |
---|
| 77 | </attached> |
---|
| 78 | </StaticEntity> |
---|
| 79 | </spawner-representation> |
---|
| 80 | </PickupRepresentation> |
---|
| 81 | </Template> |
---|
| 82 | @endcode |
---|
| 83 | |
---|
| 84 | For the purpose of them working over the network, they are synchronised. |
---|
| 85 | |
---|
[7539] | 86 | @author |
---|
| 87 | Damian 'Mozork' Frick |
---|
| 88 | |
---|
| 89 | @ingroup Pickup |
---|
[6475] | 90 | */ |
---|
[6711] | 91 | class _PickupExport PickupRepresentation // tolua_export |
---|
[7504] | 92 | : public BaseObject, public Synchronisable |
---|
[6711] | 93 | { // tolua_export |
---|
[7163] | 94 | |
---|
[6474] | 95 | public: |
---|
[6475] | 96 | PickupRepresentation(); //!< Constructor |
---|
| 97 | PickupRepresentation(BaseObject* creator); //!< Default constructor. |
---|
| 98 | virtual ~PickupRepresentation(); //!< Destructor. |
---|
[7163] | 99 | |
---|
[7540] | 100 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupRepresentation object through XML. |
---|
[7163] | 101 | |
---|
[6475] | 102 | /** |
---|
[7547] | 103 | @brief Get the name of the Pickupable represented by this PickupRepresentation. |
---|
| 104 | @return Returns the name. |
---|
| 105 | */ |
---|
| 106 | inline const std::string& getPickupName(void) const { return this->name_; } // tolua_export |
---|
| 107 | /** |
---|
| 108 | @brief Get the description of the Pickupable represented by this PickupRepresentation. |
---|
| 109 | @return Returns the description. |
---|
| 110 | */ |
---|
| 111 | inline const std::string& getPickupDescription(void) const { return this->description_; } // tolua_export |
---|
| 112 | /** |
---|
| 113 | @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation. |
---|
| 114 | @return Returns the name of the spawnerTemplate. |
---|
| 115 | */ |
---|
| 116 | inline const std::string& getSpawnerTemplate(void) const |
---|
| 117 | { return this->spawnerTemplate_; } |
---|
| 118 | /** |
---|
| 119 | @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. |
---|
| 120 | @param index The index. |
---|
| 121 | @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL. |
---|
| 122 | */ |
---|
| 123 | inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) const |
---|
| 124 | { if(index == 0) return this->spawnerRepresentation_; return NULL; } |
---|
| 125 | /** |
---|
| 126 | @brief Get the name of the image representing the pickup in the PickupInventory. |
---|
| 127 | @return Returns the name of the image as a string. |
---|
| 128 | */ |
---|
| 129 | inline const std::string& getInventoryRepresentation(void) const { return this->inventoryRepresentation_; } // tolua_export |
---|
| 130 | |
---|
[9318] | 131 | virtual void changedName(); |
---|
| 132 | |
---|
[9302] | 133 | StaticEntity* createSpawnerRepresentation(PickupSpawner* spawner); //!< Create a spawnerRepresentation for a specific PickupSpawner. |
---|
[7547] | 134 | |
---|
| 135 | protected: |
---|
| 136 | /** |
---|
[6475] | 137 | @brief Set the name of the Pickupable represented by this PickupRepresentation. |
---|
| 138 | @param name The name. |
---|
| 139 | */ |
---|
[6711] | 140 | inline void setPickupName(const std::string& name) |
---|
[6474] | 141 | { this->name_ = name; } |
---|
[6475] | 142 | /** |
---|
| 143 | @brief Set the description of the Pickupable represented by this PickupRepresentation. |
---|
| 144 | @param description The Description. |
---|
| 145 | */ |
---|
[6711] | 146 | inline void setPickupDescription(const std::string& description) |
---|
[6474] | 147 | { this->description_ = description; } |
---|
[6475] | 148 | /** |
---|
| 149 | @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation. |
---|
| 150 | The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. |
---|
| 151 | @param spawnerTemplate The name of the template. |
---|
| 152 | */ |
---|
[6474] | 153 | inline void setSpawnerTemplate(const std::string& spawnerTemplate) |
---|
| 154 | { this->spawnerTemplate_ = spawnerTemplate; } |
---|
[6475] | 155 | /** |
---|
| 156 | @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. |
---|
| 157 | 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. |
---|
| 158 | @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. |
---|
| 159 | */ |
---|
[9318] | 160 | void setSpawnerRepresentation(StaticEntity* representation); |
---|
| 161 | |
---|
[6475] | 162 | /** |
---|
[6711] | 163 | @brief Set the image representing the pickup in the PickupInventory. |
---|
| 164 | @param image A string with the name of the image representing the pickup. |
---|
| 165 | */ |
---|
| 166 | inline void setInventoryRepresentation(const std::string& image) |
---|
| 167 | { this->inventoryRepresentation_ = image; } |
---|
[7163] | 168 | |
---|
[6474] | 169 | private: |
---|
[6475] | 170 | void initialize(void); //!< Initializes the member variables of this PickupRepresentation. |
---|
| 171 | StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner. |
---|
[7163] | 172 | |
---|
[7540] | 173 | void registerVariables(void); //!< Registers the variables that need to be synchronised. |
---|
[7504] | 174 | |
---|
[6475] | 175 | std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation. |
---|
| 176 | std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation. |
---|
| 177 | std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. |
---|
| 178 | StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. |
---|
[7163] | 179 | std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. |
---|
| 180 | |
---|
[6711] | 181 | }; // tolua_export |
---|
[6474] | 182 | |
---|
[6711] | 183 | } // tolua_export |
---|
[7163] | 184 | |
---|
[6474] | 185 | #endif // _PickupRepresentation_H__ |
---|