GameObject.ixx File
High-level facade for entity manipulation in the ECS. More...
Included Headers
#include <cassert>
#include <type_traits>
#include <typeindex>
#include <generator>
#include <helios.core.data>
#include <helios.engine.ecs.types.ComponentTypeId>
#include <helios.engine.ecs.components.HierarchyComponent>
#include <helios.engine.ecs.EntityManager>
#include <helios.util.Guid>
#include <helios.engine.mechanics.lifecycle.components.Active>
#include <helios.engine.mechanics.lifecycle.components.Inactive>
#include <helios.engine.ecs.ComponentOpsRegistry>
#include <helios.engine.ecs.EntityHandle>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | ecs |
|
Core Entity-Component-System architecture. More... | |
Classes Index
| class | GameObject |
|
Lightweight facade for entity component manipulation. More... | |
Description
High-level facade for entity manipulation in the ECS.
File Listing
The file content with the documentation metadata removed is:
32export namespace helios::engine::ecs {
85 class GameObject {
90 helios::engine::ecs::EntityHandle entityHandle_{0,0};
95 helios::engine::ecs::EntityManager* entityManager_;
106 explicit GameObject(
107 const helios::engine::ecs::EntityHandle entityHandle,
108 helios::engine::ecs::EntityManager* entityManager
110 ) noexcept : entityHandle_(entityHandle), entityManager_(entityManager) {
120 componentTypeIds() const {
129 [[nodiscard]] helios::engine::ecs::EntityHandle entityHandle() noexcept {
138 [[nodiscard]] helios::engine::ecs::EntityHandle entityHandle() const noexcept {
160 if (entityManager_->has<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_)) {
168 auto typeId = helios::engine::ecs::types::ComponentTypeId::id<T>();
169 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
170 void* raw = entityManager_->raw(entityHandle_, typeId);
173 ops.onActivate(raw);
175 ops.onDeactivate(raw);
196 return add<T>(std::forward<Args>(args)...);
218 void* raw(const helios::engine::ecs::types::ComponentTypeId typeId) {
265 bool has(helios::engine::ecs::types::ComponentTypeId typeId) {
274 void enableComponent(const helios::engine::ecs::types::ComponentTypeId typeId) {
283 void disableComponent(const helios::engine::ecs::types::ComponentTypeId typeId) {
311 bool isActive = entityManager_->has<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
312 bool isInActive = entityManager_->has<helios::engine::mechanics::lifecycle::components::Inactive>(entityHandle_);
314 if (!isActive && active) {
315 auto* hc = entityManager_->get<helios::engine::ecs::components::HierarchyComponent>(entityHandle_);
320 entityManager_->remove<helios::engine::mechanics::lifecycle::components::Inactive>(entityHandle_);
321 entityManager_->emplaceOrGet<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
325 auto* hc = entityManager_->get<helios::engine::ecs::components::HierarchyComponent>(entityHandle_);
330 entityManager_->emplaceOrGet<helios::engine::mechanics::lifecycle::components::Inactive>(entityHandle_);
331 entityManager_->remove<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
334 for (auto typeId : componentTypeIds()) {
335 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
336 void* raw = entityManager_->raw(entityHandle_, typeId);
339 ops.onActivate(raw);
341 ops.onDeactivate(raw);
352 return entityManager_->has<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
362 for (auto typeId : componentTypeIds()) {
363 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
364 void* raw = entityManager_->raw(entityHandle_, typeId);
367 ops.onRelease(raw);
379 for (auto typeId : componentTypeIds()) {
380 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
381 void* raw = entityManager_->raw(entityHandle_, typeId);
384 ops.onAcquire(raw);
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.