Skip to main content

GameObjectLifecycleSystem Class

Reacts to HealthDepletedEvents and despawns or deactivates entities. More...

Declaration

class helios::engine::mechanics::lifecycle::systems::GameObjectLifecycleSystem { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions Index

voidupdate (helios::engine::runtime::world::UpdateContext &updateContext) noexcept

Processes health depletion events and enqueues despawn commands. More...

Description

Reacts to HealthDepletedEvents and despawns or deactivates entities.

Reads HealthDepletedEvents from the phase bus. For each affected entity, the system inspects the HealthComponent's HealthDepletedBehavior flags:

Definition at line 57 of file GameObjectLifecycleSystem.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::mechanics::lifecycle::systems::GameObjectLifecycleSystem::EngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions

update()

void helios::engine::mechanics::lifecycle::systems::GameObjectLifecycleSystem::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Processes health depletion events and enqueues despawn commands.

Parameters
updateContext

Current frame context.

Definition at line 68 of file GameObjectLifecycleSystem.ixx.

69
70 auto events = updateContext.readPass<HealthDepletedEvent>();
71
72 for (auto& event : events) {
73 auto go = updateContext.find(event.source());
74
75 if (go) {
76
78 if (hc) {
79 auto healthDepletedBehavior = hc->healthDepletedBehavior();
80 if (hasHealthDepletedFlag(healthDepletedBehavior, HealthDepletedBehavior::Despawn)) {
81 if (auto* sbp = go->get<SpawnedByProfileComponent>()) {
82 assert(sbp->spawnProfileId().value() != 0 && "Entity has no SpawnProfileId.");
83 updateContext.queueCommand<DespawnCommand>(go->entityHandle(), sbp->spawnProfileId());
84 } else {
85 go->setActive(false);
86 /**
87 * @todo remove from gameworld
88 */
89 }
90 }
91 }
92 }
93
94 }
95
96 }

References helios::engine::mechanics::health::types::Despawn and helios::engine::mechanics::health::types::hasHealthDepletedFlag.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.