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::util::Guid &guid, const helios::math::aabbf &bounds, const SpawnPlanCursor &cursor, const SpawnContext &spawnContext) override

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

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 29 of file RandomSpawnPlacer.ixx.

Public Member Functions

getPosition()

helios::math::vec3f helios::engine::runtime::spawn::behavior::placements::RandomSpawnPlacer::getPosition (const helios::util::Guid & guid, const helios::math::aabbf & bounds, const SpawnPlanCursor & cursor, const SpawnContext & spawnContext)
inline virtual

Returns a random position within the level bounds.

Parameters
guid

The GUID of the entity being spawned (unused).

bounds

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 43 of file RandomSpawnPlacer.ixx.

44 const helios::util::Guid& guid,
45 const helios::math::aabbf& bounds,
46 const SpawnPlanCursor& cursor,
47 const SpawnContext& spawnContext
48 ) override {
49
50 static auto rGen = helios::util::Random(12345);
51
52 float xPos = rGen.randomFloat(bounds.min()[0], bounds.max()[0]);
53 float yPos = rGen.randomFloat(bounds.min()[1], bounds.max()[1]);
54
55 return helios::math::vec3f{xPos, yPos, 0.0f};
56 }

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


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.