cubos::core::ecs::Cubos class final

Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.

Constructors, destructors, conversion operators

Cubos()
Constructs an empty application without arguments.
Cubos(int argc, char** argv)
Constructs an empty application with arguments.
TagBuilder(Cubos& cubos, std::string name, bool isStartup, Planner::TagId tagId)
Constructs.
SystemBuilder(Cubos& cubos, bool isStartup, std::string name)
Constructs.
ObserverBuilder(Cubos& cubos, std::string name)
Constructs.

Public functions

auto plugin(Plugin plugin) -> Cubos&
Adds a new plugin as a sub-plugin of the current plugin.
auto depends(Plugin plugin) -> Cubos&
Marks the given plugin as a dependency of the current plugin.
auto inject(Plugin target, Plugin plugin) -> Cubos&
Marks the target plugin so that when it is added, it is replaced by the given plugin.
auto uninitResource(const reflection::Type& type) -> Cubos&
Registers a new resource type, without initializing it.
auto resource(memory::AnyValue value) -> Cubos&
Registers a new resource type with the given initial value.
template<typename T>
auto uninitResource() -> Cubos&
Registers a new resource type, without initializing it.
template<typename T, typename... TArgs>
auto resource(TArgs && ... args) -> Cubos&
Registers a new resource type, constructing it with the given arguments.
auto component(const reflection::Type& type) -> Cubos&
Registers a new component type.
template<typename T>
auto component() -> Cubos&
Registers a new component type.
auto relation(const reflection::Type& type) -> Cubos&
Registers a new relation type.
template<typename T>
auto relation() -> Cubos&
Registers a new relation type.
template<typename T>
auto event() -> Cubos&
Registers a new event type.
auto tag(const Tag& tag) -> TagBuilder
Registers a new tag. Returns a builder used to configure tagged systems.
auto startupTag(const Tag& tag) -> TagBuilder
Registers a new startup tag. Returns a builder used to configure tagged systems.
auto system(std::string name) -> SystemBuilder
Returns a new builder used to add a system to the engine.
auto startupSystem(std::string name) -> SystemBuilder
Returns a new builder used to add a startup system to the engine.
auto observer(std::string name) -> ObserverBuilder
Returns a new builder used to add an observer to the engine.
void reset()
Resets the application to its initial state.
void start()
Runs the application's startup systems.
auto update() -> bool
Runs the application's main systems.
void run()
Runs the application's main loop.
auto before(const Tag& tag) -> TagBuilder&
Makes all tagged systems run before systems with the given tag.
auto after(const Tag& tag) -> TagBuilder&
Makes all tagged systems run after systems with the given tag.
auto tagged(const Tag& tag) -> TagBuilder&
Tags all tagged systems with the given tag.
auto addTo(const Tag& tag) -> TagBuilder&
Equivalent to calling tagged on the given tag.
auto runIf(auto func) -> TagBuilder&
Makes all systems within the tag run only if the given condition evaluates to true.
auto repeatWhile(auto func) -> TagBuilder&
Makes all systems within the tag repeat while the given condition evaluates to true.
auto tagged(const Tag& tag) && -> SystemBuilder&&
Adds a tag to the system.
auto before(const Tag& tag) && -> SystemBuilder&&
Forces this system to only run after all systems with the given tag have finished.
auto after(const Tag& tag) && -> SystemBuilder&&
Forces all systems with the given tag to run only after this system has finished.
auto entity(int target = -1) && -> SystemBuilder&&
Forces the next entity query argument to have the given target.
auto with(const reflection::Type& type, int target = -1) && -> SystemBuilder&&
Forces the given target of the next query argument to have the following component.
template<typename T>
auto with(int target = -1) && -> SystemBuilder&&
auto withOpt(const reflection::Type& type, int target = -1) && -> SystemBuilder&&
Accepts the following component from the given target of the next query argument.
template<typename T>
auto withOpt(int target = -1) && -> SystemBuilder&&
auto without(const reflection::Type& type, int target = -1) && -> SystemBuilder&&
Forces the given target of the next query argument to not have the following component.
template<typename T>
auto without(int target = -1) && -> SystemBuilder&&
auto related(const reflection::Type& type, int fromTarget = -1, int toTarget = -1) && -> SystemBuilder&&
Forces the given targets of the next query argument to be related with the given relation.
template<typename T>
auto related(int fromTarget = -1, int toTarget = -1) && -> SystemBuilder&&
auto related(const reflection::Type& type, Traversal traversal, int fromTarget = -1, int toTarget = -1) && -> SystemBuilder&&
Forces the given targets of the next query argument to be related with the given tree relation.
template<typename T>
auto related(Traversal traversal, int fromTarget = -1, int toTarget = -1) && -> SystemBuilder&&
auto other() && -> SystemBuilder&&
Makes the following argument options relative to the next argument.
auto onlyIf(auto function) && -> SystemBuilder&&
Makes the system only run if the given condition evaluates to true.
void call(auto function) &&
Finishes building the system with the given function.
auto onAdd(const reflection::Type& type, int target = -1) && -> ObserverBuilder&&
Triggers the observer whenever the given component is added to an entity.
template<typename T>
auto onAdd(int target = -1) && -> ObserverBuilder&&
auto onRemove(const reflection::Type& type, int target = -1) && -> ObserverBuilder&&
Triggers the observer whenever the given component is removed from an entity, or an entity with it is destroyed.
template<typename T>
auto onRemove(int target = -1) && -> ObserverBuilder&&
auto entity(int target = -1) && -> ObserverBuilder&&
Forces the next entity query argument to have the given target.
auto with(const reflection::Type& type, int target = -1) && -> ObserverBuilder&&
Forces the given target of the next query argument to have the following component.
template<typename T>
auto with(int target = -1) && -> ObserverBuilder&&
auto without(const reflection::Type& type, int target = -1) && -> ObserverBuilder&&
Forces the given target of the next query argument to not have the following component.
template<typename T>
auto without(int target = -1) && -> ObserverBuilder&&
auto related(const reflection::Type& type, int fromTarget = -1, int toTarget = -1) && -> ObserverBuilder&&
Forces the given targets of the next query argument to be related with the given relation.
template<typename T>
auto related(int fromTarget = -1, int toTarget = -1) && -> ObserverBuilder&&
auto related(const reflection::Type& type, Traversal traversal, int fromTarget = -1, int toTarget = -1) && -> ObserverBuilder&&
Forces the given targets of the next query argument to be related with the given tree relation.
template<typename T>
auto related(Traversal traversal, int fromTarget = -1, int toTarget = -1) && -> ObserverBuilder&&
auto other() && -> ObserverBuilder&&
Makes the following argument options relative to the next argument.
void call(auto function) &&
Finishes building the observer with the given function.

Function documentation

cubos::core::ecs::Cubos::Cubos(int argc, char** argv)

Constructs an empty application with arguments.

Parameters
argc Argument count.
argv Argument array.

cubos::core::ecs::Cubos::TagBuilder(Cubos& cubos, std::string name, bool isStartup, Planner::TagId tagId)

Constructs.

Parameters
cubos Cubos.
name Tag debug name.
isStartup Whether the tag is a startup tag.
tagId Tag identifier.

cubos::core::ecs::Cubos::SystemBuilder(Cubos& cubos, bool isStartup, std::string name)

Constructs.

Parameters
cubos Cubos.
isStartup Whether the system is a startup system.
name Debug name.

cubos::core::ecs::Cubos::ObserverBuilder(Cubos& cubos, std::string name)

Constructs.

Parameters
cubos Cubos.
name Debug name.

Cubos& cubos::core::ecs::Cubos::plugin(Plugin plugin)

Adds a new plugin as a sub-plugin of the current plugin.

Parameters
plugin Plugin.
Returns Cubos.

Aborts if the plugin has already been added by this or any other plugin.

Cubos& cubos::core::ecs::Cubos::depends(Plugin plugin)

Marks the given plugin as a dependency of the current plugin.

Parameters
plugin Plugin.
Returns Cubos.

Aborts if the plugin hasn't been added by this or any other plugin.

Cubos& cubos::core::ecs::Cubos::inject(Plugin target, Plugin plugin)

Marks the target plugin so that when it is added, it is replaced by the given plugin.

Parameters
target Target plugin.
plugin Plugin.
Returns Cubos.

Aborts if the target plugin has already been added.

Cubos& cubos::core::ecs::Cubos::uninitResource(const reflection::Type& type)

Registers a new resource type, without initializing it.

Parameters
type Type.
Returns Cubos.

Cubos& cubos::core::ecs::Cubos::resource(memory::AnyValue value)

Registers a new resource type with the given initial value.

Parameters
value Resource value.
Returns Cubos.

template<typename T>
Cubos& cubos::core::ecs::Cubos::uninitResource()

Registers a new resource type, without initializing it.

Template parameters
T Type.
Returns Cubos.

template<typename T, typename... TArgs>
Cubos& cubos::core::ecs::Cubos::resource(TArgs && ... args)

Registers a new resource type, constructing it with the given arguments.

Template parameters
T Type.
TArgs Constructor argument types.
Parameters
args Constructor arguments.
Returns Cubos.

Cubos& cubos::core::ecs::Cubos::component(const reflection::Type& type)

Registers a new component type.

Parameters
type Type.
Returns Cubos.

template<typename T>
Cubos& cubos::core::ecs::Cubos::component()

Registers a new component type.

Template parameters
T Type.
Returns Cubos.

Cubos& cubos::core::ecs::Cubos::relation(const reflection::Type& type)

Registers a new relation type.

Parameters
type Type.
Returns Cubos.

template<typename T>
Cubos& cubos::core::ecs::Cubos::relation()

Registers a new relation type.

Template parameters
T Type.
Returns Cubos.

template<typename T>
Cubos& cubos::core::ecs::Cubos::event()

Registers a new event type.

Template parameters
T Type.
Returns Reference to this object, for chaining.

TagBuilder cubos::core::ecs::Cubos::tag(const Tag& tag)

Registers a new tag. Returns a builder used to configure tagged systems.

Parameters
tag Tag.
Returns TagBuilder.

TagBuilder cubos::core::ecs::Cubos::startupTag(const Tag& tag)

Registers a new startup tag. Returns a builder used to configure tagged systems.

Parameters
tag Tag.
Returns TagBuilder.

SystemBuilder cubos::core::ecs::Cubos::system(std::string name)

Returns a new builder used to add a system to the engine.

Parameters
name System debug name.
Returns Builder used to configure the system.

SystemBuilder cubos::core::ecs::Cubos::startupSystem(std::string name)

Returns a new builder used to add a startup system to the engine.

Parameters
name System debug name.
Returns Builder used to configure the system.

ObserverBuilder cubos::core::ecs::Cubos::observer(std::string name)

Returns a new builder used to add an observer to the engine.

Parameters
name Observer debug name.
Returns Builder used to configure the observer.

void cubos::core::ecs::Cubos::reset()

Resets the application to its initial state.

Equivalent to constructing a new Cubos object.

bool cubos::core::ecs::Cubos::update()

Runs the application's main systems.

Returns Whether the application should continue running, based on the ShouldQuit resource.

void cubos::core::ecs::Cubos::run()

Runs the application's main loop.

Equivalent to calling start() followed by update() until it returns false.

TagBuilder& cubos::core::ecs::Cubos::before(const Tag& tag)

Makes all tagged systems run before systems with the given tag.

Parameters
tag Tag.
Returns Builder.

TagBuilder& cubos::core::ecs::Cubos::after(const Tag& tag)

Makes all tagged systems run after systems with the given tag.

Parameters
tag Tag.
Returns Builder.

TagBuilder& cubos::core::ecs::Cubos::tagged(const Tag& tag)

Tags all tagged systems with the given tag.

Parameters
tag Tag.
Returns Builder.

TagBuilder& cubos::core::ecs::Cubos::addTo(const Tag& tag)

Equivalent to calling tagged on the given tag.

Parameters
tag Tag.
Returns Builder.

TagBuilder& cubos::core::ecs::Cubos::runIf(auto func)

Makes all systems within the tag run only if the given condition evaluates to true.

Parameters
func Condition system function.
Returns Builder.

TagBuilder& cubos::core::ecs::Cubos::repeatWhile(auto func)

Makes all systems within the tag repeat while the given condition evaluates to true.

Parameters
func Condition system function.
Returns Builder.

SystemBuilder&& cubos::core::ecs::Cubos::tagged(const Tag& tag) &&

Adds a tag to the system.

Parameters
tag Tag.
Returns Builder.

SystemBuilder&& cubos::core::ecs::Cubos::before(const Tag& tag) &&

Forces this system to only run after all systems with the given tag have finished.

Parameters
tag Tag.
Returns Builder.

SystemBuilder&& cubos::core::ecs::Cubos::after(const Tag& tag) &&

Forces all systems with the given tag to run only after this system has finished.

Parameters
tag Tag.
Returns Builder.

SystemBuilder&& cubos::core::ecs::Cubos::entity(int target = -1) &&

Forces the next entity query argument to have the given target.

Parameters
target Target index. By default, the last specified target or 0.
Returns Builder.

SystemBuilder&& cubos::core::ecs::Cubos::with(const reflection::Type& type, int target = -1) &&

Forces the given target of the next query argument to have the following component.

Parameters
type Component type.
target Target index. By default, the last specified target or 0.
Returns Builder.

template<typename T>
SystemBuilder&& cubos::core::ecs::Cubos::with(int target = -1) &&

Template parameters
T Component type.

SystemBuilder&& cubos::core::ecs::Cubos::withOpt(const reflection::Type& type, int target = -1) &&

Accepts the following component from the given target of the next query argument.

Parameters
type Component type.
target Target index. By default, the last specified target or 0.
Returns Builder.

template<typename T>
SystemBuilder&& cubos::core::ecs::Cubos::withOpt(int target = -1) &&

Template parameters
T Component type.

SystemBuilder&& cubos::core::ecs::Cubos::without(const reflection::Type& type, int target = -1) &&

Forces the given target of the next query argument to not have the following component.

Parameters
type Component type.
target Target. By default, the last specified target or 0.
Returns Builder.

template<typename T>
SystemBuilder&& cubos::core::ecs::Cubos::without(int target = -1) &&

Template parameters
T Component type.

SystemBuilder&& cubos::core::ecs::Cubos::related(const reflection::Type& type, int fromTarget = -1, int toTarget = -1) &&

Forces the given targets of the next query argument to be related with the given relation.

Parameters
type Relation type.
fromTarget From target index. By default, the last specified target or 0.
toTarget From target index. By default, fromTarget + 1.
Returns Builder.

template<typename T>
SystemBuilder&& cubos::core::ecs::Cubos::related(int fromTarget = -1, int toTarget = -1) &&

Template parameters
T Relation type.

SystemBuilder&& cubos::core::ecs::Cubos::related(const reflection::Type& type, Traversal traversal, int fromTarget = -1, int toTarget = -1) &&

Forces the given targets of the next query argument to be related with the given tree relation.

Parameters
type Relation type.
traversal Tree traversal direction.
fromTarget From target index. By default, the last specified target or 0.
toTarget From target index. By default, fromTarget + 1.
Returns Builder.

template<typename T>
SystemBuilder&& cubos::core::ecs::Cubos::related(Traversal traversal, int fromTarget = -1, int toTarget = -1) &&

Template parameters
T Relation type.

SystemBuilder&& cubos::core::ecs::Cubos::other() &&

Makes the following argument options relative to the next argument.

Returns Builder.

SystemBuilder&& cubos::core::ecs::Cubos::onlyIf(auto function) &&

Makes the system only run if the given condition evaluates to true.

Parameters
function Condition function.
Returns Builder.

The condition runs immediately before the system runs, and is basically just like a normal system, but which returns a boolean instead of void.

void cubos::core::ecs::Cubos::call(auto function) &&

Finishes building the system with the given function.

Parameters
function System function.

ObserverBuilder&& cubos::core::ecs::Cubos::onAdd(const reflection::Type& type, int target = -1) &&

Triggers the observer whenever the given component is added to an entity.

Parameters
type Component type.
target Target index. By default, the last specified target or 0.
Returns Builder.

template<typename T>
ObserverBuilder&& cubos::core::ecs::Cubos::onAdd(int target = -1) &&

Template parameters
T Component type.

ObserverBuilder&& cubos::core::ecs::Cubos::onRemove(const reflection::Type& type, int target = -1) &&

Triggers the observer whenever the given component is removed from an entity, or an entity with it is destroyed.

Parameters
type Component type.
target Target index. By default, the last specified target or 0.
Returns Builder.

template<typename T>
ObserverBuilder&& cubos::core::ecs::Cubos::onRemove(int target = -1) &&

Template parameters
T Component type.

ObserverBuilder&& cubos::core::ecs::Cubos::entity(int target = -1) &&

Forces the next entity query argument to have the given target.

Parameters
target Target index. By default, the last specified target or 0.
Returns Builder.

ObserverBuilder&& cubos::core::ecs::Cubos::with(const reflection::Type& type, int target = -1) &&

Forces the given target of the next query argument to have the following component.

Parameters
type Component type.
target Target index. By default, the last specified target or 0.
Returns Builder.

template<typename T>
ObserverBuilder&& cubos::core::ecs::Cubos::with(int target = -1) &&

Template parameters
T Component type.

ObserverBuilder&& cubos::core::ecs::Cubos::without(const reflection::Type& type, int target = -1) &&

Forces the given target of the next query argument to not have the following component.

Parameters
type Component type.
target Target. By default, the last specified target or 0.
Returns Builder.

template<typename T>
ObserverBuilder&& cubos::core::ecs::Cubos::without(int target = -1) &&

Template parameters
T Component type.

ObserverBuilder&& cubos::core::ecs::Cubos::related(const reflection::Type& type, int fromTarget = -1, int toTarget = -1) &&

Forces the given targets of the next query argument to be related with the given relation.

Parameters
type Relation type.
fromTarget From target index. By default, the last specified target or 0.
toTarget From target index. By default, fromTarget + 1.
Returns Builder.

template<typename T>
ObserverBuilder&& cubos::core::ecs::Cubos::related(int fromTarget = -1, int toTarget = -1) &&

Template parameters
T Relation type.

ObserverBuilder&& cubos::core::ecs::Cubos::related(const reflection::Type& type, Traversal traversal, int fromTarget = -1, int toTarget = -1) &&

Forces the given targets of the next query argument to be related with the given tree relation.

Parameters
type Relation type.
traversal Tree traversal direction.
fromTarget From target index. By default, the last specified target or 0.
toTarget From target index. By default, fromTarget + 1.
Returns Builder.

template<typename T>
ObserverBuilder&& cubos::core::ecs::Cubos::related(Traversal traversal, int fromTarget = -1, int toTarget = -1) &&

Template parameters
T Relation type.

ObserverBuilder&& cubos::core::ecs::Cubos::other() &&

Makes the following argument options relative to the next argument.

Returns Builder.

void cubos::core::ecs::Cubos::call(auto function) &&

Finishes building the observer with the given function.

Parameters
function System function.