Orxonox  0.0.5 Codename: Arcturus
Pickupable.h
Go to the documentation of this file.
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 
35 #ifndef _Pickupable_H__
36 #define _Pickupable_H__
37 
38 #include "OrxonoxPrereqs.h"
39 
40 #include <list>
41 #include "core/class/Super.h"
42 
44 #include "Rewardable.h"
45 
46 namespace orxonox
47 {
48 
60  class _OrxonoxExport Pickupable : virtual public OrxonoxInterface, public Rewardable
61  {
62  friend class PickupCarrier;
63 
64  protected:
65  Pickupable();
66 
67  public:
68  virtual ~Pickupable();
69 
71  virtual const std::string& getRepresentationName() const = 0;
72 
77  inline bool isUsed(void) const
78  { return this->used_; }
83  virtual void changedUsed(void) {}
84 
89  inline PickupCarrier* getCarrier(void)
90  { return this->carrier_; }
95  virtual void changedCarrier(void) {}
96 
101  inline bool isPickedUp(void) const
102  { return this->pickedUp_; }
107  virtual void changedPickedUp(void) {}
108 
113  inline bool isUsable(void) const
114  { return this->enabled_; }
115 
120  inline bool isUnusable(void) const
121  { return this->enabled_; }
122 
128  inline bool isEnabled(void) const
129  { return this->enabled_; }
130 
131  bool pickup(PickupCarrier* carrier);
132  bool drop(bool createSpawner = true);
133 
134  virtual bool isTarget(const PickupCarrier* carrier) const;
135  bool isTarget(const Identifier* identifier) const;
136  bool addTarget(PickupCarrier* target);
137  bool addTarget(Identifier* identifier);
138 
139  bool setUsed(bool used);
140  bool setPickedUp(bool pickedUp);
141  bool setCarrier(PickupCarrier* carrier, bool tell = true);
142 
143  void destroy(void);
144 
145  protected:
146  virtual void preDestroy(void) override;
147  virtual void destroyPickup(void);
148  virtual void carrierDestroyed(void);
149 
153  inline void setDisabled(void)
154  { this->enabled_ = false; }
155 
160  inline bool isBeingDestroyed(void)
161  { return this->beingDestroyed_; }
162 
168  virtual bool createSpawner(void) = 0;
169 
170  private:
171 
172  bool used_;
173  bool pickedUp_;
174 
175  bool enabled_;
176 
178  std::list<Identifier*> targets_;
179 
181 
182  // For implementing the Rewardable interface:
183  public:
184  virtual bool reward(PlayerInfo* player) override;
185 
186  };
187 
189  SUPER_FUNCTION(9, Pickupable, changedUsed, false);
190  SUPER_FUNCTION(10, Pickupable, changedCarrier, false);
191  SUPER_FUNCTION(11, Pickupable, changedPickedUp, false);
192 }
193 
194 #endif /* _Pickupable_H__ */
bool beingDestroyed_
Is true if the Pickupable is in the process of being destroyed.
Definition: Pickupable.h:180
bool isPickedUp(void) const
Returns whether the Pickupable is currently picked up.
Definition: Pickupable.h:101
An Interface (or more precisely an abstract class) to model and represent different (all kinds of) pi...
Definition: Pickupable.h:60
virtual void changedUsed(void)
Should be called when the Pickupable has transited from used to unused or the other way around...
Definition: Pickupable.h:83
::std::string string
Definition: gtest-port.h:756
PickupCarrier * getCarrier(void)
Get the carrier of the Pickupable.
Definition: Pickupable.h:89
The MetaPickup drops all the PickupCarriers&#39; Pickupables.
This is the class from which all interfaces of the game-logic (not the engine) are derived from...
Definition: OrxonoxInterface.h:50
bool pickedUp_
Whether the Pickupable is currently picked up or not.
Definition: Pickupable.h:173
std::list< Identifier * > targets_
The possible targets of this Pickupable.
Definition: Pickupable.h:178
The MetaPickup destroys all the PickupCarriers&#39; Pickupables.
bool isBeingDestroyed(void)
Check whether the Pickupable is in the process of being destroyed.
Definition: Pickupable.h:160
SUPER_FUNCTION(0, BaseObject, XMLPort, false)
bool isEnabled(void) const
Returns whether the Pickupable is enabled.
Definition: Pickupable.h:128
virtual void changedPickedUp(void)
Should be called when the Pickupable has transited from picked up to dropped or the other way around...
Definition: Pickupable.h:107
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Declaration of OrxonoxInterface, the base class of all interfaces in Orxonox.
PickupCarrier * carrier_
The PickupCarrier of the Pickupable.
Definition: Pickupable.h:177
The Identifier is used to identify the class of an object and to store information about the class...
Definition: Identifier.h:109
Shared library macros, enums, constants and forward declarations for the orxonox library ...
bool isUsable(void) const
Returns whether the Pickupable can be used.
Definition: Pickupable.h:113
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward ...
Definition: Rewardable.h:50
Definition of the Rewardable class.
bool isUnusable(void) const
Returns whether the Pickupable can be unused.
Definition: Pickupable.h:120
The PickupCarrier interface provides the means, for any class implementing it, to possess Pickupables...
Definition: PickupCarrier.h:68
bool used_
Whether the Pickupable is currently in use or not.
Definition: Pickupable.h:172
void setDisabled(void)
Sets the Pickuapble to disabled.
Definition: Pickupable.h:153
Definition: PlayerInfo.h:39
Definition of all super-function related macros, used to call functions of the base class...
bool enabled_
Whether the Pickupable is enabled or not.
Definition: Pickupable.h:175
virtual void changedCarrier(void)
Should be called when the Pickupable has changed its PickupCarrier.
Definition: Pickupable.h:95
bool isUsed(void) const
Get whether the Pickupable is currently in use or not.
Definition: Pickupable.h:77