|
|
@ -65,7 +65,11 @@ namespace ant::core { |
|
|
|
auto set_visible(bool visible) -> bool { |
|
|
|
return std::exchange(m_is_visible, visible); |
|
|
|
} |
|
|
|
virtual void initialize() {} |
|
|
|
virtual void initialize() { |
|
|
|
for (auto& comp : m_components) { |
|
|
|
comp->initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
virtual void render() { |
|
|
|
if(not visibility_flag()) return; |
|
|
|
for(auto& child : m_children | std::views::filter([](const std::shared_ptr<entity>& elem){return elem->visibility_flag();})) { |
|
|
@ -109,9 +113,11 @@ namespace ant::core { |
|
|
|
|
|
|
|
template<std::derived_from<entity> EntityType> |
|
|
|
friend auto make_entity(const std::shared_ptr<entity>& parent, auto&&... ARGS) -> std::shared_ptr<EntityType>; |
|
|
|
|
|
|
|
template<std::derived_from<entity> EntityType> |
|
|
|
friend auto make_entity(auto&&... ARGS) -> std::shared_ptr<EntityType>; |
|
|
|
|
|
|
|
template<std::derived_from<entity> EntityType> |
|
|
|
friend auto make_entity(auto&&... ARGS) -> std::shared_ptr<EntityType>; |
|
|
|
|
|
|
|
friend auto make_entity(const std::shared_ptr<entity>& parent) -> std::shared_ptr<entity>; |
|
|
|
}; |
|
|
|
|
|
|
|
template<std::derived_from<entity> EntityType> |
|
|
@ -126,14 +132,26 @@ namespace ant::core { |
|
|
|
object->initialize(); |
|
|
|
return object; |
|
|
|
} |
|
|
|
|
|
|
|
template<std::derived_from<entity> EntityType> |
|
|
|
[[nodiscard]] auto make_entity(auto&&... ARGS) -> std::shared_ptr<EntityType> { |
|
|
|
auto object = std::make_shared<EntityType>(std::shared_ptr<entity>(nullptr), std::forward<decltype(ARGS)>(ARGS)...); |
|
|
|
const std::shared_ptr<entity>& entity_router = object; |
|
|
|
entity_router->m_parent = std::shared_ptr<entity>(nullptr); |
|
|
|
entity_router->m_self = object; |
|
|
|
object->initialize(); |
|
|
|
return object; |
|
|
|
} |
|
|
|
|
|
|
|
template<std::derived_from<entity> EntityType> |
|
|
|
[[nodiscard]] auto make_entity(auto&&... ARGS) -> std::shared_ptr<EntityType> { |
|
|
|
auto object = std::make_shared<EntityType>(std::shared_ptr<entity>(nullptr), std::forward<decltype(ARGS)>(ARGS)...); |
|
|
|
const std::shared_ptr<entity>& entity_router = object; |
|
|
|
entity_router->m_parent = std::shared_ptr<entity>(nullptr); |
|
|
|
entity_router->m_self = object; |
|
|
|
object->initialize(); |
|
|
|
return object; |
|
|
|
} |
|
|
|
|
|
|
|
[[nodiscard]] inline auto make_entity(const std::shared_ptr<entity>& parent) -> std::shared_ptr<entity> { |
|
|
|
auto object = std::make_shared<entity>(parent); |
|
|
|
const std::shared_ptr<entity>& entity_router = object; |
|
|
|
entity_router->m_parent = parent; |
|
|
|
entity_router->m_self = object; |
|
|
|
if(parent) { |
|
|
|
parent->m_children.push_back(object); |
|
|
|
} |
|
|
|
object->initialize(); |
|
|
|
return object; |
|
|
|
} |
|
|
|
} |