v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
54
source/core/StarNetElementSyncGroup.hpp
Normal file
54
source/core/StarNetElementSyncGroup.hpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#ifndef STAR_NET_ELEMENT_SYNC_GROUP_HPP
|
||||
#define STAR_NET_ELEMENT_SYNC_GROUP_HPP
|
||||
|
||||
#include "StarNetElementGroup.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
// NetElementGroup class that works with NetElements that are not automatically
|
||||
// kept up to date with working data, and users need to be notified when to
|
||||
// synchronize with working data.
|
||||
class NetElementSyncGroup : public NetElementGroup {
|
||||
public:
|
||||
void enableNetInterpolation(float extrapolationHint = 0.0f) override;
|
||||
void disableNetInterpolation() override;
|
||||
void tickNetInterpolation(float dt) override;
|
||||
|
||||
void netStore(DataStream& ds) const override;
|
||||
void netLoad(DataStream& ds) override;
|
||||
|
||||
bool writeNetDelta(DataStream& ds, uint64_t fromStep) const override;
|
||||
void readNetDelta(DataStream& ds, float interpolationTime = 0.0f) override;
|
||||
void blankNetDelta(float interpolationTime = 0.0f) override;
|
||||
|
||||
protected:
|
||||
// Notifies when data needs to be pulled from NetElements, load is true if
|
||||
// this is due to a netLoad call
|
||||
virtual void netElementsNeedLoad(bool load);
|
||||
// Notifies when data needs to be pushed to NetElements
|
||||
virtual void netElementsNeedStore();
|
||||
|
||||
private:
|
||||
bool m_hasRecentChanges = false;
|
||||
float m_recentDeltaTime = 0.0f;
|
||||
bool m_recentDeltaWasBlank = false;
|
||||
};
|
||||
|
||||
// Same as a NetElementSyncGroup, except instead of protected methods, calls
|
||||
// optional callback functions.
|
||||
class NetElementCallbackGroup : public NetElementSyncGroup {
|
||||
public:
|
||||
void setNeedsLoadCallback(function<void(bool)> needsLoadCallback);
|
||||
void setNeedsStoreCallback(function<void()> needsStoreCallback);
|
||||
|
||||
private:
|
||||
void netElementsNeedLoad(bool load) override;
|
||||
void netElementsNeedStore() override;
|
||||
|
||||
function<void(bool)> m_netElementsNeedLoad;
|
||||
function<void()> m_netElementsNeedStore;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue