Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates2/src/modules/pickup/PickupRepresentation.h @ 6978

Last change on this file since 6978 was 6540, checked in by dafrick, 15 years ago

Removed some TODO's. Finished up documenting pickup module.

File size: 7.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*/
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
48{
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 : public BaseObject
56    {
57       
58        public:
59            PickupRepresentation(); //!< Constructor
60            PickupRepresentation(BaseObject* creator); //!< Default constructor.
61            virtual ~PickupRepresentation(); //!< Destructor.
62           
63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
64           
65            /**
66            @brief Set the name of the Pickupable represented by this PickupRepresentation.
67            @param name The name.
68            */
69            inline void setName(const std::string& name)
70                { this->name_ = name; }
71            /**
72            @brief Set the description of the Pickupable represented by this PickupRepresentation.
73            @param description The Description.
74            */
75            inline void setDescription(const std::string& description)
76                { this->description_ = description; }
77            /**
78            @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation.
79                   The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
80            @param spawnerTemplate The name of the template.
81            */
82            inline void setSpawnerTemplate(const std::string& spawnerTemplate)
83                { this->spawnerTemplate_ = spawnerTemplate; }
84            /**
85            @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
86                   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.
87            @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
88            */
89            inline void setSpawnerRepresentation(StaticEntity* representation)
90                { this->spawnerRepresentation_ = representation; }
91            /**
92            @brief Set the Pickupable that is represented by this PickupRepresentation.
93            @param pickup A pointer to the Pickupable.
94            */
95            inline void setPickup(Pickupable* pickup)
96                { this->pickup_ = pickup; }
97               
98            /**
99            @brief Get the name of the Pickupable represented by this PickupRepresentation.
100            @return Returns the name.
101            */
102            inline const std::string& getName(void)
103                { return this->name_; }
104            /**
105            @brief Get the description of the Pickupable represented by this PickupRepresentation.
106            @return Returns the description.
107            */
108            inline const std::string& getDescription(void)
109                { return this->description_; }
110            /**
111            @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
112            @return Returns the name of the spawnerTemplate.
113            */
114            inline const std::string& getSpawnerTemplate(void)
115                { return this->spawnerTemplate_; }
116            /**
117            @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
118            @param index The index.
119            @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.
120            */
121            inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
122                { if(index == 0) return this->spawnerRepresentation_; return NULL; }
123            /**
124            @brief Get the Pickupable represented by this PickupRepresentation.
125            @param index The index.
126            @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
127            */
128            inline const Pickupable* getPickup(unsigned int index)
129                { if(index == 0) return this->pickup_; return NULL; }
130               
131            StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
132       
133        private:
134            void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
135            StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
136           
137            std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation.
138            std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation.
139            std::string spawnerTemplate_; //!<  The name of the template of this PickupRepresentation.
140            StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation.
141           
142            Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
143           
144    };
145
146}
147   
148#endif // _PickupRepresentation_H__
Note: See TracBrowser for help on using the repository browser.