Flecs v3.1
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
173 world_t* c_ptr() const {
174 return m_world;
175 }
176
180 const ecs_world_info_t *stats = ecs_get_world_info(m_world);
181 return stats->delta_time;
182 }
183
186 int64_t tick() const {
187 const ecs_world_info_t *stats = ecs_get_world_info(m_world);
188 return stats->frame_count_total;
189 }
190
194 const ecs_world_info_t *stats = ecs_get_world_info(m_world);
195 return stats->world_time_total;
196 }
197
201 void quit() const {
202 ecs_quit(m_world);
203 }
204
207 void atfini(ecs_fini_action_t action, void *ctx) const {
208 ecs_atfini(m_world, action, ctx);
209 }
210
213 bool should_quit() const {
214 return ecs_should_quit(m_world);
215 }
216
236 return ecs_frame_begin(m_world, delta_time);
237 }
238
245 void frame_end() const {
246 ecs_frame_end(m_world);
247 }
248
267 bool readonly_begin() const {
268 return ecs_readonly_begin(m_world);
269 }
270
278 void readonly_end() const {
279 ecs_readonly_end(m_world);
280 }
281
288 bool defer_begin() const {
289 return ecs_defer_begin(m_world);
290 }
291
297 bool defer_end() const {
298 return ecs_defer_end(m_world);
299 }
300
303 bool is_deferred() const {
304 return ecs_is_deferred(m_world);
305 }
306
319 void set_stage_count(int32_t stages) const {
320 ecs_set_stage_count(m_world, stages);
321 }
322
328 int32_t get_stage_count() const {
329 return ecs_get_stage_count(m_world);
330 }
331
338 int32_t get_stage_id() const {
339 return ecs_get_stage_id(m_world);
340 }
341
348 bool is_stage() const {
350 ecs_poly_is(m_world, ecs_world_t) ||
351 ecs_poly_is(m_world, ecs_stage_t),
352 ECS_INVALID_PARAMETER, NULL);
353 return ecs_poly_is(m_world, ecs_stage_t);
354 }
355
372 void set_automerge(bool automerge) const {
373 ecs_set_automerge(m_world, automerge);
374 }
375
384 void merge() const {
385 ecs_merge(m_world);
386 }
387
402 flecs::world get_stage(int32_t stage_id) const {
403 return flecs::world(ecs_get_stage(m_world, stage_id));
404 }
405
424 auto result = flecs::world(ecs_async_stage_new(m_world));
425 result.m_owned = true;
426 return result;
427 }
428
436 /* Safe cast, mutability is checked */
437 return flecs::world(
438 m_world ? const_cast<flecs::world_t*>(ecs_get_world(m_world)) : nullptr);
439 }
440
447 bool is_readonly() const {
448 return ecs_stage_is_readonly(m_world);
449 }
450
457 void set_context(void* ctx) const {
458 ecs_set_context(m_world, ctx);
459 }
460
465 void* get_context() const {
466 return ecs_get_context(m_world);
467 }
468
474 void dim(int32_t entity_count) const {
475 ecs_dim(m_world, entity_count);
476 }
477
484 void set_entity_range(entity_t min, entity_t max) const {
485 ecs_set_entity_range(m_world, min, max);
486 }
487
496 void enable_range_check(bool enabled) const {
497 ecs_enable_range_check(m_world, enabled);
498 }
499
506 flecs::entity set_scope(const flecs::entity_t scope) const;
507
513 flecs::entity get_scope() const;
514
518 template <typename T>
519 flecs::entity set_scope() const;
520
523 flecs::entity_t* set_lookup_path(const flecs::entity_t *search_path) const {
524 return ecs_set_lookup_path(m_world, search_path);
525 }
526
531 flecs::entity lookup(const char *name) const;
532
535 template <typename T, if_t< !is_callable<T>::value > = 0>
536 void set(const T& value) const {
537 flecs::set<T>(m_world, _::cpp_type<T>::id(m_world), value);
538 }
539
540 template <typename T, if_t< !is_callable<T>::value > = 0>
541 void set(T&& value) const {
542 flecs::set<T>(m_world, _::cpp_type<T>::id(m_world),
543 FLECS_FWD(value));
544 }
545
548 template <typename Func, if_t< is_callable<Func>::value > = 0 >
549 void set(const Func& func) const;
550
551 template <typename T, typename ... Args>
552 void emplace(Args&&... args) const {
553 flecs::id_t component_id = _::cpp_type<T>::id(m_world);
554 flecs::emplace<T>(m_world, component_id, component_id,
555 FLECS_FWD(args)...);
556 }
557
560 template <typename T>
561 T* get_mut() const;
562
565 template <typename T>
566 void modified() const;
567
570 template <typename T>
571 ref<T> get_ref() const;
572
575 template <typename T>
576 const T* get() const;
577
580 template <typename Func, if_t< is_callable<Func>::value > = 0 >
581 void get(const Func& func) const;
582
585 template <typename T>
586 bool has() const;
587
590 template <typename T>
591 void add() const;
592
595 template <typename T>
596 void remove() const;
597
600 template <typename T>
601 flecs::entity singleton() const;
602
609 template <typename T>
610 flecs::entity use(const char *alias = nullptr) const;
611
617 flecs::entity use(const char *name, const char *alias = nullptr) const;
618
624 void use(flecs::entity entity, const char *alias = nullptr) const;
625
630 int count(flecs::id_t component_id) const {
631 return ecs_count_id(m_world, component_id);
632 }
633
639 int count(flecs::entity_t first, flecs::entity_t second) const {
640 return ecs_count_id(m_world, ecs_pair(first, second));
641 }
642
647 template <typename T>
648 int count() const {
649 return count(_::cpp_type<T>::id(m_world));
650 }
651
657 template <typename First>
658 int count(flecs::entity_t second) const {
659 return count(_::cpp_type<First>::id(m_world), second);
660 }
661
667 template <typename First, typename Second>
668 int count() const {
669 return count(
670 _::cpp_type<First>::id(m_world),
671 _::cpp_type<Second>::id(m_world));
672 }
673
676 template <typename Func>
677 void with(id_t with_id, const Func& func) const {
678 ecs_id_t prev = ecs_set_with(m_world, with_id);
679 func();
680 ecs_set_with(m_world, prev);
681 }
682
685 template <typename T, typename Func>
686 void with(const Func& func) const {
687 with(this->id<T>(), func);
688 }
689
692 template <typename First, typename Second, typename Func>
693 void with(const Func& func) const {
694 with(ecs_pair(this->id<First>(), this->id<Second>()), func);
695 }
696
699 template <typename First, typename Func>
700 void with(id_t second, const Func& func) const {
701 with(ecs_pair(this->id<First>(), second), func);
702 }
703
706 template <typename Func>
707 void with(id_t first, id_t second, const Func& func) const {
708 with(ecs_pair(first, second), func);
709 }
710
714 template <typename Func>
715 void scope(id_t parent, const Func& func) const {
716 ecs_entity_t prev = ecs_set_scope(m_world, parent);
717 func();
718 ecs_set_scope(m_world, prev);
719 }
720
723 template <typename T, typename Func>
724 void scope(const Func& func) const {
725 flecs::id_t parent = _::cpp_type<T>::id(m_world);
726 scope(parent, func);
727 }
728
732 flecs::scoped_world scope(id_t parent) const;
733
734 template <typename T>
735 flecs::scoped_world scope() const;
736
738 void delete_with(id_t the_id) const {
739 ecs_delete_with(m_world, the_id);
740 }
741
743 void delete_with(entity_t first, entity_t second) const {
744 delete_with(ecs_pair(first, second));
745 }
746
748 template <typename T>
749 void delete_with() const {
751 }
752
754 template <typename First, typename Second>
755 void delete_with() const {
757 }
758
760 void remove_all(id_t the_id) const {
761 ecs_remove_all(m_world, the_id);
762 }
763
765 void remove_all(entity_t first, entity_t second) const {
766 remove_all(ecs_pair(first, second));
767 }
768
770 template <typename T>
771 void remove_all() const {
773 }
774
776 template <typename First, typename Second>
777 void remove_all() const {
779 }
780
784 template <typename Func>
785 void defer(const Func& func) const {
786 ecs_defer_begin(m_world);
787 func();
788 ecs_defer_end(m_world);
789 }
790
795 void defer_suspend() const {
796 ecs_defer_suspend(m_world);
797 }
798
803 void defer_resume() const {
804 ecs_defer_resume(m_world);
805 }
806
811 bool exists(flecs::entity_t e) const {
812 return ecs_exists(m_world, e);
813 }
814
819 bool is_alive(flecs::entity_t e) const {
820 return ecs_is_alive(m_world, e);
821 }
822
828 bool is_valid(flecs::entity_t e) const {
829 return ecs_is_valid(m_world, e);
830 }
831
837 flecs::entity get_alive(flecs::entity_t e) const;
838
839/* Prevent clashing with Unreal define. Unreal applications will have to use
840 * ecs_ensure. */
841#ifndef ensure
848 flecs::entity ensure(flecs::entity_t e) const;
849#endif
850
851 /* Run callback after completing frame */
852 void run_post_frame(ecs_fini_action_t action, void *ctx) const {
853 ecs_run_post_frame(m_world, action, ctx);
854 }
855
856# include "mixins/id/mixin.inl"
858# include "mixins/entity/mixin.inl"
859# include "mixins/event/mixin.inl"
860# include "mixins/term/mixin.inl"
861# include "mixins/filter/mixin.inl"
863# include "mixins/query/mixin.inl"
864# include "mixins/enum/mixin.inl"
865
866# ifdef FLECS_MODULE
867# include "mixins/module/mixin.inl"
868# endif
869# ifdef FLECS_PIPELINE
871# endif
872# ifdef FLECS_SNAPSHOT
874# endif
875# ifdef FLECS_SYSTEM
876# include "mixins/system/mixin.inl"
877# endif
878# ifdef FLECS_TIMER
879# include "mixins/timer/mixin.inl"
880# endif
881# ifdef FLECS_RULES
882# include "mixins/rule/mixin.inl"
883# endif
884# ifdef FLECS_PLECS
885# include "mixins/plecs/mixin.inl"
886# endif
887# ifdef FLECS_META
888# include "mixins/meta/world.inl"
889# endif
890# ifdef FLECS_JSON
891# include "mixins/json/world.inl"
892# endif
893# ifdef FLECS_APP
894# include "mixins/app/mixin.inl"
895# endif
896
897public:
898 void init_builtin_components();
899
900 world_t *m_world;
901 bool m_owned;
902};
903
909 flecs::world_t *w,
910 flecs::entity_t s) : world(nullptr)
911 {
912 m_prev_scope = ecs_set_scope(w, s);
913 m_world = w;
914 m_owned = false;
915 }
916
917 ~scoped_world() {
918 ecs_set_scope(m_world, m_prev_scope);
919 }
920
921 scoped_world(const scoped_world& obj) : world(nullptr) {
922 m_prev_scope = obj.m_prev_scope;
923 m_world = obj.m_world;
924 m_owned = obj.m_owned;
925 }
926
927 flecs::entity_t m_prev_scope;
928};
929
932} // 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:220
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:229
uint64_t ecs_id_t
An id.
Definition: flecs.h:217
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:411
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:928
float delta_time
Time passed to or computed by ecs_progress.
Definition: flecs.h:935
float world_time_total
Time elapsed in simulation.
Definition: flecs.h:942
int64_t frame_count_total
Total number of frames.
Definition: flecs.h:946
Entity.
Definition: entity.hpp:30
Class that wraps around a flecs::id_t.
Definition: decl.hpp:27
Scoped world.
Definition: world.hpp:907
The world.
Definition: world.hpp:113
bool is_stage() const
Test if is a stage.
Definition: world.hpp:348
void delete_with() const
Delete all entities with specified component.
Definition: world.hpp:749
void set_automerge(bool automerge) const
Enable/disable automerging for world or stage.
Definition: world.hpp:372
void remove_all(id_t the_id) const
Remove all instances of specified id.
Definition: world.hpp:760
void merge() const
Merge world or stage.
Definition: world.hpp:384
ecs_ftime_t time() const
Get current simulation time.
Definition: world.hpp:193
void delete_with(id_t the_id) const
Delete all entities with specified id.
Definition: world.hpp:738
flecs::entity get_scope() const
Get current scope.
Definition: world.hpp:67
T * get_mut() const
Get mut singleton component.
Definition: world.hpp:82
void remove() const
Remove singleton component.
Definition: world.hpp:118
ecs_ftime_t delta_time() const
Get last delta_time.
Definition: world.hpp:179
void quit() const
Signal application should quit.
Definition: world.hpp:201
flecs::entity get_alive(flecs::entity_t e) const
Get alive entity for id.
Definition: world.hpp:142
void set_entity_range(entity_t min, entity_t max) const
Set entity range.
Definition: world.hpp:484
void readonly_end() const
End staging.
Definition: world.hpp:278
void with(const Func &func) const
All entities created in function are created with pair.
Definition: world.hpp:693
int count() const
Count entities matching a component.
Definition: world.hpp:648
const T * get() const
Get singleton component.
Definition: world.hpp:100
void defer(const Func &func) const
Defer all operations called in function.
Definition: world.hpp:785
bool should_quit() const
Test if quit() has been called.
Definition: world.hpp:213
bool is_alive(flecs::entity_t e) const
Check if entity id exists in the world.
Definition: world.hpp:819
void * get_context() const
Get world context.
Definition: world.hpp:465
world_t * c_ptr() const
Obtain pointer to C world object.
Definition: world.hpp:173
bool defer_begin() const
Defer operations until end of frame.
Definition: world.hpp:288
flecs::entity lookup(const char *name) const
Lookup entity by name.
Definition: world.hpp:76
flecs::entity_t * set_lookup_path(const flecs::entity_t *search_path) const
Set search path.
Definition: world.hpp:523
void defer_suspend() const
Suspend deferring operations.
Definition: world.hpp:795
bool is_valid(flecs::entity_t e) const
Check if entity id is valid.
Definition: world.hpp:828
flecs::world async_stage() const
Create asynchronous stage.
Definition: world.hpp:423
bool is_deferred() const
Test whether deferring is enabled.
Definition: world.hpp:303
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:338
void scope(const Func &func) const
Same as scope(parent, func), but with T as parent.
Definition: world.hpp:724
bool readonly_begin() const
Begin staging.
Definition: world.hpp:267
void defer_resume() const
Resume deferring operations.
Definition: world.hpp:803
flecs::entity set_scope() const
Same as set_scope but with type.
Definition: world.hpp:72
void dim(int32_t entity_count) const
Preallocate memory for number of entities.
Definition: world.hpp:474
void set_stage_count(int32_t stages) const
Configure world to have N stages.
Definition: world.hpp:319
void with(id_t with_id, const Func &func) const
All entities created in function are created with id.
Definition: world.hpp:677
void set_context(void *ctx) const
Set world context.
Definition: world.hpp:457
world(const world &obj)=delete
Not allowed to copy a world.
int count() const
Count entities matching a pair.
Definition: world.hpp:668
void remove_all() const
Remove all instances of specified pair.
Definition: world.hpp:777
bool defer_end() const
End block of operations to defer.
Definition: world.hpp:297
int count(flecs::entity_t first, flecs::entity_t second) const
Count entities matching a pair.
Definition: world.hpp:639
world(world_t *w)
Create world from C world.
Definition: world.hpp:130
flecs::world get_world() const
Get actual world.
Definition: world.hpp:435
void atfini(ecs_fini_action_t action, void *ctx) const
Register action to be executed when world is destroyed.
Definition: world.hpp:207
flecs::entity ensure(flecs::entity_t e) const
Ensures that entity with provided generation is alive.
Definition: world.hpp:149
void scope(id_t parent, const Func &func) const
All entities created in function are created in scope.
Definition: world.hpp:715
void with(const Func &func) const
All entities created in function are created with type.
Definition: world.hpp:686
void remove_all(entity_t first, entity_t second) const
Remove all instances of specified pair.
Definition: world.hpp:765
void modified() const
Mark singleton component as modified.
Definition: world.hpp:88
int64_t tick() const
Get current tick.
Definition: world.hpp:186
int count(flecs::entity_t second) const
Count entities matching a pair.
Definition: world.hpp:658
ecs_ftime_t frame_begin(float delta_time=0) const
Begin frame.
Definition: world.hpp:235
flecs::entity use(const char *alias=nullptr) const
Create alias for component.
Definition: world.hpp:34
bool is_readonly() const
Test whether the current world object is readonly.
Definition: world.hpp:447
void add() const
Add singleton component.
Definition: world.hpp:112
void set(const T &value) const
Set singleton component.
Definition: world.hpp:536
void with(id_t first, id_t second, const Func &func) const
All entities created in function are created with pair.
Definition: world.hpp:707
void enable_range_check(bool enabled) const
Enforce that operations cannot modify entities outside of range.
Definition: world.hpp:496
flecs::world get_stage(int32_t stage_id) const
Get stage-specific world pointer.
Definition: world.hpp:402
bool has() const
Test if world has singleton component.
Definition: world.hpp:106
bool exists(flecs::entity_t e) const
Check if entity id exists in the world.
Definition: world.hpp:811
world()
Create world.
Definition: world.hpp:116
void frame_end() const
End frame.
Definition: world.hpp:245
int32_t get_stage_count() const
Get number of configured stages.
Definition: world.hpp:328
void delete_with(entity_t first, entity_t second) const
Delete all entities with specified pair.
Definition: world.hpp:743
void delete_with() const
Delete all entities with specified pair.
Definition: world.hpp:755
flecs::entity singleton() const
Get singleton entity for type.
Definition: world.hpp:124
void with(id_t second, const Func &func) const
All entities created in function are created with pair.
Definition: world.hpp:700
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:630
void remove_all() const
Remove all instances of specified component.
Definition: world.hpp:771
ref< T > get_ref() const
Get ref singleton component.
Definition: world.hpp:94
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