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.core.data.ComponentTypeId>
#include <helios.engine.runtime.world.UpdateContext>
#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 {
77 class GameObject {
82 helios::engine::ecs::EntityHandle entityHandle_{0,0};
87 helios::engine::ecs::EntityManager* entityManager_;
98 explicit GameObject(
100 helios::engine::ecs::EntityManager* entityManager
102 ) noexcept : entityHandle_(entityHandle), entityManager_(entityManager) {
112 componentTypeIds() const {
121 [[nodiscard]] helios::engine::ecs::EntityHandle entityHandle() noexcept {
130 [[nodiscard]] helios::engine::ecs::EntityHandle entityHandle() const noexcept {
152 if (entityManager_->has<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_)) {
160 auto typeId = helios::engine::core::data::ComponentTypeId::id<T>();
161 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
162 void* raw = entityManager_->raw(entityHandle_, typeId);
165 ops.onActivate(raw);
167 ops.onDeactivate(raw);
188 return add<T>(std::forward<Args>(args)...);
198 void* raw(const helios::engine::core::data::ComponentTypeId typeId) {
245 bool has(helios::engine::core::data::ComponentTypeId typeId) {
254 void enableComponent(const helios::engine::core::data::ComponentTypeId typeId) {
263 void disableComponent(const helios::engine::core::data::ComponentTypeId typeId) {
286 entityManager_->remove<helios::engine::mechanics::lifecycle::components::Inactive>(entityHandle_);
287 entityManager_->emplaceOrGet<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
289 entityManager_->emplaceOrGet<helios::engine::mechanics::lifecycle::components::Inactive>(entityHandle_);
290 entityManager_->remove<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
293 for (auto typeId : componentTypeIds()) {
294 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
295 void* raw = entityManager_->raw(entityHandle_, typeId);
298 ops.onActivate(raw);
300 ops.onDeactivate(raw);
311 return entityManager_->has<helios::engine::mechanics::lifecycle::components::Active>(entityHandle_);
321 for (auto typeId : componentTypeIds()) {
322 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
323 void* raw = entityManager_->raw(entityHandle_, typeId);
326 ops.onRelease(raw);
338 for (auto typeId : componentTypeIds()) {
339 const auto ops = helios::engine::ecs::ComponentOpsRegistry::ops(typeId);
340 void* raw = entityManager_->raw(entityHandle_, typeId);
343 ops.onAcquire(raw);
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.