Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands3/src/modules/pickup/PickupRepresentation.h @ 7546

Last change on this file since 7546 was 7163, checked in by dafrick, 14 years ago

Merged presentation3 branch into trunk.

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