Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/modules/pickup/PickupRepresentation.h @ 6475

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

Additional documentation, code niceifying and potential bug fixing. Also: Renamed DroppedItem to DroppedPickup.

File size: 7.0 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#ifndef _PickupRepresentation_H__
30#define _PickupRepresentation_H__
31
32#include "PickupPrereqs.h"
33
34#include "core/XMLPort.h"
35#include "interfaces/Pickupable.h"
36#include "pickup/PickupIdentifier.h"
37#include "worldentities/StaticEntity.h"
38#include "PickupSpawner.h"
39
40#include "core/BaseObject.h"
41
42namespace orxonox
43{
44
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    */
50    class _PickupExport PickupRepresentation : public BaseObject
51    {
52       
53        public:
54            PickupRepresentation(); //!< Constructor
55            PickupRepresentation(BaseObject* creator); //!< Default constructor.
56            virtual ~PickupRepresentation(); //!< Destructor.
57           
58            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
59           
60            /**
61            @brief Set the name of the Pickupable represented by this PickupRepresentation.
62            @param name The name.
63            */
64            inline void setName(const std::string& name)
65                { this->name_ = name; }
66            /**
67            @brief Set the description of the Pickupable represented by this PickupRepresentation.
68            @param description The Description.
69            */
70            inline void setDescription(const std::string& description)
71                { this->description_ = description; }
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            */
77            inline void setSpawnerTemplate(const std::string& spawnerTemplate)
78                { this->spawnerTemplate_ = spawnerTemplate; }
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            */
84            inline void setSpawnerRepresentation(StaticEntity* representation)
85                { this->spawnerRepresentation_ = representation; }
86            /**
87            @brief Set the Pickupable that is represented by this PickupRepresentation.
88            @param pickup A pointer to the Pickupable.
89            */
90            inline void setPickup(Pickupable* pickup)
91                { this->pickup_ = pickup; }
92               
93            /**
94            @brief Get the name of the Pickupable represented by this PickupRepresentation.
95            @return Returns the name.
96            */
97            inline const std::string& getName(void)
98                { return this->name_; }
99            /**
100            @brief Get the description of the Pickupable represented by this PickupRepresentation.
101            @return Returns the description.
102            */
103            inline const std::string& getDescription(void)
104                { return this->description_; }
105            /**
106            @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
107            @return Returns the name of the spawnerTemplate.
108            */
109            inline const std::string& getSpawnerTemplate(void)
110                { return this->spawnerTemplate_; }
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            */
116            inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
117                { if(index == 0) return this->spawnerRepresentation_; return NULL; }
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            */
123            inline const Pickupable* getPickup(unsigned int index)
124                { if(index == 0) return this->pickup_; return NULL; }
125               
126            StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
127       
128        private:
129            void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
130            StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
131           
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.
136           
137            Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
138           
139    };
140
141}
142   
143#endif // _PickupRepresentation_H__
Note: See TracBrowser for help on using the repository browser.