Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/objects/pickup/BaseItem.h @ 2972

Last change on this file since 2972 was 2972, checked in by danielh, 15 years ago

Update

  • Minor changes in BaseItem
  • Updated to NotificationQueue from trunk (compile error with old)
  • Added PickupInventory for GUI handling
  • Added basic support for toLua++ methods
  • Property svn:eol-style set to native
File size: 4.8 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 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Definition of BaseItem (base-class for items/pickups).
32*/
33
34#ifndef _BaseItem_H__
35#define _BaseItem_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include "core/BaseObject.h"
40
41// tolua_begin
42namespace orxonox
43{
44    /**
45        @brief
46            Base class for all items/pickups.
47
48            Provides common methods to be used in derived classes.
49        @author
50            Daniel 'Huty' Haggenmueller
51    */
52    class _OrxonoxExport BaseItem : public BaseObject
53    {
54// tolua_end
55    public:
56        BaseItem(BaseObject* creator);
57        virtual ~BaseItem();
58
59        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< XMLPort
60
61        /**
62            @brief Checks how many instances of this item can be carried at a time.
63            @return How many of this item can be carried.
64        */
65        virtual int getMaxCarryAmount() const
66            { return 1; }
67
68        bool addTo(Pawn* pawn);             //!< Add the item to a pawn.
69        bool removeFrom(Pawn* pawn);        //!< Removes the item from a pawn.
70        /**
71            @brief
72                Method invoked when the item gets picked up.
73
74                Has to be overridden for an item to work,
75                should contain a call to addTo().
76
77            @param pawn Pawn who picks up the item.
78            @return Returns whether the pawn was able to pick up the item.
79        */
80        virtual bool pickedUp(Pawn* pawn)
81            { return false; }
82        /**
83            @brief
84                Method invoked when the item is dropped from a player.
85
86                Should be overridden by derived classes,
87                should also contain a call to removeFrom().
88
89            @param pawn Pawn which dropped the item.
90            @return Returns whether the item was able to get dropped by the pawn.
91        */
92        virtual bool dropped(Pawn* pawn)
93            { return false; }
94
95        /**
96            @brief Gets the current owner of the pickup.
97            @return Returns the current owner.
98        */
99        inline Pawn* getOwner() const
100            { return this->owner_; }
101        /**
102            @brief Sets the owner of the pickup.
103            @param owner New owner for the pickup.
104        */
105        inline void setOwner(Pawn* owner)
106            { this->owner_ = owner; }
107
108        /**
109            @brief Gets the pickupIdentifier of the item.
110            @return Returns the pickupIdentifier of the item.
111            @see pickupIdentifier_
112        */
113        inline const std::string& getPickupIdentifier() const
114            { return this->pickupIdentifier_; }
115        /**
116            @brief Sets the pickupIdentifier for the item.
117            @param identifier New pickupIdentifier for the item.
118            @see pickupIdentifier_
119        */
120        inline void setPickupIdentifier(const std::string& identifier)
121            { this->pickupIdentifier_ = identifier; }
122
123        // GUI stuff
124        virtual const std::string& getGUIText()
125            { return this->guiText_; }
126        inline void setGUIText(const std::string& text)
127            { this->guiText_ = text; }
128
129        virtual const std::string& getGUITooltip()
130            { return this->guiTooltip_; }
131        inline void setGUITooltip(const std::string& tooltip)
132            { this->guiTooltip_ = tooltip; }
133
134        virtual const std::string& getGUIImage()
135            { return this->guiImage_; }
136        inline void setGUIImage(const std::string& image)
137            { this->guiImage_ = image; }
138    private:
139        Pawn* owner_;   //!< The current owner of the item.
140
141        /**
142            @brief
143                The pickupIdentifier of the item..
144
145                Usually set to the template name used by a PickupSpawner,
146                used to index items in the PickupCollection.
147        */
148        std::string pickupIdentifier_;
149
150        std::string guiText_;
151        std::string guiTooltip_;
152        std::string guiImage_;
153    };
154}
155
156#endif /* _BaseItem_H__ */
Note: See TracBrowser for help on using the repository browser.