Flecs v3.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1
9#ifdef FLECS_TIMER
10
19#ifndef FLECS_MODULE
20#define FLECS_MODULE
21#endif
22
23#ifndef FLECS_PIPELINE
24#define FLECS_PIPELINE
25#endif
26
27#ifndef FLECS_TIMER_H
28#define FLECS_TIMER_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
35typedef struct EcsTimer {
38 int32_t fired_count;
39 bool active;
42
44typedef struct EcsRateFilter {
46 int32_t rate;
47 int32_t tick_count;
50
51
70FLECS_API
72 ecs_world_t *world,
73 ecs_entity_t tick_source,
75
95FLECS_API
97 const ecs_world_t *world,
98 ecs_entity_t tick_source);
99
117FLECS_API
119 ecs_world_t *world,
120 ecs_entity_t tick_source,
122
131FLECS_API
133 const ecs_world_t *world,
134 ecs_entity_t tick_source);
135
145FLECS_API
147 ecs_world_t *world,
148 ecs_entity_t tick_source);
149
157FLECS_API
159 ecs_world_t *world,
160 ecs_entity_t tick_source);
161
192FLECS_API
194 ecs_world_t *world,
195 ecs_entity_t tick_source,
196 int32_t rate,
197 ecs_entity_t source);
198
221FLECS_API
223 ecs_world_t *world,
225 ecs_entity_t tick_source);
226
227
231
232FLECS_API
233void FlecsTimerImport(
234 ecs_world_t *world);
235
236#ifdef __cplusplus
237}
238#endif
239
240#endif
241
244#endif
FLECS_API ecs_ftime_t ecs_get_timeout(const ecs_world_t *world, ecs_entity_t tick_source)
Get current timeout value for the specified timer.
FLECS_API ecs_entity_t ecs_set_interval(ecs_world_t *world, ecs_entity_t tick_source, ecs_ftime_t interval)
Set timer interval.
FLECS_API ecs_ftime_t ecs_get_interval(const ecs_world_t *world, ecs_entity_t tick_source)
Get current interval value for the specified timer.
FLECS_API void ecs_set_tick_source(ecs_world_t *world, ecs_entity_t system, ecs_entity_t tick_source)
Assign tick source to system.
FLECS_API ecs_entity_t ecs_set_rate(ecs_world_t *world, ecs_entity_t tick_source, int32_t rate, ecs_entity_t source)
Set rate filter.
FLECS_API void ecs_start_timer(ecs_world_t *world, ecs_entity_t tick_source)
Start timer.
FLECS_API ecs_entity_t ecs_set_timeout(ecs_world_t *world, ecs_entity_t tick_source, ecs_ftime_t timeout)
Set timer timeout.
FLECS_API void ecs_stop_timer(ecs_world_t *world, ecs_entity_t tick_source)
Stop timer This operation stops a timer from triggering.
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:220
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:229
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition: flecs.h:42
Apply a rate filter to a tick source.
Definition: timer.h:44
int32_t rate
Rate of the rate filter.
Definition: timer.h:46
int32_t tick_count
Number of times the rate filter ticked.
Definition: timer.h:47
ecs_ftime_t time_elapsed
Time elapsed since last tick.
Definition: timer.h:48
ecs_entity_t src
Source of the rate filter.
Definition: timer.h:45
Component used for one shot/interval timer functionality.
Definition: timer.h:35
ecs_ftime_t time
Incrementing time value.
Definition: timer.h:37
bool active
Is the timer active or not.
Definition: timer.h:39
bool single_shot
Is this a single shot timer.
Definition: timer.h:40
int32_t fired_count
Number of times ticked.
Definition: timer.h:38
ecs_ftime_t timeout
Timer timeout period.
Definition: timer.h:36
flecs::system_builder< Components... > system(Args &&... args) const
Create a new system.
ecs_ftime_t timeout()
Get timeout.
ecs_ftime_t interval()
Get interval.
void rate(int32_t rate)
Set system rate (system is its own tick source).