The ECS world.
More...
#include <vecs.h>
|
template<typename T> |
World & | add_resource (T *resource) |
| Adds a non-owned resource to the world.
|
|
template<typename T> |
Resource< T > & | get_resource () const |
| Retrieves a non-owned resource of type T.
|
|
template<typename Func> |
void | add_system (ScheduleLabel label, Func &&func) |
| Adds a system to the specified schedule.
|
|
template<typename Func> |
void | add_system (Func &&func) |
| Adds a system to the Update schedule.
|
|
void | progress () |
| Progresses the ECS world by one tick, with automatically calculated delta time.
|
|
void | progress (float delta_time) |
| Progresses the ECS world by one tick, with a supplied delta time.
|
|
EntityBuilder | spawn () |
|
EntityBuilder | entity (Entity entity) |
|
template<typename... Components> |
Query< Components... > | query () |
|
template<typename... Components> |
Observer< Components... > & | observe () |
|
Commands & | commands () |
|
void | despawn (Entity entity) |
|
void | log_archetypes () |
|
|
template<typename... Components> |
class | Query |
|
class | EntityBuilder |
|
class | EntityCommands |
|
AddFlags | operator| (AddFlags a, AddFlags b) |
|
AddFlags | operator& (AddFlags a, AddFlags b) |
|
◆ add_resource()
template<typename T>
World & vecs::World::add_resource |
( |
T * | resource | ) |
|
|
inline |
Adds a non-owned resource to the world.
The resource must have the same lifetime as the world, as the world does not manage its memory.
- Template Parameters
-
T | The type of the resource to add. |
- Parameters
-
resource | A pointer to the resource to add. |
- Returns
- A reference to the world for method chaining.
◆ add_system() [1/2]
template<typename Func>
void vecs::World::add_system |
( |
Func && | func | ) |
|
|
inline |
Adds a system to the Update schedule.
- Parameters
-
func | The system function, which accepts anything that implements into_system_param trait. |
Example usage:
world.add_system([](
const Time& time, Query<Position, const Velocity>& query) {
for (auto [p, v] : query) {
p.x += v.x * time.delta;
p.y += v.y * time.delta;
}
});
◆ add_system() [2/2]
template<typename Func>
void vecs::World::add_system |
( |
ScheduleLabel | label, |
|
|
Func && | func ) |
|
inline |
Adds a system to the specified schedule.
- Parameters
-
label | The schedule label indicating the phase for system execution |
func | The system function, which accepts anything that implements into_system_param trait. |
Example usage:
world.add_system(ScheduleLabel::Startup, [](Query<Position>& query) {
for (auto [p] : query) {
printf("Startup Position: (%f, %f)\n", p.x, p.y);
}
});
◆ get_resource()
template<typename T>
Resource< T > & vecs::World::get_resource |
( |
| ) |
const |
|
inline |
Retrieves a non-owned resource of type T.
Asserts if the resource is not found. The resource must have been previously added using add_resource and must have a matching lifetime with the world.
- Template Parameters
-
T | The type of the resource to retrieve. |
- Returns
- A reference to the resource wrapper of type Resource<T>.
◆ progress()
void vecs::World::progress |
( |
float | delta_time | ) |
|
|
inline |
Progresses the ECS world by one tick, with a supplied delta time.
Note: Calling this without delta time will use built-in clock
The documentation for this class was generated from the following file: