Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx/src/modules/pickup/PickupRepresentation.h @ 8748

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

Pickups module is now (from what I can tell after some basic testing) fully functional over the network.
However it's still a little messy, needs some cleanup and documentation.
I introduced a new class, the PickupListener, which allows reacting to pickups becoming used, unused, picked up or dropped.

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