Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
api.h
1#pragma once
2#include "gaia/config/config.h"
3
4#include <cstdarg>
5
6#include "gaia/core/span.h"
7#include "gaia/ecs/command_buffer_fwd.h"
8#include "gaia/ecs/id_fwd.h"
9#include "gaia/ecs/query_fwd.h"
10
11namespace gaia {
12 namespace ecs {
13 class World;
14 class ComponentCache;
15 class Archetype;
16 struct ComponentCacheItem;
17 struct EntityContainer;
18 struct Entity;
19
20 // Component API
21
22 const ComponentCache& comp_cache(const World& world);
23 ComponentCache& comp_cache_mut(World& world);
24 template <typename T>
25 const ComponentCacheItem& comp_cache_add(World& world);
26
27 // Entity API
28
29 const EntityContainer& fetch(const World& world, Entity entity);
30 EntityContainer& fetch_mut(World& world, Entity entity);
31
32 void del(World& world, Entity entity);
33
34 Entity entity_from_id(const World& world, EntityId id);
35
37 bool valid(const World& world, Entity entity);
38
39 bool is(const World& world, Entity entity, Entity baseEntity);
40 bool is_base(const World& world, Entity entity);
41
42 Archetype* archetype_from_entity(const World& world, Entity entity);
43
44 util::str_view entity_name(const World& world, Entity entity);
45 util::str_view entity_name(const World& world, EntityId entityId);
46 Entity target(const World& world, Entity entity, Entity relation);
49 void
50 world_for_each_target(const World& world, Entity entity, Entity relation, void* ctx, void (*func)(void*, Entity));
51 Entity world_pair_target_if_alive(const World& world, Entity pair);
52 bool world_entity_enabled(const World& world, Entity entity);
53 bool world_entity_enabled_hierarchy(const World& world, Entity entity, Entity relation);
54 uint32_t world_enabled_hierarchy_version(const World& world);
56 uint32_t world_version(const World& world);
58 uint32_t world_rel_version(const World& world, Entity relation);
60 bool world_is_hierarchy_relation(const World& world, Entity relation);
62 bool world_is_fragmenting_relation(const World& world, Entity relation);
64 bool world_is_fragmenting_hierarchy_relation(const World& world, Entity relation);
66 bool world_supports_depth_order(const World& world, Entity relation);
68 bool world_depth_order_prunes_disabled_subtrees(const World& world, Entity relation);
69 template <typename T>
70 decltype(auto) world_query_entity_arg_by_id(World& world, Entity entity, Entity id);
71
72 // Traversal API
73
74 template <typename Func>
75 void as_relations_trav(const World& world, Entity target, Func func);
76 template <typename Func>
77 bool as_relations_trav_if(const World& world, Entity target, Func func);
78 template <typename Func>
79 void as_targets_trav(const World& world, Entity relation, Func func);
80 template <typename Func>
81 bool as_targets_trav_if(const World& world, Entity relation, Func func);
82 template <typename Func>
83 void targets_trav(const World& world, Entity relation, Entity source, Func func);
84 template <typename Func>
85 bool targets_trav_if(const World& world, Entity relation, Entity source, Func func);
86 const cnt::darray<Entity>& targets_trav_cache(const World& world, Entity relation, Entity source);
87 template <typename Func>
88 void sources(const World& world, Entity relation, Entity target, Func func);
89 template <typename Func>
90 void sources_if(const World& world, Entity relation, Entity target, Func func);
91 const cnt::darray<Entity>& sources_bfs_trav_cache(const World& world, Entity relation, Entity rootTarget);
92 template <typename Func>
93 void sources_bfs(const World& world, Entity relation, Entity rootTarget, Func func);
94 template <typename Func>
95 bool sources_bfs_if(const World& world, Entity relation, Entity rootTarget, Func func);
96 template <typename Func>
97 void children(const World& world, Entity parent, Func func);
98 template <typename Func>
99 void children_if(const World& world, Entity parent, Func func);
100 template <typename Func>
101 void children_bfs(const World& world, Entity root, Func func);
102 template <typename Func>
103 bool children_bfs_if(const World& world, Entity root, Func func);
104
105 // Query API
106
107 QuerySerBuffer& query_buffer(World& world, QueryId& serId);
108 void query_buffer_reset(World& world, QueryId& serId);
109
110 Entity expr_to_entity(const World& world, va_list& args, std::span<const char> exprRaw);
111
112 GroupId group_by_func_default(const World& world, const Archetype& archetype, Entity groupBy);
113
114 // Locking API
115
116 void lock(World& world);
117 void unlock(World& world);
118 bool locked(const World& world);
119
120 // CommandBuffer API
121
122 CommandBufferST& cmd_buffer_st_get(World& world);
123 CommandBufferMT& cmd_buffer_mt_get(World& world);
124 void commit_cmd_buffer_st(World& world);
125 void commit_cmd_buffer_mt(World& world);
126 } // namespace ecs
127} // namespace gaia
Definition span_impl.h:99
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9