Orxonox  0.0.5 Codename: Arcturus
PickupManager.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 _PickupManager_H__
36 #define _PickupManager_H__
37 
38 #include "PickupPrereqs.h"
39 
40 #include <map>
41 #include "core/object/WeakPtr.h"
42 
43 #include "PickupRepresentation.h"
44 
45 #include "util/Singleton.h"
47 
48 namespace orxonox // tolua_export
49 { // tolua_export
50 
51  // tolua_begin
60  {
61  uint32_t pickup;
62  bool inUse;
63  bool pickedUp;
64  bool usable;
65  bool unusable;
67  uint32_t carrierPawnId;
68  };
69  // tolua_end
70 
99  class _PickupExport PickupManager // tolua_export
100  : public Singleton<PickupManager>, public PickupListener
101  { // tolua_export
102  friend class Singleton<PickupManager>;
103 
104  public:
105  PickupManager();
106  virtual ~PickupManager();
107 
112  static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export
113 
114  bool registerRepresentation(const std::string& name, PickupRepresentation* representation);
115  bool unregisterRepresentation(const std::string& name);
116 
117  PickupRepresentation* getRepresentation(const std::string& name); // tolua_export
118 
119  virtual void pickupChangedUsed(Pickupable* pickup, bool used) override;
120  static void pickupChangedUsedNetwork(uint32_t pickup, bool inUse, bool usable, bool unusable);
121  virtual void pickupChangedPickedUp(Pickupable* pickup, bool pickedUp) override;
122  static void pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, const std::string& representationName, bool pickedUp, uint32_t carrierPawnId);
123 
124  // Methods to be used by the PickupInventory.
125  public:
126  // tolua_begin
127  int getNumPickups(void);
128 
134  { return (this->pickupsIterator_++)->second; }
135 
136  void dropPickup(uint32_t pickup);
137  void usePickup(uint32_t pickup, bool use);
138 
143  bool isValidPickup(uint32_t pickup) const
144  { return this->pickups_.find(pickup) != this->pickups_.end(); }
145  // tolua_end
146 
147  static void dropPickupNetworked(uint32_t pickup);
148  static void usePickupNetworked(uint32_t pickup, bool use);
149 
150  private:
152  static const std::string guiName_s;
153  bool guiLoaded_;
155 
157 
158  std::map<std::string, PickupRepresentation*> representations_;
159 
160  std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_;
161  std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_;
162 
163  std::map<uint32_t, WeakPtr<Pickupable>> pickups_;
164  std::map<Pickupable*, uint32_t> indexes_;
165 
166  void updateGUI(void);
167  uint32_t getPickupIndex(void);
168 
169  }; // tolua_export
170 
171 } // tolua_export
172 
173 #endif // _PickupManager_H__
std::map< uint32_t, WeakPtr< Pickupable > > pickups_
Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.
Definition: PickupManager.h:163
const orxonox::PickupInventoryContainer * popPickup(void)
Get the next PickupInventoryContainer in the list.
Definition: PickupManager.h:133
bool guiLoaded_
Whether the PickupInventory GUI has been loaded, yet.
Definition: PickupManager.h:153
uint32_t pickup
An indentifier for the Pickupable that is associated with the information stored here.
Definition: PickupManager.h:61
#define _PickupExport
Definition: PickupPrereqs.h:60
Data structure to store collected data for one specific Pickupable.
Definition: PickupManager.h:59
PickupRepresentation * defaultRepresentation_
The default PickupRepresentation.
Definition: PickupManager.h:156
An Interface (or more precisely an abstract class) to model and represent different (all kinds of) pi...
Definition: Pickupable.h:60
uint32_t pickupHighestIndex_
The highest pickup index currently in use. (not taking wrap-around into account)
Definition: PickupManager.h:154
The MetaPickup uses all the PickupCarriers&#39; Pickupables.
bool pickedUp
Whether the Pickupable is currently picked up.
Definition: PickupManager.h:63
::std::string string
Definition: gtest-port.h:756
static PickupManager & getInstance()
Get the instance of the PickupManager singleton.
Definition: PickupManager.h:112
Definition of WeakPtr<T>, wraps a pointer to an object.
bool usable
Whether the Pickupable is usable.
Definition: PickupManager.h:64
bool isValidPickup(uint32_t pickup) const
Check whether the input Pickupable is valid, meaning that it is in the PickupManager&#39;s list and still...
Definition: PickupManager.h:143
std::map< std::string, PickupRepresentation * > representations_
Map linking PickupRepresentations and their names.
Definition: PickupManager.h:158
Definition of the PickupListener class.
static PickupManager * singletonPtr_s
Definition: PickupManager.h:151
std::map< uint32_t, PickupInventoryContainer * > pickupInventoryContainers_
Map linking a number identifying a Pickupable to a PickupInventoryContainer, which contains all neces...
Definition: PickupManager.h:160
bool inUse
Whether the Pickupable is currently in use.
Definition: PickupManager.h:62
Base for singleton classes.
Definition: Singleton.h:114
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
std::map< uint32_t, PickupInventoryContainer * >::iterator pickupsIterator_
An iterator pointing to the current Pickupable in pickupsList_.
Definition: PickupManager.h:161
Definition of the PickupRepresentation class.
The PickupListener class facilitates the flow of information regarding the picking up...
Definition: PickupListener.h:57
The PickupRepresentation class represents a specific pickup type.
Definition: PickupRepresentation.h:91
std::map< Pickupable *, uint32_t > indexes_
Map linking Pickupable to the number identifying it.
Definition: PickupManager.h:164
static const std::string guiName_s
The name of the PickupInventory.
Definition: PickupManager.h:152
uint32_t carrierPawnId
The objectId of the Pawn that carries the Pickupable.
Definition: PickupManager.h:67
Definition of the Singleton template that is used as base class for classes that allow only one insta...
bool unusable
Whether the Pickupable is droppable.
Definition: PickupManager.h:65
std::string representationName
The name of the associated PickupRepresentation.
Definition: PickupManager.h:66
Shared library macros, enums, constants and forward declarations for the questsystem module ...
static T & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
The PickupManager class manages Pickupables.
Definition: PickupManager.h:99