Skip to main content

builder Folder

Folders Index

foldergameObject
folderspawnSystem

Files Index

filehelios/engine/builder/_module.ixx

Module aggregation for helios.engine.builder. More...

Description

helios::engine::builder

Fluent builder pattern implementation for constructing game entities in the helios engine.

Overview

This module provides a declarative, composable API for creating GameObject instances with their associated components. The builder pattern enables clean, readable entity construction while abstracting the complexity of component dependencies and initialization order.

Key Classes

ClassPurpose
GameObjectFactoryEntry point for creating and cloning GameObjects
GameObjectPrototypeFluent builder for configuring entity components

Submodules

gameObject/

The main factory and prototype classes for GameObject construction.

gameObject/builders/

Domain-specific builders for different aspects of entity configuration:

BuilderPurpose
MotionBuilderMovement and steering configuration
RenderingBuilderVisual representation setup
SceneBuilderScene graph integration
CollisionBuilderCollision detection configuration
TransformBuilderSpatial transform setup
UiTransformBuilderUI/viewport-relative transform setup
EffectsBuilderVisual effects (spin, etc.)
SpawnBuilderSpawn system integration
AiBuilderAI behavior configuration
CombatBuilderWeapon and projectile setup
LifecycleBuilderEntity lifecycle (active/inactive)
HealthBuilderHealth and damage configuration
ScoringBuilderScore tracking configuration
ObserverBuilderData binding and observation

gameObject/builders/configs/

Fine-grained configuration classes used by builders:

ConfigPurpose
Move2DConfig2D movement parameters
SteeringConfigRotation and steering behavior
MeshRenderableConfigMesh, material, and shader setup
TextRenderableConfigText rendering setup
SceneNodeConfigScene graph parenting and inheritance
TransformConfigScale and translation
UiTransformConfigUI/viewport-relative positioning
CollisionConfigCollision layers and responses
LevelBoundsCollisionConfigArena boundary behavior
GfxEffectsConfigVisual effects parameters
SpawnConfigSpawn profile integration
ChaseConfigAI chase behavior
WeaponConfigWeapon fire rate and projectiles
CombatConfigCombat system configuration
LifecycleConfigEntity lifecycle settings
HealthConfigHealth and max health values
ScoreValueConfigScore value on defeat
ScorePoolConfigScore pool binding
ObserverConfigData observation/binding

Usage

Creating a New GameObject

 auto player = GameObjectFactory::gameObject()
  .withMotion([](auto& motion) {
  motion.move2D()
  .speed(5.0f)
  .acceleration(10.0f);
  motion.steering()
  .instantSteering(false);
  })
  .withRendering([&](auto& rendering) {
  rendering.renderable()
  .shape(triangleShape)
  .shader(shader)
  .primitiveType(PrimitiveType::Triangles)
  .color({1.0f, 0.0f, 0.0f, 1.0f})
  .attachTo(rootNode);
  })
  .withCollision([](auto& collision) {
  collision.collision()
  .useBoundingBox()
  .layerId(PLAYER_LAYER);
  })
  .make(true); // active = true

Cloning an Existing GameObject

 auto enemyTemplate = createEnemyTemplate();
 auto enemy = GameObjectFactory::from(enemyTemplate.get())
  .withTransform([&](auto& transform) {
  transform.transform()
  .translate(spawnPosition);
  })
  .make(true);

Architecture

 ┌─────────────────────────────────────────────────────────────────┐
 │ GameObjectFactory │
 │ ┌───────────────────────────────────────────────────────────┐ │
 │ │ GameObjectPrototype │ │
 │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
 │ │ │MotionBuilder│ │RenderingBld │ │CollisionBld │ ... │ │
 │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ │
 │ │ │ │ │ │ │
 │ │ ▼ ▼ ▼ │ │
 │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
 │ │ │ Move2DConfig│ │RenderableCfg│ │CollisionCfg │ ... │ │
 │ │ │SteeringCfg │ │SceneNodeCfg │ │LevelBndsCfg │ │ │
 │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ │
 │ │ │ │ │ │ │
 │ │ ▼ ▼ ▼ │ │
 │ │ ┌─────────────────────────────────────────────────────┐ │ │
 │ │ │ GameObject │ │ │
 │ │ │ [Move2DComponent] [RenderableComponent] [...] │ │ │
 │ │ └─────────────────────────────────────────────────────┘ │ │
 │ └───────────────────────────────────────────────────────────┘ │
 └─────────────────────────────────────────────────────────────────┘

Design Principles

The builder module follows these principles:

1. Fluent Interface: Method chaining for readable configuration. 2. Callback-Based Configuration: Builders are configured via lambdas, allowing scoped access. 3. Automatic Dependencies: Configs automatically add required dependent components. 4. Separation of Concerns: Each builder focuses on a single domain (motion, rendering, etc.). 5. Cloning Support: GameObjectFactory::from() creates new entities based on existing templates.

Related Modules

ModulePurpose
helios.engine.ecsGameObject, Component base classes
helios.engine.modulesComponent implementations used by configs
helios.engine.mechanicsGameplay-specific components


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.