Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7108 was 6711, checked in by dafrick, 15 years ago

Merged pickup4 branch back to trunk.

File size: 8.0 KB
RevLine 
[6474]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
[6540]29/**
30    @file PickupRepresentation.h
31    @brief Definition of the PickupRepresentation class.
32*/
33
[6474]34#ifndef _PickupRepresentation_H__
35#define _PickupRepresentation_H__
36
37#include "PickupPrereqs.h"
38
39#include "core/XMLPort.h"
[6475]40#include "interfaces/Pickupable.h"
[6474]41#include "pickup/PickupIdentifier.h"
42#include "worldentities/StaticEntity.h"
[6475]43#include "PickupSpawner.h"
[6474]44
[6475]45#include "core/BaseObject.h"
46
[6711]47namespace orxonox // tolua_export
48{ // tolua_export
[6474]49
[6475]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    */
[6711]55    class _PickupExport PickupRepresentation // tolua_export
56        : public BaseObject
57    { // tolua_export
[6474]58       
59        public:
[6475]60            PickupRepresentation(); //!< Constructor
61            PickupRepresentation(BaseObject* creator); //!< Default constructor.
62            virtual ~PickupRepresentation(); //!< Destructor.
[6474]63           
64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
65           
[6475]66            /**
67            @brief Set the name of the Pickupable represented by this PickupRepresentation.
68            @param name The name.
69            */
[6711]70            inline void setPickupName(const std::string& name)
[6474]71                { this->name_ = name; }
[6475]72            /**
73            @brief Set the description of the Pickupable represented by this PickupRepresentation.
74            @param description The Description.
75            */
[6711]76            inline void setPickupDescription(const std::string& description)
[6474]77                { this->description_ = description; }
[6475]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            */
[6474]83            inline void setSpawnerTemplate(const std::string& spawnerTemplate)
84                { this->spawnerTemplate_ = spawnerTemplate; }
[6475]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            */
[6474]90            inline void setSpawnerRepresentation(StaticEntity* representation)
91                { this->spawnerRepresentation_ = representation; }
[6475]92            /**
[6711]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            /**
[6475]99            @brief Set the Pickupable that is represented by this PickupRepresentation.
100            @param pickup A pointer to the Pickupable.
101            */
[6474]102            inline void setPickup(Pickupable* pickup)
103                { this->pickup_ = pickup; }
104               
[6475]105            /**
106            @brief Get the name of the Pickupable represented by this PickupRepresentation.
107            @return Returns the name.
108            */
[6711]109            inline const std::string& getPickupName(void) { return this->name_; } // tolua_export
[6475]110            /**
111            @brief Get the description of the Pickupable represented by this PickupRepresentation.
112            @return Returns the description.
113            */
[6711]114            inline const std::string& getPickupDescription(void) { return this->description_; } // tolua_export
[6475]115            /**
116            @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
117            @return Returns the name of the spawnerTemplate.
118            */
[6474]119            inline const std::string& getSpawnerTemplate(void)
120                { return this->spawnerTemplate_; }
[6475]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            */
[6474]126            inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
127                { if(index == 0) return this->spawnerRepresentation_; return NULL; }
[6475]128            /**
[6711]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            /**
[6475]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            */
[6474]138            inline const Pickupable* getPickup(unsigned int index)
139                { if(index == 0) return this->pickup_; return NULL; }
140               
[6475]141            StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
[6474]142       
143        private:
[6475]144            void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
145            StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
[6474]146           
[6475]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.
[6711]151            std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. TODO: Exact format and placement of image?
[6474]152           
[6475]153            Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
[6474]154           
[6711]155    }; // tolua_export
[6474]156
[6711]157} // tolua_export
[6474]158   
159#endif // _PickupRepresentation_H__
Note: See TracBrowser for help on using the repository browser.