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 {
39 int32_t fired_count;
40 bool active;
43
45typedef struct EcsRateFilter {
47 int32_t rate;
48 int32_t tick_count;
51
52
71FLECS_API
73 ecs_world_t *world,
74 ecs_entity_t tick_source,
76
96FLECS_API
98 const ecs_world_t *world,
99 ecs_entity_t tick_source);
100
118FLECS_API
120 ecs_world_t *world,
121 ecs_entity_t tick_source,
123
132FLECS_API
134 const ecs_world_t *world,
135 ecs_entity_t tick_source);
136
146FLECS_API
148 ecs_world_t *world,
149 ecs_entity_t tick_source);
150
158FLECS_API
160 ecs_world_t *world,
161 ecs_entity_t tick_source);
162
193FLECS_API
195 ecs_world_t *world,
196 ecs_entity_t tick_source,
197 int32_t rate,
198 ecs_entity_t source);
199
222FLECS_API
224 ecs_world_t *world,
226 ecs_entity_t tick_source);
227
228
232
233FLECS_API
234void FlecsTimerImport(
235 ecs_world_t *world);
236
237#ifdef __cplusplus
238}
239#endif
240
241#endif
242
245#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:219
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:228
#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:45
int32_t rate
Rate of the rate filter.
Definition: timer.h:47
int32_t tick_count
Number of times the rate filter ticked.
Definition: timer.h:48
ecs_ftime_t time_elapsed
Time elapsed since last tick.
Definition: timer.h:49
ecs_entity_t src
Source of the rate filter.
Definition: timer.h:46
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:40
bool single_shot
Is this a single shot timer.
Definition: timer.h:41
ecs_ftime_t overshoot
Used to correct returned interval time.
Definition: timer.h:38
int32_t fired_count
Number of times ticked.
Definition: timer.h:39
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).