|
viotecs 1.1.0
|
#include <world.hpp>
Public Member Functions | |
| World ()=delete | |
Static Public Member Functions | |
| static void | init () |
| Initialize the world. | |
| static void | destroy () |
| Delete the world. | |
| static void | tick () |
| Tick the world. | |
| static std::set< EntityId > * | get_entities () |
| Get the entities container. | |
| static UMap< TypeId, Resource > * | get_resources () |
| Get the resources container. | |
| static UMapVec< TypeId, Component > * | get_components () |
| Get the components container. | |
| static Entity | new_entity () |
| Create a new entity. | |
| template<typename R > | |
| static R * | get_resource () |
| Get a pointer to a resource. | |
| template<typename C , typename... Args> | |
| static void | add_component (EntityId e, Args &&... args) |
| Add a component to an entity. | |
| template<typename R > | |
| static void | add_resource (R resource) |
| Add a resource to the world. | |
| static void | remove_entity (EntityId e) |
| Remove an entity. | |
| template<typename R > | |
| static void | remove_resource () |
| Remove a resource. | |
| template<typename C > | |
| static C * | entity_to_component (EntityId e) |
| Get the component of an entity. | |
| template<typename... S> | |
| static void | register_systems () |
Static Public Attributes | |
| static std::function< void()> | run_systems |
| Run all systems. | |
World class.
This class is a singleton that contains all the entities, components and systems in the game world, provides acces to them through queries and is responsible for updating the game world.
|
delete |
Add a component to an entity.
This method adds a component to an entity. The component is copied and stored in the world.
| C | The type of the component |
| entity | The entity to add the component to |
| args | The argument to construct the component |
Example:
Add a resource to the world.
This method adds a resource to the world.
Example:
Delete the world.
This method deletes the world, freeing the entities, components, and resources containers, freeing the memory.
Get the component of an entity.
This method returns a pointer to the component of the specified type of the specified entity. If the component is not found, it returns nullptr.
| C | The type of the component |
| entity | The entity to get the component from |
Example:
Get the components container.
Get the entities container.
Get a pointer to a resource.
This method returns a pointer to a resource of the specified type. If the resource is not found, it returns nullptr.
| R | The type of the resource |
Example:
Get the resources container.
Initialize the world.
This method initializes the world, creating the entities, components, and resources containers.
Remove an entity.
This method removes an entity from the world, deleting all its components.
| entity | The entity to remove |
Example:
Tick the world.
This method ticks the world, calling each system in the world.
|
static |