Skip to main content

RandomSpawnPlacer Class

Placer that spawns entities at random positions within bounds. More...

Declaration

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

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

Returns a random position within the level bounds. More...

voidonReset () noexcept override

Resets the random number generator to its initial seed. More...

Private Member Attributes Index

helios::util::RandomrGen_ {12345}

Description

Placer that spawns entities at random positions within bounds.

RandomSpawnPlacer generates random X and Y coordinates within the provided level bounds. The Z coordinate is set to 0, making this suitable for 2D games.

info

Uses a static Random generator with a fixed seed for reproducibility.

See Also

SpawnPlacer

Definition at line 30 of file RandomSpawnPlacer.ixx.

Public Member Functions

getPosition()

helios::math::vec3f helios::engine::runtime::spawn::behavior::placements::RandomSpawnPlacer::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 a random position within the level bounds.

Parameters
entityHandle

The handle of the entity being spawned (unused).

gameObjectBounds

The bounding box of the entity to spawn (unused).

environmentBounds

The level bounds to spawn within.

cursor

The current position within the spawn batch (unused).

spawnContext

Context data (unused).

Returns

A random vec3f with Z = 0.

Definition at line 47 of file RandomSpawnPlacer.ixx.

48 const helios::engine::ecs::EntityHandle& entityHandle,
49 const helios::math::aabbf& gameObjectBounds,
50 const helios::math::aabbf& environmentBounds,
51 const SpawnPlanCursor& cursor,
52 const SpawnContext& spawnContext
53 ) override {
54
55
56 float xPos = rGen_.randomFloat(environmentBounds.min()[0], environmentBounds.max()[0]);
57 float yPos = rGen_.randomFloat(environmentBounds.min()[1], environmentBounds.max()[1]);
58
59 return helios::math::vec3f{xPos, yPos, 0.0f};
60 }

References helios::math::aabb< T >::max and helios::math::aabb< T >::min.

onReset()

void helios::engine::runtime::spawn::behavior::placements::RandomSpawnPlacer::onReset ()
inline noexcept virtual

Resets the random number generator to its initial seed.

Definition at line 65 of file RandomSpawnPlacer.ixx.

65 void onReset() noexcept override {
66 rGen_.reset();
67 }

Private Member Attributes

rGen_

helios::util::Random helios::engine::runtime::spawn::behavior::placements::RandomSpawnPlacer::rGen_ {12345}

Definition at line 32 of file RandomSpawnPlacer.ixx.

32 helios::util::Random rGen_{12345};

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.