blob: 6f009d8af0a8390e57ac017d476685c411c793c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include "StarSet.hpp"
#include "StarNetElement.hpp"
#include "StarDataStreamDevices.hpp"
namespace Star {
// A static group of NetElements that itself is a NetElement and serializes
// changes based on the order in which elements are added. All participants
// must externally add elements of the correct type in the correct order.
class NetElementGroup : public NetElement {
public:
NetElementGroup() = default;
NetElementGroup(NetElementGroup const&) = delete;
NetElementGroup& operator=(NetElementGroup const&) = delete;
// Add an element to the group.
void addNetElement(NetElement* element, bool propagateInterpolation = true);
// Removes all previously added elements
void clearNetElements();
void initNetVersion(NetElementVersion const* version = nullptr) override;
void netStore(DataStream& ds, NetCompatibilityRules rules = {}) const override;
void netLoad(DataStream& ds, NetCompatibilityRules rules) override;
void enableNetInterpolation(float extrapolationHint = 0.0f) override;
void disableNetInterpolation() override;
void tickNetInterpolation(float dt) override;
bool writeNetDelta(DataStream& ds, uint64_t fromVersion, NetCompatibilityRules rules = {}) const override;
void readNetDelta(DataStream& ds, float interpolationTime = 0.0f, NetCompatibilityRules rules = {}) override;
void blankNetDelta(float interpolationTime) override;
NetElementVersion const* netVersion() const;
bool netInterpolationEnabled() const;
float netExtrapolationHint() const;
private:
List<NetElement*>& filterElementsForRules(NetCompatibilityRules rules);
List<pair<NetElement*, bool>> m_elements;
Maybe<NetCompatibilityRules> m_filteredForRules;
List<NetElement*> m_filteredElementsCache;
NetElementVersion const* m_version = nullptr;
bool m_interpolationEnabled = false;
float m_extrapolationHint = 0.0f;
mutable DataStreamBuffer m_buffer;
};
inline NetElementVersion const* NetElementGroup::netVersion() const {
return m_version;
}
inline bool NetElementGroup::netInterpolationEnabled() const {
return m_interpolationEnabled;
}
inline float NetElementGroup::netExtrapolationHint() const {
return m_extrapolationHint;
}
}
|