Emergency 20 Dokumentation  4.2.0
FreeplayEvent-inl.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Namespace ]
6 //[-------------------------------------------------------]
7 namespace em5
8 {
9 
10 
11  //[-------------------------------------------------------]
12  //[ Public methods ]
13  //[-------------------------------------------------------]
15  {
16  // Nothing here
17  }
18 
19  inline void FreeplayEvent::setGreatJob(bool greatJob)
20  {
21  mGreatJob = greatJob;
22  }
23 
25  {
26  return mId;
27  }
28 
29  inline const std::string& FreeplayEvent::getEventName() const
30  {
31  return mEventName;
32  }
33 
34  inline void FreeplayEvent::setEventName(const std::string& name)
35  {
36  mEventName = name;
37  }
38 
40  {
41  return mEventFactoryName;
42  }
43 
45  {
46  mEventFactoryName = factoryName;
47  }
48 
50  {
51  return mObjectives;
52  }
53 
55  {
56  return mMap;
57  }
58 
59  inline const qsf::Map& FreeplayEvent::getMap() const
60  {
61  return mMap;
62  }
63 
65  {
66  return mRecordedHintSystemMessages;
67  }
68 
70  {
71  return mState;
72  }
73 
74  inline void FreeplayEvent::setCanWinEvent(bool canWinEvent)
75  {
76  mCanWinEvent = canWinEvent;
77  }
78 
79  inline bool FreeplayEvent::getCanWinEvent() const
80  {
81  return mCanWinEvent;
82  }
83 
84  inline void FreeplayEvent::setCanLoseEvent(bool canLoseEvent)
85  {
86  mCanLoseEvent = canLoseEvent;
87  }
88 
89  inline bool FreeplayEvent::getCanLoseEvent() const
90  {
91  return mCanLoseEvent;
92  }
93 
95  {
96  return mLifeTime;
97  }
98 
100  {
101  return mRunningTime;
102  }
103 
105  {
106  return mNormalPointGain;
107  }
108 
110  {
111  mNormalPointGain = pointGain;
112  }
113 
115  {
116  return mNormalCreditGain;
117  }
118 
120  {
121  mNormalCreditGain = creditGain;
122  }
123 
125  {
126  return mMultiplayerPointGain;
127  }
128 
130  {
131  mMultiplayerPointGain = pointGain;
132  }
133 
135  {
136  return mEventDensityIncrease;
137  }
138 
139  inline void FreeplayEvent::setEventDensityIncrease(float eventDensityIncrease)
140  {
141  mEventDensityIncrease = eventDensityIncrease;
142  }
143 
145  {
146  return mEntityIds;
147  }
148 
149  inline float FreeplayEvent::getEventDensity() const
150  {
151  return (FreeplayEvent::STATE_HIDDEN == getState()) ? mEventDensity : 0.0f;
152  }
153 
154  inline void FreeplayEvent::setEventDensity(float density)
155  {
156  mEventDensity = density;
157  }
158 
160  {
161  return mEventResult.mPlayerIndex;
162  }
163 
165  {
166  return mEventLocationEntity.valid();
167  }
168 
169 
170  //[-------------------------------------------------------]
171  //[ Public virtual em5::FreeplayEvent methods ]
172  //[-------------------------------------------------------]
174  {
175  // Default implementation simply returns "true"
176  return true;
177  }
178 
180  {
181  // Default implementation is empty
182  }
183 
184  inline void FreeplayEvent::onRun()
185  {
186  // Default implementation is empty
187  }
188 
189  inline bool FreeplayEvent::onSuccess(EventResult& eventResult)
190  {
191  // Always inform the freeplay system about finish
192  return true;
193  }
194 
195 
196  //[-------------------------------------------------------]
197  //[ Protected methods ]
198  //[-------------------------------------------------------]
200  {
201  return mObjectives;
202  }
203 
204  template<typename T>
205  T& FreeplayEvent::createObserver(uint64 entityId, const std::string& name)
206  {
207  return static_cast<T&>(createObserverByTypeId(T::GAMELOGIC_TYPE_ID, entityId, name));
208  }
209 
210  inline Observer& FreeplayEvent::createGeneralObserverByTypeId(uint32 typeId, const std::string& name)
211  {
212  return createObserverByTypeId(typeId, 0, name); // The core entity ID is always 0
213  }
214 
215  template<typename T>
216  T& FreeplayEvent::createGeneralObserver(const std::string& name)
217  {
218  return static_cast<T&>(createGeneralObserverByTypeId(T::GAMELOGIC_TYPE_ID, name));
219  }
220 
221  inline bool FreeplayEvent::isMiniEvent() const
222  {
223  return getIsMiniEvent();
224  }
225 
226 
227 //[-------------------------------------------------------]
228 //[ Namespace ]
229 //[-------------------------------------------------------]
230 } // em5
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
T & createGeneralObserver(const std::string &name=std::string())
Create a new general observer (i.e. not bound to a single entity, but observing the whole map) of the...
Definition: FreeplayEvent-inl.h:216
Map class.
Definition: Map.h:93
bool getCanLoseEvent() const
Access the flag which prevents losing the event even though a fail condition is fulfilled.
Definition: FreeplayEvent-inl.h:89
T & createObserver(uint64 entityId, const std::string &name=std::string())
Create a new observer of the specified type, inside the given entity.
Definition: FreeplayEvent-inl.h:205
void setEventName(const std::string &name)
Set freeplay event's localizable name (e.g. "EM5_EVENT_TITLE_04")
Definition: FreeplayEvent-inl.h:34
unsigned int uint32
Definition: PlatformTypes.h:181
uint32 mPlayerIndex
To which player is the event assigned (in single player this value is always uninitialized) ...
Definition: FreeplayEvent.h:126
const RecordedHintSystemMessages & getRecordedHintSystemMessages() const
Return recorded hint system messages.
Definition: FreeplayEvent-inl.h:64
bool getCanWinEvent() const
Access the flag which prevents winning the event even though all objectives succeeded.
Definition: FreeplayEvent-inl.h:79
void setCanLoseEvent(bool canLoseEvent)
Set the flag which prevents losing the event even though a fail condition is fulfilled.
Definition: FreeplayEvent-inl.h:84
Observer & createGeneralObserverByTypeId(uint32 typeId, const std::string &name=std::string())
Create a new general observer (i.e. not bound to a single entity, but observing the whole map) of the...
Definition: FreeplayEvent-inl.h:210
void setMultiplayerPointGain(uint32 pointGain)
Set point gain on multiplayer success.
Definition: FreeplayEvent-inl.h:129
virtual void onShutdown()
React to shutdown of the freeplay event.
Definition: FreeplayEvent-inl.h:179
void setGreatJob(bool greatJob)
Set whether or not the normal or great point gain should occur.
Definition: FreeplayEvent-inl.h:19
bool isMiniEvent() const
Definition: FreeplayEvent-inl.h:221
virtual void onRun()
React to state change from (initial) hidden state to running state.
Definition: FreeplayEvent-inl.h:184
bool isEventLocationEntitySet() const
Return "true" if the event location entity is set, else "false".
Definition: FreeplayEvent-inl.h:164
uint64_t uint64
Definition: PlatformTypes.h:184
qsf::Time getCurrentLifeTime() const
Get game time passed since this event was triggered, i.e. got its startup.
Definition: FreeplayEvent-inl.h:94
uint32 getMultiplayerPointGain() const
Get point gain on multiplayer success.
Definition: FreeplayEvent-inl.h:124
State getState() const
Get or set the music level of the event (high or low)
Definition: FreeplayEvent-inl.h:69
virtual ~FreeplayEvent()
Destructor.
Definition: FreeplayEvent-inl.h:14
qsf::Time getCurrentRunningTime() const
Get game time passed since this event was set to running state, i.e. was showed to the player...
Definition: FreeplayEvent-inl.h:99
float getEventDensityIncrease() const
Get event factor.
Definition: FreeplayEvent-inl.h:134
uint32 getNormalPointGain() const
Get point gain on normal success.
Definition: FreeplayEvent-inl.h:104
virtual bool onStartup()
React to startup of the freeplay event.
Definition: FreeplayEvent-inl.h:173
ObjectiveList & getObjectives()
Return the objectives list.
Definition: FreeplayEvent-inl.h:199
void setCanWinEvent(bool canWinEvent)
Set the flag which prevents winning the event even though all objectives succeeded.
Definition: FreeplayEvent-inl.h:74
Observer & createObserverByTypeId(uint32 typeId, uint64 entityId, const std::string &name=std::string())
Create a new observer of the specified type ID, inside the given entity.
void setNormalCreditGain(uint32 creditGain)
Set credit gain on campaign success.
Definition: FreeplayEvent-inl.h:119
float getEventDensity() const
Get the event density.
Definition: FreeplayEvent-inl.h:149
const qsf::NamedIdentifier & getEventFactoryName() const
Return original freeplay event factory's name.
Definition: FreeplayEvent-inl.h:39
uint32 getId() const
Return freeplay event ID.
Definition: FreeplayEvent-inl.h:24
void setEventDensityIncrease(float eventDensityIncrease)
Set event factor.
Definition: FreeplayEvent-inl.h:139
uint32 getNormalCreditGain() const
Get credit gain on campaign success.
Definition: FreeplayEvent-inl.h:114
std::vector< uint64 > EntityIdArray
Definition: FreeplayEvent.h:129
bool valid() const
Check if this instance contains is a valid pointer.
Definition: WeakPtr-inl.h:20
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
void setEventFactoryName(const qsf::NamedIdentifier &factoryName)
Set original freeplay event factory's name.
Definition: FreeplayEvent-inl.h:44
virtual bool onSuccess(EventResult &eventResult)
React to state change from running state to success state.
Definition: FreeplayEvent-inl.h:189
const std::string & getEventName() const
Return freeplay event's localizable name (e.g. "EM5_EVENT_TITLE_04")
Definition: FreeplayEvent-inl.h:29
void setEventDensity(float density)
Set event density.
Definition: FreeplayEvent-inl.h:154
uint32 getPlayerIndex() const
Returns the player index to which the event is assigned.
Definition: FreeplayEvent-inl.h:159
EMERGENCY 5 objective list class.
Definition: ObjectiveList.h:32
Definition: FreeplayEvent.h:92
std::vector< RecordedHintSystemMessage > RecordedHintSystemMessages
Definition: FreeplayEvent.h:151
void setNormalPointGain(uint32 pointGain)
Set point gain on normal success.
Definition: FreeplayEvent-inl.h:109
const EntityIdArray & getEntityIds() const
Get event entities.
Definition: FreeplayEvent-inl.h:144
const ObjectiveList & getObjectiveList() const
Return the objectives list.
Definition: FreeplayEvent-inl.h:49
State
Definition: FreeplayEvent.h:90
qsf::Map & getMap()
Returns the map this event takes place in, all entities of the event are inside this map...
Definition: FreeplayEvent-inl.h:54
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32