Skip to main content

ChaseSystem Class

System that steers entities towards their chase targets. More...

Declaration

class helios::engine::modules::ai::systems::ChaseSystem { ... }

Public Member Typedefs Index

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

Public Member Functions Index

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

Updates steering for all chasing entities. More...

Description

System that steers entities towards their chase targets.

Processes all entities with ChaseComponent, SteeringComponent, and TranslationStateComponent. Updates steering intent to face the target entity based on a cooldown timer.

The system: 1. Finds the target entity by handle 2. Waits for the cooldown timer to expire 3. Calculates direction from entity to target 4. Sets steering intent to face that direction

Definition at line 48 of file ChaseSystem.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::modules::ai::systems::ChaseSystem::EngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions

update()

void helios::engine::modules::ai::systems::ChaseSystem::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Updates steering for all chasing entities.

Parameters
updateContext

Context providing delta time and game world access.

Definition at line 59 of file ChaseSystem.ixx.

60
61 for (auto [entity, sc, cc, tsc, active] : updateContext.view<
66 >().whereEnabled()) {
67
68 const auto entityHandle = cc->target();
69
70 auto go = updateContext.find(entityHandle);
71
72 if (!go || !go->isActive() || go->has<DeadTagComponent>()) {
73 continue;
74 }
75
77 if (!ttr) {
78 continue;
79 }
80
81 cc->updateCooldownTimerBy(updateContext.deltaTime());
82
83 if (cc->cooldownTimer() < cc->cooldown()) {
84 continue;
85 }
86
87 cc->setCooldownTimer(0.0f);
88
89 const auto translation = tsc->translation();
90 const auto direction = (ttr->translation() - translation).normalize();
91
92 if (std::abs(direction.length() - 1.0f) > helios::math::EPSILON_LENGTH) {
93 continue;
94 }
95
96 sc->setSteeringIntent(direction, 1.0f);
97
98 }
99 }

References helios::math::EPSILON_LENGTH, helios::math::vec3< T >::normalize and helios::engine::modules::spatial::transform::components::TranslationStateComponent::translation.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.