44 template<
CComponent C,
typename... Args>
inline C&
add(Args&&... args)
noexcept(std::is_nothrow_constructible_v<
C, Args...>) {
57 inline C&
addWith(
Block&&
block, Args&&... args)
noexcept(std::is_nothrow_constructible_v<
C, Args...>) {
67 template<
CComponent C,
typename... Args>
inline C&
set(Args&&... args)
noexcept(std::is_nothrow_constructible_v<
C, Args...>) {
The base entity class.
Definition Entity.hpp:41
AbstractComponent & add(const ComponentType &type, const Box &initialValue=nullptr) const
Adds a new component of the given type.
AbstractComponent * getIf(const ComponentType &type) const
Gets a component of the given type.
C & addWith(Block &&block, Args &&... args) const noexcept(std::is_nothrow_constructible_v< C, Args... >)
Adds a new component and calls block with the added component.
AbstractComponent & get(const ComponentType &type) const
Gets a component of the given type.
void remove(const ComponentType &type) const
Removes a component of the given type from the entity.
bool has(const ComponentType &type) const noexcept
Checks if the entity has all components of the given type.
C & set(Args &&... args) const noexcept(std::is_nothrow_constructible_v< C, Args... >)
Sets a component.
AbstractComponent & getOr(const ComponentType &type) const
Gets a component of the given type.
Definition EntityScript.hpp:16
C & add(Args &&... args) noexcept(std::is_nothrow_constructible_v< C, Args... >)
Adds a new component.
Definition EntityScript.hpp:44
const C * getIf() const noexcept
Gets a component of type C.
Definition EntityScript.hpp:129
virtual void onDestroy()
A function called by the runtime whenever the script is destroyed.
Definition EntityScript.hpp:35
Tuple< C0 &, C1 &, Cs &... > get() noexcept
Gets a set of components of types C0, C1 and Cs.
Definition EntityScript.hpp:91
C * getIf() noexcept
Gets a component of type C.
Definition EntityScript.hpp:123
C & addWith(Block &&block, Args &&... args) noexcept(std::is_nothrow_constructible_v< C, Args... >)
Adds a new component and calls block with the added component.
Definition EntityScript.hpp:57
C & get() noexcept
Gets a component of type C.
Definition EntityScript.hpp:78
Tuple< C0 &, C1 &, Cs &... > getOr() noexcept
Gets a set of components of types C0, C1 and Cs.
Definition EntityScript.hpp:117
void remove() noexcept(std::is_nothrow_destructible_v< C >)
Removes a component of type C from the entity.
Definition EntityScript.hpp:73
Tuple< const C0 &, const C1 &, const Cs &... > get() const noexcept
Gets a set of components of types C0, C1 and Cs.
Definition EntityScript.hpp:101
virtual void onCreate()
A function called by the runtime whenever the script is first created.
Definition EntityScript.hpp:28
C & getOr() noexcept(std::is_nothrow_constructible_v< C >)
Gets a component of type C.
Definition EntityScript.hpp:109
Tuple< C0 *, C1 *, Cs *... > getIf() noexcept
Gets a set of components of types C0, C1 and Cs.
Definition EntityScript.hpp:137
const C & get() const noexcept
Gets a component of type C.
Definition EntityScript.hpp:83
virtual void update(double dt)
A function called by the runtime every update iteration.
Definition EntityScript.hpp:32
Tuple< const C0 *, const C1 *, const Cs *... > getIf() const noexcept
Gets a set of components of types C0, C1 and Cs.
Definition EntityScript.hpp:147
Entity mEntity
The entity associated with this script instance.
Definition EntityScript.hpp:21
virtual ~EntityScript()=default
bool has() const noexcept
Checks if the entity has all components of types Cs.
Definition EntityScript.hpp:154
C & set(Args &&... args) noexcept(std::is_nothrow_constructible_v< C, Args... >)
Sets a component.
Definition EntityScript.hpp:67
Definition ScriptingSystem.hpp:18
Tuple is a fixed-size collection of heterogeneous values.
Definition Tuple.hpp:15
Definition Component.hpp:117
Definition Application.hpp:19
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25