Flecs: include/flecs/addons/timer.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1
8
9#ifdef FLECS_TIMER
10
18
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
35 typedef struct EcsTimer {
36 ecs_ftime_t timeout;
37 ecs_ftime_t time;
38 ecs_ftime_t overshoot;
39 int32_t fired_count;
40 bool active;
41 bool single_shot;
42} EcsTimer;
43
45 typedef struct EcsRateFilter {
46 ecs_entity_t src;
47 int32_t rate;
48 int32_t tick_count;
49 ecs_ftime_t time_elapsed;
50} EcsRateFilter;
51
52
71FLECS_API
72 ecs_entity_t ecs_set_timeout(
73 ecs_world_t *world,
74 ecs_entity_t tick_source,
75 ecs_ftime_t timeout);
76
96FLECS_API
97 ecs_ftime_t ecs_get_timeout(
98 const ecs_world_t *world,
99 ecs_entity_t tick_source);
100
118FLECS_API
119 ecs_entity_t ecs_set_interval(
120 ecs_world_t *world,
121 ecs_entity_t tick_source,
122 ecs_ftime_t interval);
123
132FLECS_API
133 ecs_ftime_t ecs_get_interval(
134 const ecs_world_t *world,
135 ecs_entity_t tick_source);
136
143FLECS_API
144 void ecs_start_timer(
145 ecs_world_t *world,
146 ecs_entity_t tick_source);
147
154FLECS_API
155 void ecs_stop_timer(
156 ecs_world_t *world,
157 ecs_entity_t tick_source);
158
165FLECS_API
166 void ecs_reset_timer(
167 ecs_world_t *world,
168 ecs_entity_t tick_source);
169
176FLECS_API
177 void ecs_randomize_timers(
178 ecs_world_t *world);
179
210FLECS_API
211 ecs_entity_t ecs_set_rate(
212 ecs_world_t *world,
213 ecs_entity_t tick_source,
214 int32_t rate,
215 ecs_entity_t source);
216
239FLECS_API
240 void ecs_set_tick_source(
241 ecs_world_t *world,
242 ecs_entity_t system,
243 ecs_entity_t tick_source);
244
245
249
258FLECS_API
259 void FlecsTimerImport(
260 ecs_world_t *world);
261
262#ifdef __cplusplus
263}
264#endif
265
266#endif
267
269
270#endif
ecs_get_timeout
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.
ecs_reset_timer
FLECS_API void ecs_reset_timer(ecs_world_t *world, ecs_entity_t tick_source)
Reset time value of timer to 0.
ecs_set_interval
FLECS_API ecs_entity_t ecs_set_interval(ecs_world_t *world, ecs_entity_t tick_source, ecs_ftime_t interval)
Set timer interval.
ecs_get_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.
ecs_set_tick_source
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.
ecs_set_rate
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.
FlecsTimerImport
FLECS_API void FlecsTimerImport(ecs_world_t *world)
Timer module import function.
ecs_start_timer
FLECS_API void ecs_start_timer(ecs_world_t *world, ecs_entity_t tick_source)
Start timer.
ecs_randomize_timers
FLECS_API void ecs_randomize_timers(ecs_world_t *world)
Enable randomizing initial time value of timers.
ecs_set_timeout
FLECS_API ecs_entity_t ecs_set_timeout(ecs_world_t *world, ecs_entity_t tick_source, ecs_ftime_t timeout)
Set timer timeout.
ecs_stop_timer
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_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:365
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:409
ecs_ftime_t
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
EcsRateFilter
Apply a rate filter to a tick source.
Definition timer.h:45
EcsRateFilter::rate
int32_t rate
Rate of the rate filter.
Definition timer.h:47
EcsRateFilter::tick_count
int32_t tick_count
Number of times the rate filter ticked.
Definition timer.h:48
EcsRateFilter::time_elapsed
ecs_ftime_t time_elapsed
Time elapsed since last tick.
Definition timer.h:49
EcsRateFilter::src
ecs_entity_t src
Source of the rate filter.
Definition timer.h:46
EcsTimer
Component used for one shot/interval timer functionality.
Definition timer.h:35
EcsTimer::time
ecs_ftime_t time
Incrementing time value.
Definition timer.h:37
EcsTimer::active
bool active
Is the timer active or not.
Definition timer.h:40
EcsTimer::single_shot
bool single_shot
Is this a single shot timer.
Definition timer.h:41
EcsTimer::overshoot
ecs_ftime_t overshoot
Used to correct returned interval time.
Definition timer.h:38
EcsTimer::fired_count
int32_t fired_count
Number of times ticked.
Definition timer.h:39
EcsTimer::timeout
ecs_ftime_t timeout
Timer timeout period.
Definition timer.h:36