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 Pickupable.h |
---|
31 | @brief Definition of the Pickupable class. |
---|
32 | */ |
---|
33 | |
---|
34 | #ifndef _Pickupable_H__ |
---|
35 | #define _Pickupable_H__ |
---|
36 | |
---|
37 | #include "OrxonoxPrereqs.h" |
---|
38 | |
---|
39 | #include <list> |
---|
40 | #include "core/Super.h" |
---|
41 | |
---|
42 | #include "core/OrxonoxClass.h" |
---|
43 | |
---|
44 | namespace orxonox // tolua_export |
---|
45 | { // tolua_export |
---|
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 | class _OrxonoxExport Pickupable // tolua_export |
---|
54 | : virtual public OrxonoxClass |
---|
55 | { // tolua_export |
---|
56 | protected: |
---|
57 | Pickupable(); //!< Default constructor. |
---|
58 | |
---|
59 | public: |
---|
60 | virtual ~Pickupable(); //!< Default destructor. |
---|
61 | |
---|
62 | /** |
---|
63 | @brief Get whether the pickup is currently in use or not. |
---|
64 | @return Returns true if the pickup is currently in use. |
---|
65 | */ |
---|
66 | inline bool isUsed(void) { return this->used_; } // tolua_export |
---|
67 | /** |
---|
68 | @brief Should be called when the pickup has transited from used to unused or the other way around. |
---|
69 | Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method. |
---|
70 | */ |
---|
71 | virtual void changedUsed(void) {} |
---|
72 | |
---|
73 | /** |
---|
74 | @brief Get the carrier of the pickup. |
---|
75 | @return Returns a pointer to the carrier of the pickup. |
---|
76 | */ |
---|
77 | inline PickupCarrier* getCarrier(void) |
---|
78 | { return this->carrier_; } |
---|
79 | /** |
---|
80 | @brief Should be called when the pickup has changed its PickupCarrier. |
---|
81 | Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method. |
---|
82 | */ |
---|
83 | virtual void changedCarrier(void) {} |
---|
84 | |
---|
85 | /** |
---|
86 | @brief Returns whether the Pickupable is currently picked up. |
---|
87 | @return Returns true if the Pickupable is currently picked up, false if not. |
---|
88 | */ |
---|
89 | inline bool isPickedUp(void) { return this->pickedUp_; } // tolua_export |
---|
90 | /** |
---|
91 | @brief Should be called when the pickup has transited from picked up to dropped or the other way around. |
---|
92 | Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method. |
---|
93 | */ |
---|
94 | virtual void changedPickedUp(void) {} |
---|
95 | |
---|
96 | bool pickedUp(PickupCarrier* carrier); //!< Sets the Pickupable to picked up. |
---|
97 | bool dropped(void); //!< Sets the Pickupable to not picked up or dropped. |
---|
98 | |
---|
99 | virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup. |
---|
100 | bool isTarget(const Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this Pickupable. |
---|
101 | bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup. |
---|
102 | bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup. |
---|
103 | |
---|
104 | Pickupable* clone(void); //!< Creates a duplicate of the Pickupable. |
---|
105 | virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. |
---|
106 | |
---|
107 | /** |
---|
108 | @brief Get the PickupIdentifier of this Pickupable. |
---|
109 | @return Returns a pointer to the PickupIdentifier of this Pickupable. |
---|
110 | */ |
---|
111 | virtual const PickupIdentifier* getPickupIdentifier(void) |
---|
112 | { return this->pickupIdentifier_; } |
---|
113 | |
---|
114 | bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input. |
---|
115 | bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up. |
---|
116 | bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup. |
---|
117 | |
---|
118 | protected: |
---|
119 | /** |
---|
120 | @brief Helper method to initialize the PickupIdentifier. |
---|
121 | */ |
---|
122 | void initializeIdentifier(void) {} |
---|
123 | |
---|
124 | /** |
---|
125 | @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. |
---|
126 | 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.: |
---|
127 | DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance); |
---|
128 | @param position The position at which the PickupSpawner should be placed. |
---|
129 | @return Returns true if a spawner was created, false if not. |
---|
130 | */ |
---|
131 | virtual bool createSpawner(void) = 0; |
---|
132 | |
---|
133 | PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable. |
---|
134 | |
---|
135 | private: |
---|
136 | |
---|
137 | bool used_; //!< Whether the pickup is currently in use or not. |
---|
138 | bool pickedUp_; //!< Whether the pickup is currently picked up or not. |
---|
139 | |
---|
140 | PickupCarrier* carrier_; //!< The carrier of the pickup. |
---|
141 | std::list<Identifier*> targets_; //!< The possible targets of this pickup. |
---|
142 | |
---|
143 | }; // tolua_export |
---|
144 | |
---|
145 | SUPER_FUNCTION(10, Pickupable, changedUsed, false); |
---|
146 | SUPER_FUNCTION(12, Pickupable, changedCarrier, false); |
---|
147 | SUPER_FUNCTION(13, Pickupable, changedPickedUp, false); |
---|
148 | } // tolua_export |
---|
149 | |
---|
150 | #endif /* _Pickupable_H__ */ |
---|