Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_systems
TimeSystem
FixedUpdateClient.cpp
Go to the documentation of this file.
1
#include "
FixedUpdateClient.hpp
"
2
#include "
TimeSystem.hpp
"
3
#include "../Defs.hpp"
4
5
namespace
iv
6
{
7
8
FixedUpdateClient::FixedUpdateClient
(
Instance
* inst,
TimeId
time ) :
9
cm( inst, this,
"FixedUpdateClient"
),
10
inst( inst ),
11
time( time ),
12
active( true )
13
{
14
auto
ts = this->
instance
()->
getSystem
<
TimeSystem
>();
15
if
( ts )
16
{
17
this->
cm
.
log
(
SRC_INFO
,
Defs::Log::TimeUpdates
,
"Stop fixed update."
);
18
ts->register_fixed_update_client(
this
, this->time );
19
}
20
}
21
22
FixedUpdateClient::~FixedUpdateClient
()
23
{
24
auto
ts = this->
instance
()->
getSystem
<
TimeSystem
>();
25
if
( ts )
26
{
27
this->
cm
.
log
(
SRC_INFO
,
Defs::Log::TimeUpdates
,
"Stop fixed update."
);
28
ts->unregister_fixed_update_client(
this
, this->time );
29
}
30
}
31
32
Instance
*
FixedUpdateClient::instance
()
const
33
{
34
return
this->inst;
35
}
36
37
void
FixedUpdateClient::fixed_update_pause
()
38
{
39
if
( !this->active )
40
return
;
41
42
this->active =
false
;
43
44
auto
ts = this->
instance
()->
getSystem
<
TimeSystem
>();
45
if
( ts )
46
{
47
this->
cm
.
log
(
SRC_INFO
,
Defs::Log::TimeUpdates
,
"Stop fixed update."
);
48
ts->unregister_fixed_update_client(
this
, this->time );
49
}
50
}
51
52
void
FixedUpdateClient::fixed_update_resume
()
53
{
54
if
( this->active )
55
return
;
56
57
this->active =
true
;
58
59
auto
ts = this->
instance
()->
getSystem
<
TimeSystem
>();
60
if
( ts )
61
{
62
this->
cm
.
log
(
SRC_INFO
,
Defs::Log::TimeUpdates
,
"Start fixed update."
);
63
ts->register_fixed_update_client(
this
, this->time );
64
}
65
}
66
67
}