[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 | |
---|
| 29 | #ifndef _PickupRepresentation_H__ |
---|
| 30 | #define _PickupRepresentation_H__ |
---|
| 31 | |
---|
| 32 | #include "PickupPrereqs.h" |
---|
| 33 | |
---|
| 34 | #include "core/XMLPort.h" |
---|
[6475] | 35 | #include "interfaces/Pickupable.h" |
---|
[6474] | 36 | #include "pickup/PickupIdentifier.h" |
---|
| 37 | #include "worldentities/StaticEntity.h" |
---|
[6475] | 38 | #include "PickupSpawner.h" |
---|
[6474] | 39 | |
---|
[6475] | 40 | #include "core/BaseObject.h" |
---|
| 41 | |
---|
[6474] | 42 | namespace orxonox |
---|
| 43 | { |
---|
| 44 | |
---|
[6475] | 45 | /** |
---|
| 46 | @brief |
---|
| 47 | 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. |
---|
| 48 | They are created through XML and are registered with the PickupManager. |
---|
| 49 | */ |
---|
[6474] | 50 | class _PickupExport PickupRepresentation : public BaseObject |
---|
| 51 | { |
---|
| 52 | |
---|
| 53 | public: |
---|
[6475] | 54 | PickupRepresentation(); //!< Constructor |
---|
| 55 | PickupRepresentation(BaseObject* creator); //!< Default constructor. |
---|
| 56 | virtual ~PickupRepresentation(); //!< Destructor. |
---|
[6474] | 57 | |
---|
| 58 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 59 | |
---|
[6475] | 60 | /** |
---|
| 61 | @brief Set the name of the Pickupable represented by this PickupRepresentation. |
---|
| 62 | @param name The name. |
---|
| 63 | */ |
---|
[6474] | 64 | inline void setName(const std::string& name) |
---|
| 65 | { this->name_ = name; } |
---|
[6475] | 66 | /** |
---|
| 67 | @brief Set the description of the Pickupable represented by this PickupRepresentation. |
---|
| 68 | @param description The Description. |
---|
| 69 | */ |
---|
[6474] | 70 | inline void setDescription(const std::string& description) |
---|
| 71 | { this->description_ = description; } |
---|
[6475] | 72 | /** |
---|
| 73 | @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation. |
---|
| 74 | The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. |
---|
| 75 | @param spawnerTemplate The name of the template. |
---|
| 76 | */ |
---|
[6474] | 77 | inline void setSpawnerTemplate(const std::string& spawnerTemplate) |
---|
| 78 | { this->spawnerTemplate_ = spawnerTemplate; } |
---|
[6475] | 79 | /** |
---|
| 80 | @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. |
---|
| 81 | 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. |
---|
| 82 | @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. |
---|
| 83 | */ |
---|
[6474] | 84 | inline void setSpawnerRepresentation(StaticEntity* representation) |
---|
| 85 | { this->spawnerRepresentation_ = representation; } |
---|
[6475] | 86 | /** |
---|
| 87 | @brief Set the Pickupable that is represented by this PickupRepresentation. |
---|
| 88 | @param pickup A pointer to the Pickupable. |
---|
| 89 | */ |
---|
[6474] | 90 | inline void setPickup(Pickupable* pickup) |
---|
| 91 | { this->pickup_ = pickup; } |
---|
| 92 | |
---|
[6475] | 93 | /** |
---|
| 94 | @brief Get the name of the Pickupable represented by this PickupRepresentation. |
---|
| 95 | @return Returns the name. |
---|
| 96 | */ |
---|
[6474] | 97 | inline const std::string& getName(void) |
---|
| 98 | { return this->name_; } |
---|
[6475] | 99 | /** |
---|
| 100 | @brief Get the description of the Pickupable represented by this PickupRepresentation. |
---|
| 101 | @return Returns the description. |
---|
| 102 | */ |
---|
[6474] | 103 | inline const std::string& getDescription(void) |
---|
| 104 | { return this->description_; } |
---|
[6475] | 105 | /** |
---|
| 106 | @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation. |
---|
| 107 | @return Returns the name of the spawnerTemplate. |
---|
| 108 | */ |
---|
[6474] | 109 | inline const std::string& getSpawnerTemplate(void) |
---|
| 110 | { return this->spawnerTemplate_; } |
---|
[6475] | 111 | /** |
---|
| 112 | @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. |
---|
| 113 | @param index The index. |
---|
| 114 | @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL. |
---|
| 115 | */ |
---|
[6474] | 116 | inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) |
---|
| 117 | { if(index == 0) return this->spawnerRepresentation_; return NULL; } |
---|
[6475] | 118 | /** |
---|
| 119 | @brief Get the Pickupable represented by this PickupRepresentation. |
---|
| 120 | @param index The index. |
---|
| 121 | @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL. |
---|
| 122 | */ |
---|
[6474] | 123 | inline const Pickupable* getPickup(unsigned int index) |
---|
| 124 | { if(index == 0) return this->pickup_; return NULL; } |
---|
| 125 | |
---|
[6475] | 126 | StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner. |
---|
[6474] | 127 | |
---|
| 128 | private: |
---|
[6475] | 129 | void initialize(void); //!< Initializes the member variables of this PickupRepresentation. |
---|
| 130 | StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner. |
---|
[6474] | 131 | |
---|
[6475] | 132 | std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation. |
---|
| 133 | std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation. |
---|
| 134 | std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. |
---|
| 135 | StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. |
---|
[6474] | 136 | |
---|
[6475] | 137 | Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation. |
---|
[6474] | 138 | |
---|
| 139 | }; |
---|
| 140 | |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | #endif // _PickupRepresentation_H__ |
---|