Leviathan  0.8.0.0
Leviathan game engine
Leviathan::ReceivedSystem Class Reference

Interpolates states for received objects and handles locally controlled entities. More...

#include <Systems.h>

Public Member Functions

DLLEXPORT void Run (std::unordered_map< ObjectID, Received *> &index, GameWorld &world)
 

Detailed Description

Interpolates states for received objects and handles locally controlled entities.

Definition at line 155 of file Systems.h.

Member Function Documentation

◆ Run()

DLLEXPORT void ReceivedSystem::Run ( std::unordered_map< ObjectID, Received *> &  index,
GameWorld world 
)

Definition at line 93 of file Systems.cpp.

95 {
96  const float progress = world.GetTickProgress();
97  const auto tick = world.GetTickNumber();
98 
99  for(auto iter = Index.begin(); iter != Index.end(); ++iter) {
100 
101  auto& node = *iter->second;
102 
103  // Unmarked nodes should have invalid interpolation status
104  if(!node.Marked)
105  return;
106 
107  if(!node.LocallyControlled) {
108 
109  // Interpolate received states //
110  float adjustedprogress = progress;
111  const Received::StoredState* first;
112  const Received::StoredState* second;
113 
114  try {
115  node.GetServerSentStates(&first, &second, tick, adjustedprogress);
116  } catch(const InvalidState&) {
117 
118  // If not found unmark to avoid running unneeded //
119  node.Marked = false;
120  continue;
121  }
122 
123  DEBUG_BREAK;
124  // first->Interpolate(second, adjustedprogress);
125 
126  } else {
127 
128  // Send updates to the server //
129  }
130  }
131 }
Storage class for ObjectDeltaStateData.
Definition: Components.h:165
DLLEXPORT float GetTickProgress() const
Returns float between 0.f and 1.f based on how far current tick has progressed.
Definition: GameWorld.cpp:657
DLLEXPORT int GetTickNumber() const
Returns the current tick.
Definition: GameWorld.cpp:652

The documentation for this class was generated from the following files: