Skip to main content

ColumnSpawnPlacer Class

Places spawned entities in a vertical column formation. More...

Declaration

class helios::engine::runtime::spawn::behavior::placements::ColumnSpawnPlacer { ... }

Base class

classSpawnPlacer

Abstract interface for determining spawn positions. More...

Public Member Functions Index

helios::math::vec3fgetPosition (const helios::engine::ecs::EntityHandle &entityHandle, const helios::math::aabbf &gameObjectBounds, const helios::math::aabbf &environmentBounds, const SpawnPlanCursor &cursor, const SpawnContext &spawnContext) override

Calculates spawn position for a vertical column layout. More...

Description

Places spawned entities in a vertical column formation.

Distributes entities evenly along the Y-axis within the environment bounds. Entities are positioned at the left edge (min X) of the environment and spaced vertically based on the spawn count.

For single spawns, a random Y position is chosen within bounds. For multiple spawns, entities are evenly distributed from top to bottom.

Example layout for 4 entities: ``` ┌─────────────────────┐ │ ○ │ <- position 1 │ │ │ ○ │ <- position 2 │ │ │ ○ │ <- position 3 │ │ │ ○ │ <- position 4 └─────────────────────┘ ```

Definition at line 46 of file ColumnSpawnPlacer.ixx.

Public Member Functions

getPosition()

helios::math::vec3f helios::engine::runtime::spawn::behavior::placements::ColumnSpawnPlacer::getPosition (const helios::engine::ecs::EntityHandle & entityHandle, const helios::math::aabbf & gameObjectBounds, const helios::math::aabbf & environmentBounds, const SpawnPlanCursor & cursor, const SpawnContext & spawnContext)
inline virtual

Calculates spawn position for a vertical column layout.

Parameters
entityHandle

The handle of the entity being spawned.

gameObjectBounds

The AABB of the entity to spawn.

environmentBounds

The AABB of the spawn environment (arena).

cursor

Current position in the spawn batch.

spawnContext

Additional context for spawn decisions.

Returns

World position for the entity (left edge, vertically distributed).

Definition at line 61 of file ColumnSpawnPlacer.ixx.

62 const helios::engine::ecs::EntityHandle& entityHandle,
63 const helios::math::aabbf& gameObjectBounds,
64 const helios::math::aabbf& environmentBounds,
65 const SpawnPlanCursor& cursor,
66 const SpawnContext& spawnContext
67 ) override {
68
69 const float top = environmentBounds.max()[1];
70 const float bottom = environmentBounds.min()[1];
71 const float height = std::abs(top - bottom);
72
73 const float objectHeight = gameObjectBounds.size()[1];
74
75 size_t position = cursor.position;
76
77 float dist;
78 if (cursor.spawnCount == 1) {
79 dist = helios::util::Random(12345).randomFloat(0, height - objectHeight);
80 position = 1;
81 } else {
82 dist = height / static_cast<float>(cursor.spawnCount);
83 }
84
85 const float x = environmentBounds.min()[0];
86 const float y = top - (static_cast<float>(position) * dist) - (objectHeight / 2.0f);
87
88 return helios::math::vec3f{x, y, 0.0f};
89
90 }

References helios::math::aabb< T >::max, helios::math::aabb< T >::min, helios::engine::runtime::spawn::SpawnPlanCursor::position, helios::util::Random::randomFloat, helios::math::aabb< T >::size and helios::engine::runtime::spawn::SpawnPlanCursor::spawnCount.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.