Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/interfaces/Pickupable.h @ 7479

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

Reviewing documentation fo Questsystem, moving documentation fully into doxygen.
Added some files to modules they belong to.

  • Property svn:eol-style set to native
File size: 8.2 KB
RevLine 
[6405]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/**
[6538]30    @file Pickupable.h
[6405]31    @brief Definition of the Pickupable class.
[7456]32    @ingroup Pickup
[6405]33*/
34
35#ifndef _Pickupable_H__
36#define _Pickupable_H__
37
38#include "OrxonoxPrereqs.h"
39
[6474]40#include <list>
[6405]41#include "core/Super.h"
42
[6474]43#include "core/OrxonoxClass.h"
[7163]44#include "Rewardable.h"
[6474]45
[7163]46namespace orxonox // tolua_export
47{ // tolua_export
48
[6405]49    /**
50    @brief
[6474]51        An Interface (or more precisely an abstract class) to model and represent different (all kinds of) pickups.
[6405]52    @author
53        Damian 'Mozork' Frick
54    */
[7163]55    class _OrxonoxExport Pickupable  // tolua_export
56        : virtual public OrxonoxClass, public Rewardable
57    {  // tolua_export
[6540]58        protected:
59            Pickupable(); //!< Default constructor.
[7163]60
[6405]61        public:
[6474]62            virtual ~Pickupable(); //!< Default destructor.
[7163]63
[6405]64            /**
65            @brief Get whether the pickup is currently in use or not.
66            @return Returns true if the pickup is currently in use.
67            */
[7163]68            inline bool isUsed(void) { return this->used_; }  // tolua_export
[6474]69            /**
70            @brief  Should be called when the pickup has transited from used to unused or the other way around.
71                    Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method.
72            */
73            virtual void changedUsed(void) {}
[7163]74
[6474]75            /**
[6521]76            @brief Get the carrier of the pickup.
77            @return Returns a pointer to the carrier of the pickup.
78            */
79            inline PickupCarrier* getCarrier(void)
80                { return this->carrier_; }
81            /**
82            @brief Should be called when the pickup has changed its PickupCarrier.
83                   Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method.
84            */
85            virtual void changedCarrier(void) {}
[7163]86
[6521]87            /**
[6474]88            @brief Returns whether the Pickupable is currently picked up.
89            @return Returns true if the Pickupable is currently picked up, false if not.
90            */
[7163]91            inline bool isPickedUp(void) { return this->pickedUp_; }  // tolua_export
[6521]92            /**
93            @brief  Should be called when the pickup has transited from picked up to dropped or the other way around.
94                    Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method.
95            */
[6523]96            virtual void changedPickedUp(void) {}
[7163]97
98            /**
99            @brief Returns whether the Pickupable can be used.
100            @return Returns true if it can be used.
101            */
102            inline bool isUsable(void) { return this->enabled_; } // tolua_export
[6521]103           
[7163]104            /**
105            @brief Returns whether the Pickupable can be unused.
106            @return Returns true if it can be unused.
107            */
108            inline bool isUnusable(void) { return this->enabled_; } // tolua_export
109
110            /**
111            @brief Returns whether the Pickupable is enabled.
112                   Once a Pickupable is disabled it cannot be enabled again. A Pickupable that is disabled can neither be used nor unused.
113            @return Returns true if the Pickupable is enabled.
114            */
115            inline bool isEnabled(void)
116                { return this->enabled_; }
117
118            bool pickup(PickupCarrier* carrier); //!< Can be called to pick up a Pickupable.
119            bool drop(bool createSpawner = true); //!< Can be called to drop a Pickupable.
120
[6901]121            virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup.
[6731]122            bool isTarget(const Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this Pickupable.
[6474]123            bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup.
[6490]124            bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup.
[7163]125
[6474]126            Pickupable* clone(void); //!< Creates a duplicate of the Pickupable.
[6497]127            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
[7163]128
[6474]129            /**
130            @brief Get the PickupIdentifier of this Pickupable.
131            @return Returns a pointer to the PickupIdentifier of this Pickupable.
132            */
133            virtual const PickupIdentifier* getPickupIdentifier(void)
[6475]134                { return this->pickupIdentifier_; }
[7163]135
[6521]136            bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input.
137            bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up.
[7163]138            //TODO: private?
139            bool setCarrier(PickupCarrier* carrier, bool tell = true); //!< Sets the carrier of the pickup.
140
141            //TODO: private?
142            virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed.
143
144            void destroy(void); //!< Is called internally within the pickup module to destroy pickups.
145
[6466]146        protected:
[6474]147            /**
148            @brief Helper method to initialize the PickupIdentifier.
149            */
[6466]150            void initializeIdentifier(void) {}
[7163]151
152            virtual void preDestroy(void); //!< A method that is called by OrxonoxClass::destroy() before the object is actually destroyed.
153            virtual void destroyPickup(void); //!< Destroys a Pickupable.
154
[6475]155            /**
[7163]156            @brief Sets the Pickuapble to disabled.
157            */
158            inline void setDisabled(void)
159                { this->enabled_ = false; }
160
161            /**
[6475]162            @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
163                   This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
[7401]164                   DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance);
[6475]165            @return Returns true if a spawner was created, false if not.
166            */
[6540]167            virtual bool createSpawner(void) = 0;
[7163]168
[6475]169            PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.
[7163]170
[6405]171        private:
172
[7163]173            bool used_; //!< Whether the Pickupable is currently in use or not.
174            bool pickedUp_; //!< Whether the Pickupable is currently picked up or not.
175
176            bool enabled_; //!< Whether the Pickupable is enabled or not.
177
178            PickupCarrier* carrier_; //!< The PickupCarrier of the Pickupable.
179            std::list<Identifier*> targets_; //!< The possible targets of this Pickupable.
180
181            bool beingDestroyed_; //!< Is true if the Pickupable is in the process of being destroyed.
182
183        // For implementing the Rewardable interface:
184        public:
185            virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player.
186
187    };  // tolua_export
188
[6466]189    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
190    SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
[6521]191    SUPER_FUNCTION(13, Pickupable, changedPickedUp, false);
[7163]192}  // tolua_export
[6405]193
194#endif /* _Pickupable_H__ */
Note: See TracBrowser for help on using the repository browser.