Emergency 20 Dokumentation  4.2.0
MessageObjectiveObserver.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 //[-------------------------------------------------------]
14 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23  class Objective;
24 }
25 
26 
27 //[-------------------------------------------------------]
28 //[ Namespace ]
29 //[-------------------------------------------------------]
30 namespace em5
31 {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Classes ]
36  //[-------------------------------------------------------]
46  {
47 
48 
49  //[-------------------------------------------------------]
50  //[ Public definitions ]
51  //[-------------------------------------------------------]
52  public:
53  static const uint32 GAMELOGIC_TYPE_ID; // "em5::MessageObjectiveObserver" game logic type ID
54 
55  enum class Reaction
56  {
57  NONE = 0,
58  OBJECTIVE_DEC_CURRENT,
59  OBJECTIVE_INC_CURRENT,
60  OBJECTIVE_DEC_NEEDED,
61  OBJECTIVE_INC_NEEDED
62  };
63 
64 
65  //[-------------------------------------------------------]
66  //[ Public methods ]
67  //[-------------------------------------------------------]
68  public:
74 
88  void initWithObjective(const qsf::MessageConfiguration& messageConfiguration, Objective& objective, Reaction reaction, bool removeAfterTrigger = true);
89 
90  void addMessage(const qsf::MessageConfiguration& messageConfiguration);
91 
92 
93  //[-------------------------------------------------------]
94  //[ Public virtual qsf::GameLogic methods ]
95  //[-------------------------------------------------------]
96  public:
97  virtual bool onStartup() override;
98  virtual void onShutdown() override;
99  virtual void serialize(qsf::BinarySerializer& serializer) override;
100 
101 
102  //[-------------------------------------------------------]
103  //[ Protected methods ]
104  //[-------------------------------------------------------]
105  protected:
110  explicit MessageObjectiveObserver(uint32 gameLogicTypeId);
111 
112 
113  //[-------------------------------------------------------]
114  //[ Protected virtual em5::MessageObjectiveObserver methods ]
115  //[-------------------------------------------------------]
116  public:
121  virtual bool checkIncomingMessage(const qsf::MessageParameters& parameters) { return true; }
122 
123 
124  //[-------------------------------------------------------]
125  //[ Private methods ]
126  //[-------------------------------------------------------]
127  private:
128  void onMessage(const qsf::MessageParameters& parameters);
129 
130 
131  //[-------------------------------------------------------]
132  //[ Private data ]
133  //[-------------------------------------------------------]
134  private:
135  std::vector<qsf::MessageConfiguration> mMessageConfigurations;
136  std::vector<qsf::MessageProxy> mMessageProxies;
137 
138  uint32 mObjectiveId;
139  Reaction mReaction;
140  bool mRemoveAfterTrigger;
141 
142 
143  //[-------------------------------------------------------]
144  //[ CAMP reflection system ]
145  //[-------------------------------------------------------]
146  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
147 
148 
149  };
150 
151 
152 //[-------------------------------------------------------]
153 //[ Namespace ]
154 //[-------------------------------------------------------]
155 } // em5
156 
157 
158 //[-------------------------------------------------------]
159 //[ CAMP reflection system ]
160 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Message parameters class.
Definition: MessageParameters.h:34
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 generic message observer.
Definition: MessageObjectiveObserver.h:45
Reaction
Definition: MessageObjectiveObserver.h:55
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 objective class.
Definition: Objective.h:51
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
virtual bool checkIncomingMessage(const qsf::MessageParameters &parameters)
Callback for sub-class implementations: return "false" to ignore this incoming message.
Definition: MessageObjectiveObserver.h:121
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Message configuration class.
Definition: MessageConfiguration.h:44
static const uint32 GAMELOGIC_TYPE_ID
Definition: MessageObjectiveObserver.h:53
Binary serializer class.
Definition: BinarySerializer.h:35