Skip to main content

DistributedSpawnPlacer Class Template

Spawn placer that assigns entities to predefined spawn points. More...

Declaration

template <std::size_t N> class helios::engine::runtime::spawn::behavior::placements::DistributedSpawnPlacer<N> { ... }

Base class

classSpawnPlacer

Abstract interface for determining spawn positions. More...

Public Constructors Index

template <typename... Args>
DistributedSpawnPlacer (Args &&...args)

Constructs a DistributedSpawnPlacer with N spawn locations. More...

Public Member Functions Index

template <std::size_t N>
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

Returns the spawn location for the current entity. More...

Private Member Attributes Index

template <std::size_t N>
std::array< helios::math::vec3f, N >locations_ {}

Fixed array of spawn point locations. More...

Description

Spawn placer that assigns entities to predefined spawn points.

DistributedSpawnPlacer uses a fixed-size array of locations to distribute spawned entities. Entities are assigned to locations based on their cursor position within the spawn batch, dividing the batch evenly across all available spawn points.

## Distribution Algorithm

Entities are mapped to locations using: `bin = N * (position / spawnCount)`

This ensures even distribution when spawn count exceeds location count, and direct mapping when spawn count equals location count.

## Use Cases

  • **Fixed spawn points:** Enemies spawning at predefined positions
  • **Formation patterns:** Entities placed in specific arrangements
  • **Level design:** Designer-defined spawn locations

## Usage

```cpp // Create placer with 3 fixed spawn points auto placer = std::make_unique<DistributedSpawnPlacer<3>>( helios::math::vec3f{-50.0f, 100.0f, 0.0f}, helios::math::vec3f{ 0.0f, 100.0f, 0.0f}, helios::math::vec3f{ 50.0f, 100.0f, 0.0f} );

// 3 entities spawn at the 3 locations // 6 entities: 2 per location ```

Template Parameters
N

Number of spawn locations.

See Also

SpawnPlacer

See Also

AxisSpawnPlacer

Definition at line 67 of file DistributedSpawnPlacer.ixx.

Public Constructors

DistributedSpawnPlacer()

template <typename... Args>
helios::engine::runtime::spawn::behavior::placements::DistributedSpawnPlacer< N >::DistributedSpawnPlacer (Args &&... args)
inline explicit

Constructs a DistributedSpawnPlacer with N spawn locations.

Template Parameters
Args

Types of location arguments (must be vec3f).

Parameters
args

Exactly N spawn point locations.

info

The number of arguments must match template parameter N.

Definition at line 87 of file DistributedSpawnPlacer.ixx.

87 explicit DistributedSpawnPlacer(Args&& ...args) : locations_({std::forward<Args>(args)... }) {}

Public Member Functions

getPosition()

template <std::size_t N>
helios::math::vec3f helios::engine::runtime::spawn::behavior::placements::DistributedSpawnPlacer< N >::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

Returns the spawn location for the current entity.

Maps the cursor position to one of the predefined locations by dividing the spawn batch evenly across available spawn points.

Parameters
guid

Unique identifier of the entity (unused).

gameObjectBounds

Bounding box of the entity (unused).

environmentBounds

Bounding box of the environment (unused).

cursor

Current spawn batch cursor with position and count.

spawnContext

Context for the spawn operation (unused).

Returns

World position from the locations array.

Definition at line 103 of file DistributedSpawnPlacer.ixx.

104 const helios::engine::ecs::EntityHandle& entityHandle,
105 const helios::math::aabbf& gameObjectBounds,
106 const helios::math::aabbf& environmentBounds,
107 const SpawnPlanCursor& cursor,
108 const SpawnContext& spawnContext
109 ) override {
110
111 const size_t bin = N * (cursor.position/static_cast<float>(cursor.spawnCount));
112
113 return locations_[bin];
114 }

References helios::engine::runtime::spawn::SpawnPlanCursor::position and helios::engine::runtime::spawn::SpawnPlanCursor::spawnCount.

Private Member Attributes

locations_

template <std::size_t N>
std::array<helios::math::vec3f, N> helios::engine::runtime::spawn::behavior::placements::DistributedSpawnPlacer< N >::locations_ {}

Fixed array of spawn point locations.

Definition at line 72 of file DistributedSpawnPlacer.ixx.

72 std::array<helios::math::vec3f, N> locations_{};

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.