[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 | /** |
---|
| 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" |
---|
[6466] | 41 | #include "pickup/PickupIdentifier.h" |
---|
[6405] | 42 | #include <list> |
---|
| 43 | |
---|
| 44 | namespace orxonox |
---|
| 45 | { |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | @brief |
---|
[6466] | 49 | An Interface (or more precisely an abstract Class) to model and represent different (all kinds of) pickups. |
---|
[6405] | 50 | @author |
---|
| 51 | Damian 'Mozork' Frick |
---|
| 52 | */ |
---|
| 53 | //TODO: Add stuff like weight/space ? |
---|
| 54 | class _OrxonoxExport Pickupable : virtual public OrxonoxClass |
---|
| 55 | { |
---|
[6466] | 56 | |
---|
[6405] | 57 | public: |
---|
| 58 | Pickupable(); //!< Default constructor. |
---|
| 59 | virtual ~Pickupable() {} //!< Default destructor. |
---|
| 60 | |
---|
| 61 | /** |
---|
[6466] | 62 | @brief Get the carrier of the pickup. |
---|
| 63 | @return Returns a pointer to the carrier of the pickup. |
---|
[6405] | 64 | */ |
---|
[6466] | 65 | inline PickupCarrier* getCarrier(void) |
---|
| 66 | { return this->carrier_; } |
---|
[6405] | 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 | |
---|
[6466] | 75 | bool isTarget(PickupCarrier* carrier); |
---|
| 76 | bool addTarget(PickupCarrier* target); |
---|
[6405] | 77 | |
---|
[6466] | 78 | bool setUsed(bool used); |
---|
[6405] | 79 | |
---|
[6466] | 80 | bool pickedUp(PickupCarrier* carrier); |
---|
| 81 | bool dropped(void); |
---|
[6405] | 82 | |
---|
[6466] | 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 | |
---|
[6405] | 93 | /** |
---|
[6466] | 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. |
---|
[6405] | 96 | */ |
---|
[6466] | 97 | virtual void changedUsed(void) {} |
---|
[6405] | 98 | |
---|
| 99 | /** |
---|
[6466] | 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. |
---|
[6405] | 102 | */ |
---|
[6466] | 103 | virtual void changedCarrier(void) {} |
---|
[6405] | 104 | |
---|
[6466] | 105 | bool setCarrier(PickupCarrier* carrier); |
---|
| 106 | |
---|
| 107 | protected: |
---|
| 108 | void initializeIdentifier(void) {} |
---|
| 109 | |
---|
| 110 | PickupIdentifier pickupIdentifier_; |
---|
| 111 | |
---|
[6405] | 112 | private: |
---|
[6466] | 113 | inline void setPickedUp(bool pickedUp) |
---|
| 114 | { this->pickedUp_ = pickedUp; } |
---|
[6405] | 115 | |
---|
| 116 | bool used_; //!< Whether the pickup is currently in use or not. |
---|
[6466] | 117 | bool pickedUp_; //!< Whether the pickup is currently picked up or not. |
---|
[6405] | 118 | |
---|
[6466] | 119 | PickupCarrier* carrier_; //!< The owner of the pickup. |
---|
[6405] | 120 | std::list<Identifier*> targets_; //!< The possible targets of this pickup. |
---|
| 121 | |
---|
| 122 | }; |
---|
| 123 | |
---|
[6466] | 124 | SUPER_FUNCTION(10, Pickupable, changedUsed, false); |
---|
| 125 | SUPER_FUNCTION(12, Pickupable, changedCarrier, false); |
---|
[6405] | 126 | } |
---|
| 127 | |
---|
| 128 | #endif /* _Pickupable_H__ */ |
---|