#include <Watch.hpp>

Public Member Functions

 Watch (Instance *inst, TimeId time_type=TimeId())
 
Instanceinstance ()
 
void time_type (TimeId tt)
 
TimeId time_type ()
 
int time_ms ()
 
int delta_ms ()
 
int time_to_next_frame_ms ()
 
void timeout (int delta_ms, std::function< void() > const &fun)
 
void timeout_unique (int delta_ms, std::function< void() > const &fun)
 
void timeout_unique ()
 
void delay (std::function< void() > const &fun)
 

Public Attributes

ClientMarker cm
 

Detailed Description

Definition at line 16 of file Watch.hpp.

Constructor & Destructor Documentation

◆ Watch()

iv::Watch::Watch ( Instance inst,
TimeId  time_type = TimeId() 
)

Definition at line 8 of file Watch.cpp.

Member Function Documentation

◆ instance()

Instance * iv::Watch::instance ( )

Definition at line 29 of file Watch.cpp.

◆ time_type() [1/2]

void iv::Watch::time_type ( TimeId  tt)

Definition at line 39 of file Watch.cpp.

◆ time_type() [2/2]

TimeId iv::Watch::time_type ( )

Definition at line 34 of file Watch.cpp.

◆ time_ms()

int iv::Watch::time_ms ( )

Returns game time in milliseconds from when the TimeId started (this does not increase if TimeId used by this Watch is paused).

Definition at line 60 of file Watch.cpp.

◆ delta_ms()

int iv::Watch::delta_ms ( )

Returns delta time from last time Watch::delta_ms was called on this instance (or from when it was constructed when this is the first time it is called).

Definition at line 68 of file Watch.cpp.

◆ time_to_next_frame_ms()

int iv::Watch::time_to_next_frame_ms ( )

TODO - tohle odebrat a dát sem nějaký mechanizmus, který zaručí, že některé timeouty budou maximálně jednou za nějaký čas (ne jednou za frame, ale jednou za nějaké simulační epsilon) Možná sem ale dát jenom nějaký helper, který pomůže klientskému kódu definovat si to časové epsilon sám. Protože u některých simulací potřebujeme jiný minimální simulační krok než u ostatních - každá simulace je jinak akční a tedy jinak náchylná na chybějící kroky. Tohle se mimochodem používá zatím asi jenom v rising_sun/Behaviors/WorldPhysics/CentroidMotion.cpp.

Definition at line 126 of file Watch.cpp.

◆ timeout()

void iv::Watch::timeout ( int  delta_ms,
std::function< void() > const &  fun 
)

Called once after 'delta_ms' time passed. It is not called if this instance of Watch is destroyed before timeout.

Definition at line 81 of file Watch.cpp.

◆ timeout_unique() [1/2]

void iv::Watch::timeout_unique ( int  delta_ms,
std::function< void() > const &  fun 
)

Calling this second time will remove the previous timeout, so only one timeout_unique can be pending simultaneously.

Definition at line 87 of file Watch.cpp.

◆ timeout_unique() [2/2]

void iv::Watch::timeout_unique ( )

This cancels current timeout_unique.

Definition at line 108 of file Watch.cpp.

◆ delay()

void iv::Watch::delay ( std::function< void() > const &  fun)

Function is called once later in this frame. This is useful to avoid dangerous recursions. It is not called if this instance of Watch is destroyed before it is called.

Definition at line 120 of file Watch.cpp.

Member Data Documentation

◆ cm

ClientMarker iv::Watch::cm

Definition at line 19 of file Watch.hpp.


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