Emergency 20 Dokumentation  4.2.0
PlayerManager.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/game/player/Player.h" // Not directly needed, but whoever needs the manager will probably also need the player class included
14 
16 
17 #include <boost/container/flat_map.hpp>
18 
19 #include <vector>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Namespace ]
24 //[-------------------------------------------------------]
25 namespace qsf
26 {
27  class BinarySerializer;
28 }
29 
30 
31 //[-------------------------------------------------------]
32 //[ Namespace ]
33 //[-------------------------------------------------------]
34 namespace em5
35 {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Classes ]
40  //[-------------------------------------------------------]
46  {
47 
48 
49  //[-------------------------------------------------------]
50  //[ Public definitions ]
51  //[-------------------------------------------------------]
52  public:
53  typedef boost::container::flat_map<uint32, Player*> PlayerMap;
54  typedef std::vector<Player*> PlayerList;
55 
56 
57  //[-------------------------------------------------------]
58  //[ Public static methods ]
59  //[-------------------------------------------------------]
60  public:
65  inline static Player* getLocalPlayer();
66 
71  inline static Player& getLocalPlayerSafe();
72 
73 
74  //[-------------------------------------------------------]
75  //[ Public methods ]
76  //[-------------------------------------------------------]
77  public:
82  inline PlayerManager();
83 
88  inline virtual ~PlayerManager();
89 
94  void startup();
95 
100  void shutdown();
101 
109  inline Player* getPlayerByIndex(uint32 playerIndex) const;
110 
118  inline const PlayerList& getAllPlayers() const;
119 
124  void unblockAllPlayersUnitPool();
125 
130  void serialize(qsf::BinarySerializer& serializer);
131 
132 
133  //[-------------------------------------------------------]
134  //[ Private methods ]
135  //[-------------------------------------------------------]
136  private:
137  void destroyAllPlayers();
138 
139 
140  //[-------------------------------------------------------]
141  //[ Private static data ]
142  //[-------------------------------------------------------]
143  private:
144  static Player* mLocalPlayer;
145 
146 
147  //[-------------------------------------------------------]
148  //[ Private data ]
149  //[-------------------------------------------------------]
150  private:
151  PlayerMap mPlayers;
152  PlayerList mPlayerList;
153 
154  bool mWasDeserialized;
155 
156 
157  };
158 
159 
160 //[-------------------------------------------------------]
161 //[ Namespace ]
162 //[-------------------------------------------------------]
163 } // em5
164 
165 
166 //[-------------------------------------------------------]
167 //[ Implementation ]
168 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
boost::container::flat_map< uint32, Player * > PlayerMap
Maps player indices to player instances.
Definition: PlayerManager.h:53
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 player manager.
Definition: PlayerManager.h:45
EMERGENCY 5 player class.
Definition: Player.h:57
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Abstract manager interface.
Definition: Manager.h:40
Definition: PickupPersonByParamedicAction.h:21
std::vector< Player * > PlayerList
Holds a list of players (no special ordering guaranteed)
Definition: PlayerManager.h:54
Binary serializer class.
Definition: BinarySerializer.h:35