Leviathan  0.8.0.0
Leviathan game engine
Leviathan::StateCreationSystem< UsedComponent, ComponentState > Class Template Reference

Base class for all systems that create states from changed components. More...

#include <System.h>

Public Member Functions

void Run (GameWorld &world, std::unordered_map< ObjectID, UsedComponent * > &index, StateHolder< ComponentState > &heldstates, int worldtick)
 

Detailed Description

template<class UsedComponent, class ComponentState>
class Leviathan::StateCreationSystem< UsedComponent, ComponentState >

Base class for all systems that create states from changed components.

Definition at line 192 of file System.h.

Member Function Documentation

◆ Run()

template<class UsedComponent, class ComponentState>
void Leviathan::StateCreationSystem< UsedComponent, ComponentState >::Run ( GameWorld world,
std::unordered_map< ObjectID, UsedComponent * > &  index,
StateHolder< ComponentState > &  heldstates,
int  worldtick 
)
inline

Definition at line 194 of file System.h.

196  {
197  // TODO: find a better way (see the comment a few lines down why this is here)
198  if(!world.GetNetworkSettings().DoInterpolation)
199  return;
200 
201  const bool authoritative = world.GetNetworkSettings().IsAuthoritative;
202 
203  for(auto iter = index.begin(); iter != index.end(); ++iter) {
204  auto& component = *iter->second;
205 
206  if(!component.Marked)
207  continue;
208 
209  // And only for locally controlled entities
210  if(!authoritative && !world.IsUnderOurLocalControl(iter->first))
211  continue;
212 
213  // Ignore creating states on the server when using local control as that causes
214  // issues Actually this whole system is disabled when interpolating isn't needed
215 
216  // Needs a new state //
217  if(heldstates.CreateStateIfChanged(iter->first, component, worldtick)) {
218 
219  component.StateMarked = true;
220  }
221 
222  component.Marked = false;
223  }
224  }

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