Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
api.inl
1#include "gaia/config/config.h"
2
3namespace gaia {
4 namespace ecs {
5 // Component API
6
7 GAIA_NODISCARD inline const ComponentCache& comp_cache(const World& world) {
8 return world.comp_cache();
9 }
10
11 GAIA_NODISCARD inline ComponentCache& comp_cache_mut(World& world) {
12 return world.comp_cache_mut();
13 }
14
15 template <typename T>
16 GAIA_NODISCARD inline const ComponentCacheItem& comp_cache_add(World& world) {
17 return world.add<T>();
18 }
19
20 // Entity API
21
22 GAIA_NODISCARD inline const EntityContainer& fetch(const World& world, Entity entity) {
23 return world.fetch(entity);
24 }
25
26 GAIA_NODISCARD inline EntityContainer& fetch_mut(World& world, Entity entity) {
27 return world.fetch(entity);
28 }
29
30 inline void del(World& world, Entity entity) {
31 world.del(entity);
32 }
33
34 GAIA_NODISCARD inline Entity entity_from_id(const World& world, EntityId id) {
35 return world.get(id);
36 }
37
38 GAIA_NODISCARD inline bool valid(const World& world, Entity entity) {
39 return world.valid(entity);
40 }
41
42 GAIA_NODISCARD inline bool is(const World& world, Entity entity, Entity baseEntity) {
43 return world.is(entity, baseEntity);
44 }
45
46 GAIA_NODISCARD inline bool is_base(const World& world, Entity entity) {
47 return world.is_base(entity);
48 }
49
50 GAIA_NODISCARD inline Archetype* archetype_from_entity(const World& world, Entity entity) {
51 const auto& ec = world.fetch(entity);
52 if (World::is_req_del(ec))
53 return nullptr;
54
55 return ec.pArchetype;
56 }
57
58 GAIA_NODISCARD inline const char* entity_name(const World& world, Entity entity) {
59 return world.name(entity);
60 }
61
62 GAIA_NODISCARD inline const char* entity_name(const World& world, EntityId entityId) {
63 return world.name(entityId);
64 }
65
66 // Traversal API
67
68 template <typename Func>
69 inline void as_relations_trav(const World& world, Entity target, Func func) {
70 world.as_relations_trav(target, func);
71 }
72
73 template <typename Func>
74 inline bool as_relations_trav_if(const World& world, Entity target, Func func) {
75 return world.as_relations_trav_if(target, func);
76 }
77
78 template <typename Func>
79 inline void as_targets_trav(const World& world, Entity relation, Func func) {
80 world.as_targets_trav(relation, func);
81 }
82
83 template <typename Func>
84 inline bool as_targets_trav_if(const World& world, Entity relation, Func func) {
85 return world.as_targets_trav_if(relation, func);
86 }
87
88 // Query API
89
90 GAIA_NODISCARD inline QuerySerBuffer& query_buffer(World& world, QueryId& serId) {
91 return world.query_buffer(serId);
92 }
93
94 inline void query_buffer_reset(World& world, QueryId& serId) {
95 world.query_buffer_reset(serId);
96 }
97
98 GAIA_NODISCARD inline Entity expr_to_entity(const World& world, va_list& args, std::span<const char> exprRaw) {
99 return world.expr_to_entity(args, exprRaw);
100 }
101
102 // Locking API
103
104 inline void lock(World& world) {
105 world.lock();
106 }
107 inline void unlock(World& world) {
108 world.unlock();
109 }
110 GAIA_NODISCARD inline bool locked(const World& world) {
111 return world.locked();
112 }
113
114 // CommandBuffer API
115
116 GAIA_NODISCARD inline CommandBufferST& cmd_buffer_st_get(World& world) {
117 return world.cmd_buffer_st();
118 }
119
120 GAIA_NODISCARD inline CommandBufferMT& cmd_buffer_mt_get(World& world) {
121 return world.cmd_buffer_mt();
122 }
123
124 inline void commit_cmd_buffer_st(World& world) {
125 if (world.locked())
126 return;
127 cmd_buffer_commit(world.cmd_buffer_st());
128 }
129
130 inline void commit_cmd_buffer_mt(World& world) {
131 if (world.locked())
132 return;
133 cmd_buffer_commit(world.cmd_buffer_mt());
134 }
135 } // namespace ecs
136} // namespace gaia
Definition span_impl.h:99
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9