Emergency 20 Dokumentation  4.2.0
InhabitantComponent.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/Export.h"
14 
16 #include <qsf/job/JobProxy.h>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
37  {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Public definitions ]
42  //[-------------------------------------------------------]
43  public:
44  static const uint32 COMPONENT_ID;
45  static const uint32 ACTION_PRIORITY;
47 
49  {
50  GOTO_DESTINATION=0,
53  };
54 
55 
56  //[-------------------------------------------------------]
57  //[ Public methods ]
58  //[-------------------------------------------------------]
59  public:
60  explicit InhabitantComponent(qsf::Prototype* prototype);
61  virtual ~InhabitantComponent();
62 
63  virtual void serialize(qsf::BinarySerializer& serializer) override;
64 
65  // Get / set the priority of the actions pushed
67  uint32 getActionPriority() const;
68  void setActionPriority(uint32 priority);
70 
71  // Get / set the home's entity id
73  uint64 getHomeEntityId() const;
74  void setHomeEntityId(uint64 entityId);
76 
77  // Get / set the destination's entity id
79  uint64 getDestinationEntityId() const;
80  void setDestinationEntityId(uint64 entityId);
82 
83  // Get / set the inhabitant's current mode
85  InhabitantMode getInhabitantMode() const;
86  void setInhabitantMode(InhabitantMode mode);
88 
89 
90  //[-------------------------------------------------------]
91  //[ Protected virtual qsf::Component methods ]
92  //[-------------------------------------------------------]
93  protected:
94  virtual void onSetSimulating(bool simulating) override;
95 
96 
97  //[-------------------------------------------------------]
98  //[ Private methods ]
99  //[-------------------------------------------------------]
100  private:
101  // Command the entity to go to the supplied target-entity.
102  bool goToEntity(uint64 targetEntityId);
103 
104  // Main processing method. Triggers actions depending on mode and situation.
105  void updateJob(const qsf::JobArguments& jobArguments);
106 
107  // Implemented as unregistering the component and registering again with the time delay defined as parameter, so that the update-interval can be changed easily on demand.
108  void setUpdateFrequency(qsf::Time updateInterval);
109 
110 
111  //[-------------------------------------------------------]
112  //[ Private data ]
113  //[-------------------------------------------------------]
114  private:
115  uint32 mActionPriority;
116  uint64 mDestinationEntityId;
117 
118  uint64 mHomeEntityId;
119  InhabitantMode mInhabitantMode;
120  qsf::JobProxy mUpdateJobProxy;
121 
122 
123  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
124 
125 
126  };
127 
128 
129 //[-------------------------------------------------------]
130 //[ Namespace ]
131 //[-------------------------------------------------------]
132 } // em5
133 
134 
135 //[-------------------------------------------------------]
136 //[ Implementation ]
137 //[-------------------------------------------------------]
139 
140 
141 //[-------------------------------------------------------]
142 //[ CAMP reflection system ]
143 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
static const uint32 ACTION_PRIORITY
"ActionPriority" unique class property ID inside the class
Definition: InhabitantComponent.h:45
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
InhabitantMode
Definition: InhabitantComponent.h:48
static const uint32 COMPONENT_ID
"em5::InhabitantComponent" unique component ID
Definition: InhabitantComponent.h:44
uint64_t uint64
Definition: PlatformTypes.h:184
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
static const uint32 DESTINATION_ENTITY_ID
"DestinationEntityId" unique class property ID inside the class
Definition: InhabitantComponent.h:46
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Prototype class.
Definition: Prototype.h:100
Definition: InhabitantComponent.h:36
Binary serializer class.
Definition: BinarySerializer.h:35
Definition: InhabitantComponent.h:51
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32