Skip to main content

ai Folder

Folders Index

foldercomponents
foldersystems

Files Index

filehelios/engine/modules/ai/_module.ixx

Aggregate module for helios::engine::modules::ai namespace. More...

filemodules/ai/registry.ixx

Component registration for AI module. More...

Description

helios::engine::modules::ai

AI behavior modules for game entities in the helios engine.

Overview

This module provides components and systems for artificial intelligence behaviors. Currently focused on simple pursuit/chase mechanics, with architecture designed for expansion to more complex AI patterns.

Submodules

components/

Data components storing AI behavior state:

ComponentPurpose
ChaseComponentTracks a target entity and controls pursuit timing

systems/

Systems that process AI components:

SystemPurpose
ChaseSystemSteers entities towards their chase targets

Usage

Basic Chase Behavior

 import helios.engine.modules.ai;
 
 // Create enemy that chases player
 auto enemy = std::make_unique<GameObject>();
 enemy->add<ChaseComponent>();
 enemy->get<ChaseComponent>()->setTarget(player->guid());
 enemy->get<ChaseComponent>()->setCooldown(0.5f); // Update direction every 0.5s
 
 // Required companion components
 enemy->add<SteeringComponent>();
 enemy->add<TranslationStateComponent>();

Using with GameObjectFactory

 auto enemy = GameObjectFactory::gameObject()
  .withAi([&](auto& ai) {
  ai.chasing()
  .target(player->guid())
  .seekInterval(0.5f);
  })
  .withMotion([](auto& m) {
  m.steering().instantSteering(true);
  m.move2D().speed(3.0f);
  })
  .make(true);

Chase Behavior Details

The ChaseSystem operates as follows:

1. Target Lookup: Finds target entity by handle in GameWorld 2. Cooldown Check: Only updates direction after cooldown expires 3. Direction Calculation: Computes normalized vector from entity to target 4. Steering Update: Sets steering intent to face target direction

 ┌─────────────────────────────────────────────────────────────┐
 │ ChaseSystem │
 │ ┌─────────────────────────────────────────────────────────┐│
 │ │ For each entity with: ││
 │ │ - ChaseComponent ││
 │ │ - SteeringComponent ││
 │ │ - TranslationStateComponent ││
 │ ├─────────────────────────────────────────────────────────┤│
 │ │ 1 Find target by handle ││
 │ │ 2 Update cooldown timer ││
 │ │ 3 If timer >= cooldown: ││
 │ │ - Calculate direction to target ││
 │ │ - Set steering intent ││
 │ │ - Reset timer ││
 │ └─────────────────────────────────────────────────────────┘│
 └─────────────────────────────────────────────────────────────┘

Component Dependencies

ComponentRequired Companions
ChaseComponentSteeringComponent, TranslationStateComponent

Related Modules

ModulePurpose
helios.engine.modules.physics.motionSteeringComponent for direction control
helios.engine.modules.spatial.transformTranslationStateComponent for position
helios.engine.builderChaseConfig for fluent setup


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.