Emergency 20 Dokumentation  4.2.0
GhostComponent.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 
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
34  {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Public definitions ]
39  //[-------------------------------------------------------]
40  public:
41  static const uint32 COMPONENT_ID;
42  static const uint32 RENDER_QUEUE_ID;
43 
44 
45  //[-------------------------------------------------------]
46  //[ Public methods ]
47  //[-------------------------------------------------------]
48  public:
49  inline GhostComponent(qsf::Prototype* prototype);
50 
51  inline uint32 getPlayerId() const;
52  void setPlayerId(uint32 playerId);
53 
58  inline bool isGhost() const;
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public virtual qsf::Component methods ]
63  //[-------------------------------------------------------]
64  public:
65  virtual void serialize(qsf::BinarySerializer& serializer) override;
66 
67 
68  //[-------------------------------------------------------]
69  //[ Protected virtual qsf::Component methods ]
70  //[-------------------------------------------------------]
71  protected:
72  //[-------------------------------------------------------]
73  //[ Lifecycle ]
74  //[-------------------------------------------------------]
75  virtual bool onStartup() override;
76  virtual void onShutdown() override;
77  inline virtual bool implementsOnComponentPropertyChange() const override { return true; }
78  virtual void onComponentPropertyChange(const Component& component, uint32 propertyId) override;
79 
80 
81  //[-------------------------------------------------------]
82  //[ Protected virtual qsf::MovableObjectRenderingListener methods ]
83  //[-------------------------------------------------------]
84  protected:
85  virtual qsf::Component* getMovableObjectRenderingListenerComponent() override;
86  virtual void onObjectRendering(const qsf::Component& component, const Ogre::Camera& ogreCamera) override;
87 
88 
89  //[-------------------------------------------------------]
90  //[ Private methods ]
91  //[-------------------------------------------------------]
92  private:
93  void setupGhostValues(qsf::Entity& entity);
94  void resetGhostValues(qsf::Entity& entity);
95  void synchronizeInternalAndRendererDataJob(const qsf::JobArguments& jobArguments);
96 
97 
98  //[-------------------------------------------------------]
99  //[ Private data ]
100  //[-------------------------------------------------------]
101  private:
102  uint16 mApplyDelay;
103  uint32 mPlayerId;
104  uint32 mLocalPlayerId;
105  float mAlphaValue;
106  bool mInternalIsGhost;
107  bool mRendererIsGhost;
108  qsf::JobProxy mSynchronizeJobProxy;
109 
110 
111  //[-------------------------------------------------------]
112  //[ CAMP reflection system ]
113  //[-------------------------------------------------------]
114  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
115 
116 
117  };
118 
119 
120 //[-------------------------------------------------------]
121 //[ Namespace ]
122 //[-------------------------------------------------------]
123 } // em5
124 
125 
126 //[-------------------------------------------------------]
127 //[ Implementation ]
128 //[-------------------------------------------------------]
130 
131 
132 //[-------------------------------------------------------]
133 //[ CAMP reflection system ]
134 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Ghost component.
Definition: GhostComponent.h:33
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
Job proxy based OGRE movable object rendering listener.
Definition: JobProxyMovableObjectRenderingListener.h:31
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
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
virtual bool implementsOnComponentPropertyChange() const override
Signal whether this component needs the "onComponentPropertyChange" callback at all.
Definition: GhostComponent.h:77
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
unsigned short uint16
Definition: PlatformTypes.h:178
static const uint32 COMPONENT_ID
"em5::GhostComponent" unique component ID
Definition: GhostComponent.h:41
Prototype class.
Definition: Prototype.h:100
Binary serializer class.
Definition: BinarySerializer.h:35
static const uint32 RENDER_QUEUE_ID
Definition: GhostComponent.h:42