2#include <engine/engine_export.h>
40 auto& component =
entity.get<T>();
41 component.set_owner(
entity);
80 entt::handle owner_{};
89template<
typename T,
typename Base = basic_component>
104 return entity.all_of<T>();
109 bool has_component =
entity.all_of<T>();
120 size_t removed =
entity.remove<T>();
124 static auto save(entt::handle
entity, std::stringstream& stream) ->
bool
129 ar(ser20::make_nvp(
"component",
entity.get<T>()));
132 catch(
const ser20::Exception& e)
134 APPLOG_ERROR(
"Failed to save component to stream: {}", e.what());
139 static auto load(entt::handle
entity, std::stringstream& stream) ->
bool
144 ar(ser20::make_nvp(
"component",
entity.get<T>()));
147 catch(
const ser20::Exception& e)
149 APPLOG_ERROR(
"Failed to load component from stream: {}", e.what());
Component that is owned by an entity.
auto operator=(const owned_component &other) -> owned_component &=default
static void on_destroy_component(entt::registry &r, entt::entity e)
static void on_create_component(entt::registry &r, entt::entity e)
auto get_owner() const noexcept -> entt::const_handle
Gets the owner of the component.
void set_owner(entt::handle owner)
Sets the owner of the component.
auto get_owner() noexcept -> entt::handle
Gets the owner of the component.
#define APPLOG_ERROR(...)
auto create_oarchive_associative(std::ostream &stream)
auto create_iarchive_associative(std::istream &stream)
Basic component structure that other components can inherit from.
bool eto
Disable empty type optimizations.
void touch()
Marks the component as 'touched'.
CRTP (Curiously Recurring Template Pattern) base structure for components.
static constexpr bool in_place_delete
Indicates if the component can be deleted in place.