Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/orxonox/interfaces/Pickupable.h @ 6466

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

Lots of things done in pickups module. Compiles, but it seems, that I've also introduced an error preventing steering of the spaceship.

File size: 4.3 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
31    @brief Definition of the Pickupable class.
32*/
33
34#ifndef _Pickupable_H__
35#define _Pickupable_H__
36
37#include "OrxonoxPrereqs.h"
38#include "core/OrxonoxClass.h"
39
40#include "core/Super.h"
41#include "pickup/PickupIdentifier.h"
42#include <list>
43
44namespace orxonox
45{
46   
47    /**
48    @brief
49        An Interface (or more precisely an abstract Class) to model and represent different (all kinds of) pickups.
50    @author
51        Damian 'Mozork' Frick
52    */
53    //TODO: Add stuff like weight/space ?
54    class _OrxonoxExport Pickupable : virtual public OrxonoxClass
55    {
56       
57        public:
58            Pickupable(); //!< Default constructor.
59            virtual ~Pickupable() {} //!< Default destructor.
60               
61            /**
62            @brief Get the carrier of the pickup.
63            @return Returns a pointer to the carrier of the pickup.
64            */
65            inline PickupCarrier* getCarrier(void)
66                { return this->carrier_; }
67               
68            /**
69            @brief Get whether the pickup is currently in use or not.
70            @return Returns true if the pickup is currently in use.
71            */
72            inline bool isUsed(void)
73                { return this->used_; }
74               
75            bool isTarget(PickupCarrier* carrier);
76            bool addTarget(PickupCarrier* target);
77
78            bool setUsed(bool used);
79           
80            bool pickedUp(PickupCarrier* carrier);
81            bool dropped(void);
82           
83            inline bool isPickedUp(void)
84                { return this->pickedUp_; }
85           
86            Pickupable* clone(void);
87           
88            virtual const PickupIdentifier* getPickupIdentifier(void)
89                { return &this->pickupIdentifier_; }
90               
91            virtual void clone(OrxonoxClass* item);
92           
93            /**
94            @brief  Should be called when the pickup has transited from used to unused or the other way around.
95                    Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method.
96            */
97            virtual void changedUsed(void) {}
98           
99            /**
100            @brief  Should be called when the pickup has transited from picked up to dropped or the other way around.
101                    Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method.
102            */
103            virtual void changedCarrier(void) {}
104           
105            bool setCarrier(PickupCarrier* carrier);
106           
107        protected:
108            void initializeIdentifier(void) {}
109           
110            PickupIdentifier pickupIdentifier_;
111           
112        private:
113            inline void setPickedUp(bool pickedUp)
114                { this->pickedUp_ = pickedUp; }
115           
116            bool used_; //!< Whether the pickup is currently in use or not.
117            bool pickedUp_; //!< Whether the pickup is currently picked up or not.
118           
119            PickupCarrier* carrier_; //!< The owner of the pickup.
120            std::list<Identifier*> targets_; //!< The possible targets of this pickup.
121
122    };
123   
124    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
125    SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
126}
127
128#endif /* _Pickupable_H__ */
Note: See TracBrowser for help on using the repository browser.