Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/PickupRepresentation.h @ 7539

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

Some cleanup in PickupManager.

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