Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
world.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace flecs
9{
10
11/* Static helper functions to assign a component value */
12
13// set(T&&), T = constructible
14template <typename T, if_t< is_flecs_constructible<T>::value > = 0>
15inline void set(world_t *world, flecs::entity_t entity, T&& value, flecs::id_t id) {
16 ecs_assert(_::cpp_type<T>::size() != 0, ECS_INVALID_PARAMETER, NULL);
17
18 T& dst = *static_cast<T*>(ecs_get_mut_id(world, entity, id));
19 dst = FLECS_MOV(value);
20
21 ecs_modified_id(world, entity, id);
22}
23
24// set(const T&), T = constructible
25template <typename T, if_t< is_flecs_constructible<T>::value > = 0>
26inline void set(world_t *world, flecs::entity_t entity, const T& value, flecs::id_t id) {
27 ecs_assert(_::cpp_type<T>::size() != 0, ECS_INVALID_PARAMETER, NULL);
28
29 T& dst = *static_cast<T*>(ecs_get_mut_id(world, entity, id));
30 dst = value;
31
32 ecs_modified_id(world, entity, id);
33}
34
35// set(T&&), T = not constructible
36template <typename T, if_not_t< is_flecs_constructible<T>::value > = 0>
37inline void set(world_t *world, flecs::entity_t entity, T&& value, flecs::id_t id) {
38 ecs_assert(_::cpp_type<T>::size() != 0, ECS_INVALID_PARAMETER, NULL);
39
40 T& dst = *static_cast<remove_reference_t<T>*>(ecs_get_mut_id(world, entity, id));
41
42 dst = FLECS_MOV(value);
43
44 ecs_modified_id(world, entity, id);
45}
46
47// set(const T&), T = not constructible
48template <typename T, if_not_t< is_flecs_constructible<T>::value > = 0>
49inline void set(world_t *world, flecs::entity_t entity, const T& value, flecs::id_t id) {
50 ecs_assert(_::cpp_type<T>::size() != 0, ECS_INVALID_PARAMETER, NULL);
51
52 T& dst = *static_cast<T*>(ecs_get_mut_id(world, entity, id));
53 dst = value;
54
55 ecs_modified_id(world, entity, id);
56}
57
58// emplace for T(Args...)
59template <typename T, typename ... Args, if_t<
60 std::is_constructible<actual_type_t<T>, Args...>::value ||
61 std::is_default_constructible<actual_type_t<T>>::value > = 0>
62inline void emplace(world_t *world, flecs::entity_t entity, flecs::id_t id, Args&&... args) {
63 ecs_assert(_::cpp_type<T>::size() != 0, ECS_INVALID_PARAMETER, NULL);
64 T& dst = *static_cast<T*>(ecs_emplace_id(world, entity, id));
65
66 FLECS_PLACEMENT_NEW(&dst, T{FLECS_FWD(args)...});
67
68 ecs_modified_id(world, entity, id);
69}
70
71// set(T&&)
72template <typename T, typename A>
73inline void set(world_t *world, entity_t entity, A&& value) {
74 id_t id = _::cpp_type<T>::id(world);
75 flecs::set(world, entity, FLECS_FWD(value), id);
76}
77
78// set(const T&)
79template <typename T, typename A>
80inline void set(world_t *world, entity_t entity, const A& value) {
81 id_t id = _::cpp_type<T>::id(world);
82 flecs::set(world, entity, value, id);
83}
84
89inline flecs::id_t strip_generation(flecs::entity_t e) {
90 return ecs_strip_generation(e);
91}
92
95inline uint32_t get_generation(flecs::entity_t e) {
96 return ECS_GENERATION(e);
97}
98
99struct scoped_world;
100
113struct world {
116 explicit world()
117 : m_world( ecs_init() )
118 , m_owned( true ) { init_builtin_components(); }
119
124 explicit world(int argc, char *argv[])
125 : m_world( ecs_init_w_args(argc, argv) )
126 , m_owned( true ) { init_builtin_components(); }
127
130 explicit world(world_t *w)
131 : m_world( w )
132 , m_owned( false ) { }
133
136 world(const world& obj) = delete;
137
138 world(world&& obj) {
139 m_world = obj.m_world;
140 m_owned = obj.m_owned;
141 obj.m_world = nullptr;
142 obj.m_owned = false;
143 }
144
145 /* Implicit conversion to world_t* */
146 operator world_t*() const { return m_world; }
147
150 world& operator=(const world& obj) = delete;
151
152 world& operator=(world&& obj) {
153 this->~world();
154
155 m_world = obj.m_world;
156 m_owned = obj.m_owned;
157 obj.m_world = nullptr;
158 obj.m_owned = false;
159 return *this;
160 }
161
162 ~world() {
163 if (m_owned && ecs_stage_is_async(m_world)) {
164 ecs_async_stage_free(m_world);
165 } else
166 if (m_owned && m_world) {
167 ecs_fini(m_world);
168 }
169 }
170
172 void reset() {
173 // Can only reset the world if we own the world object.
174 ecs_assert(this->m_owned, ECS_INVALID_OPERATION, NULL);
175 ecs_fini(m_world);
176 m_world = ecs_init();
177 }
178
181 world_t* c_ptr() const {
182 return m_world;
183 }
184
188 void quit() const {
189 ecs_quit(m_world);
190 }
191
194 void atfini(ecs_fini_action_t action, void *ctx) const {
195 ecs_atfini(m_world, action, ctx);
196 }
197
200 bool should_quit() const {
201 return ecs_should_quit(m_world);
202 }
203
222 ecs_ftime_t frame_begin(float delta_time = 0) const {
223 return ecs_frame_begin(m_world, delta_time);
224 }
225
232 void frame_end() const {
233 ecs_frame_end(m_world);
234 }
235
254 bool readonly_begin() const {
255 return ecs_readonly_begin(m_world);
256 }
257
265 void readonly_end() const {
266 ecs_readonly_end(m_world);
267 }
268
275 bool defer_begin() const {
276 return ecs_defer_begin(m_world);
277 }
278
284 bool defer_end() const {
285 return ecs_defer_end(m_world);
286 }
287
290 bool is_deferred() const {
291 return ecs_is_deferred(m_world);
292 }
293
306 void set_stage_count(int32_t stages) const {
307 ecs_set_stage_count(m_world, stages);
308 }
309
315 int32_t get_stage_count() const {
316 return ecs_get_stage_count(m_world);
317 }
318
325 int32_t get_stage_id() const {
326 return ecs_get_stage_id(m_world);
327 }
328
335 bool is_stage() const {
337 ecs_poly_is(m_world, ecs_world_t) ||
338 ecs_poly_is(m_world, ecs_stage_t),
339 ECS_INVALID_PARAMETER, NULL);
340 return ecs_poly_is(m_world, ecs_stage_t);
341 }
342
359 void set_automerge(bool automerge) const {
360 ecs_set_automerge(m_world, automerge);
361 }
362
371 void merge() const {
372 ecs_merge(m_world);
373 }
374
389 flecs::world get_stage(int32_t stage_id) const {
390 return flecs::world(ecs_get_stage(m_world, stage_id));
391 }
392
411 auto result = flecs::world(ecs_async_stage_new(m_world));
412 result.m_owned = true;
413 return result;
414 }
415
423 /* Safe cast, mutability is checked */
424 return flecs::world(
425 m_world ? const_cast<flecs::world_t*>(ecs_get_world(m_world)) : nullptr);
426 }
427
434 bool is_readonly() const {
435 return ecs_stage_is_readonly(m_world);
436 }
437
444 void set_context(void* ctx) const {
445 ecs_set_context(m_world, ctx);
446 }
447
452 void* get_context() const {
453 return ecs_get_context(m_world);
454 }
455
461 void dim(int32_t entity_count) const {
462 ecs_dim(m_world, entity_count);
463 }
464
471 void set_entity_range(entity_t min, entity_t max) const {
472 ecs_set_entity_range(m_world, min, max);
473 }
474
483 void enable_range_check(bool enabled) const {
484 ecs_enable_range_check(m_world, enabled);
485 }
486
493 flecs::entity set_scope(const flecs::entity_t scope) const;
494
500 flecs::entity get_scope() const;
501
505 template <typename T>
506 flecs::entity set_scope() const;
507
510 flecs::entity_t* set_lookup_path(const flecs::entity_t *search_path) const {
511 return ecs_set_lookup_path(m_world, search_path);
512 }
513
518 flecs::entity lookup(const char *name) const;
519
522 template <typename T, if_t< !is_callable<T>::value > = 0>
523 void set(const T& value) const {
524 flecs::set<T>(m_world, _::cpp_type<T>::id(m_world), value);
525 }
526
529 template <typename T, if_t< !is_callable<T>::value > = 0>
530 void set(T&& value) const {
531 flecs::set<T>(m_world, _::cpp_type<T>::id(m_world),
532 FLECS_FWD(value));
533 }
534
537 template <typename First, typename Second, typename P = flecs::pair<First, Second>,
538 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
539 void set(const A& value) const {
540 flecs::set<P>(m_world, _::cpp_type<First>::id(m_world), value);
541 }
542
545 template <typename First, typename Second, typename P = flecs::pair<First, Second>,
546 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value> = 0>
547 void set(A&& value) const {
548 flecs::set<P>(m_world, _::cpp_type<First>::id(m_world), FLECS_FWD(value));
549 }
550
553 template <typename First, typename Second>
554 void set(Second second, const First& value) const;
555
558 template <typename First, typename Second>
559 void set(Second second, First&& value) const;
560
563 template <typename Func, if_t< is_callable<Func>::value > = 0 >
564 void set(const Func& func) const;
565
566 template <typename T, typename ... Args>
567 void emplace(Args&&... args) const {
568 flecs::id_t component_id = _::cpp_type<T>::id(m_world);
569 flecs::emplace<T>(m_world, component_id, component_id,
570 FLECS_FWD(args)...);
571 }
572
575 template <typename T>
576 T* get_mut() const;
577
580 template <typename T>
581 void modified() const;
582
585 template <typename T>
586 ref<T> get_ref() const;
587
590 template <typename T>
591 const T* get() const;
592
595 template <typename First, typename Second, typename P = flecs::pair<First, Second>,
596 typename A = actual_type_t<P>>
597 const A* get() const;
598
601 template <typename First, typename Second>
602 const First* get(Second second) const;
603
606 template <typename Func, if_t< is_callable<Func>::value > = 0 >
607 void get(const Func& func) const;
608
611 template <typename T>
612 bool has() const;
613
619 template <typename First, typename Second>
620 bool has() const;
621
627 template <typename First>
628 bool has(flecs::id_t second) const;
629
635 bool has(flecs::id_t first, flecs::id_t second) const;
636
639 template <typename T>
640 void add() const;
641
647 template <typename First, typename Second>
648 void add() const;
649
655 template <typename First>
656 void add(flecs::entity_t second) const;
657
663 void add(flecs::entity_t first, flecs::entity_t second) const;
664
667 template <typename T>
668 void remove() const;
669
675 template <typename First, typename Second>
676 void remove() const;
677
683 template <typename First>
684 void remove(flecs::entity_t second) const;
685
691 void remove(flecs::entity_t first, flecs::entity_t second) const;
692
697 template <typename Func>
698 void children(Func&& f) const;
699
702 template <typename T>
703 flecs::entity singleton() const;
704
713 template<typename First>
714 flecs::entity target(int32_t index = 0) const;
715
724 template<typename T>
725 flecs::entity target(flecs::entity_t first, int32_t index = 0) const;
726
735 flecs::entity target(flecs::entity_t first, int32_t index = 0) const;
736
743 template <typename T>
744 flecs::entity use(const char *alias = nullptr) const;
745
751 flecs::entity use(const char *name, const char *alias = nullptr) const;
752
758 void use(flecs::entity entity, const char *alias = nullptr) const;
759
764 int count(flecs::id_t component_id) const {
765 return ecs_count_id(m_world, component_id);
766 }
767
773 int count(flecs::entity_t first, flecs::entity_t second) const {
774 return ecs_count_id(m_world, ecs_pair(first, second));
775 }
776
781 template <typename T>
782 int count() const {
783 return count(_::cpp_type<T>::id(m_world));
784 }
785
791 template <typename First>
792 int count(flecs::entity_t second) const {
793 return count(_::cpp_type<First>::id(m_world), second);
794 }
795
801 template <typename First, typename Second>
802 int count() const {
803 return count(
804 _::cpp_type<First>::id(m_world),
805 _::cpp_type<Second>::id(m_world));
806 }
807
810 template <typename Func>
811 void with(id_t with_id, const Func& func) const {
812 ecs_id_t prev = ecs_set_with(m_world, with_id);
813 func();
814 ecs_set_with(m_world, prev);
815 }
816
819 template <typename T, typename Func>
820 void with(const Func& func) const {
821 with(this->id<T>(), func);
822 }
823
826 template <typename First, typename Second, typename Func>
827 void with(const Func& func) const {
828 with(ecs_pair(this->id<First>(), this->id<Second>()), func);
829 }
830
833 template <typename First, typename Func>
834 void with(id_t second, const Func& func) const {
835 with(ecs_pair(this->id<First>(), second), func);
836 }
837
840 template <typename Func>
841 void with(id_t first, id_t second, const Func& func) const {
842 with(ecs_pair(first, second), func);
843 }
844
848 template <typename Func>
849 void scope(id_t parent, const Func& func) const {
850 ecs_entity_t prev = ecs_set_scope(m_world, parent);
851 func();
852 ecs_set_scope(m_world, prev);
853 }
854
857 template <typename T, typename Func>
858 void scope(const Func& func) const {
859 flecs::id_t parent = _::cpp_type<T>::id(m_world);
860 scope(parent, func);
861 }
862
866 flecs::scoped_world scope(id_t parent) const;
867
868 template <typename T>
869 flecs::scoped_world scope() const;
870
871 flecs::scoped_world scope(const char* name) const;
872
874 void delete_with(id_t the_id) const {
875 ecs_delete_with(m_world, the_id);
876 }
877
879 void delete_with(entity_t first, entity_t second) const {
880 delete_with(ecs_pair(first, second));
881 }
882
884 template <typename T>
885 void delete_with() const {
887 }
888
890 template <typename First, typename Second>
891 void delete_with() const {
893 }
894
896 void remove_all(id_t the_id) const {
897 ecs_remove_all(m_world, the_id);
898 }
899
901 void remove_all(entity_t first, entity_t second) const {
902 remove_all(ecs_pair(first, second));
903 }
904
906 template <typename T>
907 void remove_all() const {
909 }
910
912 template <typename First, typename Second>
913 void remove_all() const {
915 }
916
920 template <typename Func>
921 void defer(const Func& func) const {
922 ecs_defer_begin(m_world);
923 func();
924 ecs_defer_end(m_world);
925 }
926
931 void defer_suspend() const {
932 ecs_defer_suspend(m_world);
933 }
934
939 void defer_resume() const {
940 ecs_defer_resume(m_world);
941 }
942
947 bool exists(flecs::entity_t e) const {
948 return ecs_exists(m_world, e);
949 }
950
955 bool is_alive(flecs::entity_t e) const {
956 return ecs_is_alive(m_world, e);
957 }
958
964 bool is_valid(flecs::entity_t e) const {
965 return ecs_is_valid(m_world, e);
966 }
967
973 flecs::entity get_alive(flecs::entity_t e) const;
974
975/* Prevent clashing with Unreal define. Unreal applications will have to use
976 * ecs_ensure. */
977#ifndef ensure
984 flecs::entity ensure(flecs::entity_t e) const;
985#endif
986
987 /* Run callback after completing frame */
988 void run_post_frame(ecs_fini_action_t action, void *ctx) const {
989 ecs_run_post_frame(m_world, action, ctx);
990 }
991
996 return ecs_get_world_info(m_world);
997 }
998
999# include "mixins/id/mixin.inl"
1001# include "mixins/entity/mixin.inl"
1002# include "mixins/event/mixin.inl"
1003# include "mixins/term/mixin.inl"
1004# include "mixins/filter/mixin.inl"
1005# include "mixins/observer/mixin.inl"
1006# include "mixins/query/mixin.inl"
1007# include "mixins/enum/mixin.inl"
1008
1009# ifdef FLECS_MODULE
1010# include "mixins/module/mixin.inl"
1011# endif
1012# ifdef FLECS_PIPELINE
1013# include "mixins/pipeline/mixin.inl"
1014# endif
1015# ifdef FLECS_SNAPSHOT
1016# include "mixins/snapshot/mixin.inl"
1017# endif
1018# ifdef FLECS_SYSTEM
1019# include "mixins/system/mixin.inl"
1020# endif
1021# ifdef FLECS_TIMER
1022# include "mixins/timer/mixin.inl"
1023# endif
1024# ifdef FLECS_RULES
1025# include "mixins/rule/mixin.inl"
1026# endif
1027# ifdef FLECS_PLECS
1028# include "mixins/plecs/mixin.inl"
1029# endif
1030# ifdef FLECS_META
1031# include "mixins/meta/world.inl"
1032# endif
1033# ifdef FLECS_JSON
1034# include "mixins/json/world.inl"
1035# endif
1036# ifdef FLECS_APP
1037# include "mixins/app/mixin.inl"
1038# endif
1039# ifdef FLECS_METRICS
1040# include "mixins/metrics/mixin.inl"
1041# endif
1042# ifdef FLECS_ALERTS
1043# include "mixins/alerts/mixin.inl"
1044# endif
1045
1046public:
1047 void init_builtin_components();
1048
1049 world_t *m_world;
1050 bool m_owned;
1051};
1052
1058 flecs::world_t *w,
1059 flecs::entity_t s) : world(nullptr)
1060 {
1061 m_prev_scope = ecs_set_scope(w, s);
1062 m_world = w;
1063 m_owned = false;
1064 }
1065
1066 ~scoped_world() {
1067 ecs_set_scope(m_world, m_prev_scope);
1068 }
1069
1070 scoped_world(const scoped_world& obj) : world(nullptr) {
1071 m_prev_scope = obj.m_prev_scope;
1072 m_world = obj.m_world;
1073 m_owned = obj.m_owned;
1074 }
1075
1076 flecs::entity_t m_prev_scope;
1077};
1078
1081} // namespace flecs
App world addon mixin.
Component mixin.
Entity world mixin.
Enum world mixin.
Event world mixin.
Filter world mixin.
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t id)
Set current with id.
void ecs_remove_all(ecs_world_t *world, ecs_id_t id)
Remove all instances of the specified id.
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:352
bool ecs_defer_end(ecs_world_t *world)
End block of operations to defer.
void ecs_defer_resume(ecs_world_t *world)
Resume deferring.
bool ecs_defer_begin(ecs_world_t *world)
Defer operations until end of frame.
void ecs_defer_suspend(ecs_world_t *world)
Suspend deferring but do not flush queue.
bool ecs_is_deferred(const ecs_world_t *world)
Test if deferring is enabled for current stage.
bool ecs_stage_is_async(ecs_world_t *stage)
Test whether provided stage is asynchronous.
void ecs_merge(ecs_world_t *world)
Merge world or stage.
void ecs_async_stage_free(ecs_world_t *stage)
Free asynchronous stage.
void ecs_set_automerge(ecs_world_t *world, bool automerge)
Enable/disable automerging for world or stage.
ecs_world_t * ecs_async_stage_new(ecs_world_t *world)
Create asynchronous stage.
bool ecs_stage_is_readonly(const ecs_world_t *world)
Test whether the current world is readonly.
int32_t ecs_get_stage_count(const ecs_world_t *world)
Get number of configured stages.
bool ecs_readonly_begin(ecs_world_t *world)
Begin readonly mode.
ecs_world_t * ecs_get_stage(const ecs_world_t *world, int32_t stage_id)
Get stage-specific world pointer.
void ecs_set_stage_count(ecs_world_t *world, int32_t stages)
Configure world to have N stages.
void ecs_readonly_end(ecs_world_t *world)
End readonly mode.
int32_t ecs_get_stage_id(const ecs_world_t *world)
Get current stage id.
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:282
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:291
uint64_t ecs_id_t
An id.
Definition flecs.h:279
void ecs_delete_with(ecs_world_t *world, ecs_id_t id)
Delete all entities with the specified id.
int32_t ecs_count_id(const ecs_world_t *world, ecs_id_t entity)
Count entities that have the specified id.
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:473
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Emplace a component.
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Signal that a component has been modified.
void * ecs_get_mut_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get a mutable pointer to a component.
ecs_id_t ecs_strip_generation(ecs_entity_t e)
Remove generation from entity id.
bool ecs_is_valid(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is valid.
bool ecs_exists(const ecs_world_t *world, ecs_entity_t entity)
Test whether an entity exists.
bool ecs_is_alive(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is alive.
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:42
ecs_entity_t * ecs_set_lookup_path(ecs_world_t *world, const ecs_entity_t *lookup_path)
Set search path for lookup operations.
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
void ecs_atfini(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register action to be executed when world is destroyed.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_init(void)
Create a new world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
float ecs_frame_begin(ecs_world_t *world, float delta_time)
Begin frame.
void ecs_run_post_frame(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register action to be executed once after frame.
bool ecs_should_quit(const ecs_world_t *world)
Return whether a quit has been signaled.
void ecs_quit(ecs_world_t *world)
Signal exit This operation signals that the application should quit.
void ecs_frame_end(ecs_world_t *world)
End frame.
void ecs_set_context(ecs_world_t *world, void *ctx)
Set a world context.
void ecs_dim(ecs_world_t *world, int32_t entity_count)
Dimension the world for a specified number of entities.
void ecs_set_entity_range(ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end)
Set a range for issueing new entity ids.
const ecs_world_info_t * ecs_get_world_info(const ecs_world_t *world)
Get world info.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
void * ecs_get_context(const ecs_world_t *world)
Get the world context.
bool ecs_enable_range_check(ecs_world_t *world, bool enable)
Enable/disable range limits.
Id world mixin.
JSON world mixin.
Meta world mixin.
Module world mixin.
Observer world mixin.
Pipeline world mixin.
Plecs world mixin.
Query world mixin.
Rule world mixin.
Snapshot world mixin.
Type that contains information about the world.
Definition flecs.h:1006
Entity.
Definition entity.hpp:30
Class that wraps around a flecs::id_t.
Definition decl.hpp:27
Scoped world.
Definition world.hpp:1056
The world.
Definition world.hpp:113
bool is_stage() const
Test if is a stage.
Definition world.hpp:335
void delete_with() const
Delete all entities with specified component.
Definition world.hpp:885
void set_automerge(bool automerge) const
Enable/disable automerging for world or stage.
Definition world.hpp:359
void remove_all(id_t the_id) const
Remove all instances of specified id.
Definition world.hpp:896
void merge() const
Merge world or stage.
Definition world.hpp:371
void delete_with(id_t the_id) const
Delete all entities with specified id.
Definition world.hpp:874
const flecs::world_info_t * get_info() const
Get the world info.
Definition world.hpp:995
flecs::entity get_scope() const
Get current scope.
Definition world.hpp:63
T * get_mut() const
Get mut singleton component.
Definition world.hpp:78
void remove() const
Remove singleton component.
Definition world.hpp:172
void set(A &&value) const
Set singleton pair.
Definition world.hpp:547
void quit() const
Signal application should quit.
Definition world.hpp:188
flecs::entity get_alive(flecs::entity_t e) const
Get alive entity for id.
Definition world.hpp:242
void set_entity_range(entity_t min, entity_t max) const
Set entity range.
Definition world.hpp:471
void readonly_end() const
End staging.
Definition world.hpp:265
void with(const Func &func) const
All entities created in function are created with pair.
Definition world.hpp:827
int count() const
Count entities matching a component.
Definition world.hpp:782
flecs::entity target(int32_t index=0) const
Get target for a given pair from a singleton entity.
Definition world.hpp:205
const T * get() const
Get singleton component.
Definition world.hpp:108
void defer(const Func &func) const
Defer all operations called in function.
Definition world.hpp:921
bool should_quit() const
Test if quit() has been called.
Definition world.hpp:200
bool is_alive(flecs::entity_t e) const
Check if entity id exists in the world.
Definition world.hpp:955
void * get_context() const
Get world context.
Definition world.hpp:452
world_t * c_ptr() const
Obtain pointer to C world object.
Definition world.hpp:181
bool defer_begin() const
Defer operations until end of frame.
Definition world.hpp:275
void reset()
Deletes and recreates the world.
Definition world.hpp:172
flecs::entity lookup(const char *name) const
Lookup entity by name.
Definition world.hpp:72
flecs::entity_t * set_lookup_path(const flecs::entity_t *search_path) const
Set search path.
Definition world.hpp:510
void defer_suspend() const
Suspend deferring operations.
Definition world.hpp:931
void set(const A &value) const
Set singleton pair.
Definition world.hpp:539
bool is_valid(flecs::entity_t e) const
Check if entity id is valid.
Definition world.hpp:964
flecs::world async_stage() const
Create asynchronous stage.
Definition world.hpp:410
bool is_deferred() const
Test whether deferring is enabled.
Definition world.hpp:290
world & operator=(const world &obj)=delete
Not allowed to copy a world.
int32_t get_stage_id() const
Get current stage id.
Definition world.hpp:325
void scope(const Func &func) const
Same as scope(parent, func), but with T as parent.
Definition world.hpp:858
bool readonly_begin() const
Begin staging.
Definition world.hpp:254
void defer_resume() const
Resume deferring operations.
Definition world.hpp:939
flecs::entity set_scope() const
Same as set_scope but with type.
Definition world.hpp:68
void dim(int32_t entity_count) const
Preallocate memory for number of entities.
Definition world.hpp:461
void set_stage_count(int32_t stages) const
Configure world to have N stages.
Definition world.hpp:306
void with(id_t with_id, const Func &func) const
All entities created in function are created with id.
Definition world.hpp:811
void set_context(void *ctx) const
Set world context.
Definition world.hpp:444
world(const world &obj)=delete
Not allowed to copy a world.
int count() const
Count entities matching a pair.
Definition world.hpp:802
void remove_all() const
Remove all instances of specified pair.
Definition world.hpp:913
bool defer_end() const
End block of operations to defer.
Definition world.hpp:284
int count(flecs::entity_t first, flecs::entity_t second) const
Count entities matching a pair.
Definition world.hpp:773
world(world_t *w)
Create world from C world.
Definition world.hpp:130
void children(Func &&f) const
Iterate entities in root of world Accepts a callback with the following signature: void(*)(flecs::ent...
Definition world.hpp:195
flecs::world get_world() const
Get actual world.
Definition world.hpp:422
void atfini(ecs_fini_action_t action, void *ctx) const
Register action to be executed when world is destroyed.
Definition world.hpp:194
flecs::entity ensure(flecs::entity_t e) const
Ensures that entity with provided generation is alive.
Definition world.hpp:249
void scope(id_t parent, const Func &func) const
All entities created in function are created in scope.
Definition world.hpp:849
void with(const Func &func) const
All entities created in function are created with type.
Definition world.hpp:820
void remove_all(entity_t first, entity_t second) const
Remove all instances of specified pair.
Definition world.hpp:901
void modified() const
Mark singleton component as modified.
Definition world.hpp:84
int count(flecs::entity_t second) const
Count entities matching a pair.
Definition world.hpp:792
ecs_ftime_t frame_begin(float delta_time=0) const
Begin frame.
Definition world.hpp:222
flecs::entity use(const char *alias=nullptr) const
Create alias for component.
Definition world.hpp:30
bool is_readonly() const
Test whether the current world object is readonly.
Definition world.hpp:434
void add() const
Add singleton component.
Definition world.hpp:149
void set(const T &value) const
Set singleton component.
Definition world.hpp:523
void with(id_t first, id_t second, const Func &func) const
All entities created in function are created with pair.
Definition world.hpp:841
void enable_range_check(bool enabled) const
Enforce that operations cannot modify entities outside of range.
Definition world.hpp:483
flecs::world get_stage(int32_t stage_id) const
Get stage-specific world pointer.
Definition world.hpp:389
void set(T &&value) const
Set singleton component.
Definition world.hpp:530
bool has() const
Test if world has singleton component.
Definition world.hpp:126
bool exists(flecs::entity_t e) const
Check if entity id exists in the world.
Definition world.hpp:947
world()
Create world.
Definition world.hpp:116
void frame_end() const
End frame.
Definition world.hpp:232
int32_t get_stage_count() const
Get number of configured stages.
Definition world.hpp:315
void delete_with(entity_t first, entity_t second) const
Delete all entities with specified pair.
Definition world.hpp:879
void delete_with() const
Delete all entities with specified pair.
Definition world.hpp:891
flecs::entity singleton() const
Get singleton entity for type.
Definition world.hpp:200
void with(id_t second, const Func &func) const
All entities created in function are created with pair.
Definition world.hpp:834
world(int argc, char *argv[])
Create world with command line arguments.
Definition world.hpp:124
int count(flecs::id_t component_id) const
Count entities matching a component.
Definition world.hpp:764
void remove_all() const
Remove all instances of specified component.
Definition world.hpp:907
ref< T > get_ref() const
Get ref singleton component.
Definition world.hpp:102
System module world mixin.
Term world mixin.
Timer module mixin.
flecs::id_t strip_generation(flecs::entity_t e)
Return id without generation.
Definition world.hpp:89
uint32_t get_generation(flecs::entity_t e)
Return entity generation.
Definition world.hpp:95