Emergency 20 Dokumentation  4.2.0
DataCacheComponentExistenceTrackingBase.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"
15 
16 #include <qsf/base/WeakPtr.h>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24  namespace multiplayer
25  {
26 
27 
28  //[-------------------------------------------------------]
29  //[ Classes ]
30  //[-------------------------------------------------------]
35  template<class TrackedComponentType>
37  {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Public methods ]
42  //[-------------------------------------------------------]
43  public:
48  inline DataCacheComponentExistenceTrackingBase(const qsf::Entity& entity, bool noDestruction = false);
49 
50 
51  //[-------------------------------------------------------]
52  //[ Public virtual em5::multiplayer::DataCacheBase methods ]
53  //[-------------------------------------------------------]
54  public:
55  inline virtual bool prepareForUpdate(const qsf::Entity& targetEntity, const qsf::Clock& clock) override;
56  inline virtual void updateData(qsf::game::BitStream& bitStream, bool force) override;
57  inline virtual void setData(const qsf::game::BitStream& bitStream, const int32 receivedHostTickCount) override;
58  inline virtual void interpolate(qsf::Entity& targetEntity, const qsf::Clock& clock, const int32 receivedHostTickCount) override;
59 
60 
61  //[-------------------------------------------------------]
62  //[ Protected methods ]
63  //[-------------------------------------------------------]
64  protected:
65  inline TrackedComponentType* getComponent(const qsf::Entity& entity);
66  inline bool hasEntityComponentFromStream();
67  inline bool hasEntityComponent();
68  inline bool hasComponentExistenceChanged();
69 
70 
71  //[-------------------------------------------------------]
72  //[ Private data ]
73  //[-------------------------------------------------------]
74  private:
76  uint8 mComponentChangeCounter;
77  bool mNoDestruction;
78  bool mEntityHasComponentFromStream;
79 
80  bool mEntityHasComponent;
81  bool mComponentExistenceChanged;
82 
83  struct HistoryEntry
84  {
85  int32 tickCount;
86  bool mEntityHasComponent;
87  bool mComponentExistenceChanged;
88  };
89 
90  std::vector<HistoryEntry> mHistoryList;
91 
92 
93  };
94 
95 
96 //[-------------------------------------------------------]
97 //[ Namespace ]
98 //[-------------------------------------------------------]
99  } // multiplayer
100 } // em5
101 
102 
103 //[-------------------------------------------------------]
104 //[ Implementation ]
105 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 multiplayer data cache base class.
Definition: DataCacheBase.h:48
bool hasEntityComponent()
Definition: DataCacheComponentExistenceTrackingBase-inl.h:176
TrackedComponentType * getComponent(const qsf::Entity &entity)
Definition: DataCacheComponentExistenceTrackingBase-inl.h:164
Entity class.
Definition: Entity.h:46
Clock class.
Definition: Clock.h:33
virtual bool prepareForUpdate(const qsf::Entity &targetEntity, const qsf::Clock &clock) override
Prepares for an update.
Definition: DataCacheComponentExistenceTrackingBase-inl.h:45
DataCacheComponentExistenceTrackingBase(const qsf::Entity &entity, bool noDestruction=false)
Constructor.
Definition: DataCacheComponentExistenceTrackingBase-inl.h:27
Game bit stream class (just a wrapper for linnet bit stream)
Definition: BitStream.h:40
bool hasComponentExistenceChanged()
Definition: DataCacheComponentExistenceTrackingBase-inl.h:182
virtual void setData(const qsf::game::BitStream &bitStream, const int32 receivedHostTickCount) override
Reads the data from the bit stream.
Definition: DataCacheComponentExistenceTrackingBase-inl.h:95
virtual void updateData(qsf::game::BitStream &bitStream, bool force) override
Updates the cache and writes any changed data to the given bit stream.
Definition: DataCacheComponentExistenceTrackingBase-inl.h:85
signed int int32
Definition: PlatformTypes.h:180
EMERGENCY 5 multiplayer data cache base class which tracks component existence.
Definition: DataCacheComponentExistenceTrackingBase.h:36
virtual void interpolate(qsf::Entity &targetEntity, const qsf::Clock &clock, const int32 receivedHostTickCount) override
Does any interpolation steps needed to apply the cached data to the entity.
Definition: DataCacheComponentExistenceTrackingBase-inl.h:122
bool hasEntityComponentFromStream()
Definition: DataCacheComponentExistenceTrackingBase-inl.h:170
unsigned char uint8
Definition: PlatformTypes.h:175