MoveInitializer.ixx File
Spawn initializer that sets initial movement direction for spawned entities. More...
Included Headers
#include <cassert>
#include <cmath>
#include <helios.util.Random>
#include <helios.math>
#include <helios.engine.modules.physics.motion.components.SteeringComponent>
#include <helios.engine.modules.spatial.transform.components.TranslationStateComponent>
#include <helios.engine.modules.spatial.transform.components.RotationStateComponent>
#include <helios.engine.modules.physics.motion.components.DirectionComponent>
#include <helios.engine.modules.physics.motion.components.Move2DComponent>
#include <helios.engine.ecs.GameObject>
#include <helios.engine.runtime.spawn.types.SpawnContext>
#include <helios.engine.runtime.spawn.types.SpawnPlanCursor>
#include <helios.engine.runtime.spawn.behavior.SpawnInitializer>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | runtime |
|
Runtime infrastructure for game execution and lifecycle orchestration. More... | |
| namespace | spawn |
|
Entity spawning infrastructure for the helios engine. More... | |
| namespace | behavior |
|
Spawn behavior strategies for positioning and initializing entities. More... | |
| namespace | initializers |
|
Concrete SpawnInitializer implementations. More... | |
Classes Index
| class | MoveInitializer |
|
Initializer that sets movement direction for spawned entities. More... | |
Description
Spawn initializer that sets initial movement direction for spawned entities.
File Listing
The file content with the documentation metadata removed is:
27using namespace helios::engine::runtime::spawn::types;
28export namespace helios::engine::runtime::spawn::behavior::initializers {
33 enum class DirectionType {
112 class MoveInitializer final : public SpawnInitializer {
114 helios::util::Random rGen_{12345};
119 const DirectionType directionType_ = DirectionType::Random;
122 * @brief Stores the custom direction target (axis/point) when using DirectionType::Axis/::Point.
124 helios::math::vec3f direction_{};
141 helios::engine::ecs::GameObject gameObject,
142 const SpawnPlanCursor& cursor,
143 const SpawnContext& spawnContext
146 auto* mc = gameObject.get<helios::engine::modules::physics::motion::components::Move2DComponent>();
147 auto* dc = gameObject.get<helios::engine::modules::physics::motion::components::DirectionComponent>();
149 auto dir = helios::math::vec2f{
153 auto* sc = gameObject.get<helios::engine::modules::physics::motion::components::SteeringComponent>();
155 sc->setTargetRotationAngle(helios::math::degrees(std::atan2(dir[1], dir[0])));
156 sc->setCurrentRotationAngle(helios::math::degrees(std::atan2(dir[1], dir[0])));
182 helios::engine::ecs::GameObject gameObject,
183 const SpawnPlanCursor& cursor,
184 const SpawnContext& spawnContext,
185 const helios::math::vec3f target,
186 const DirectionType directionType = DirectionType::Axis
190 auto* mc = gameObject.get<helios::engine::modules::physics::motion::components::Move2DComponent>();
191 auto* sc = gameObject.get<helios::engine::modules::physics::motion::components::SteeringComponent>();
192 auto* dc = gameObject.get<helios::engine::modules::physics::motion::components::DirectionComponent>();
195 if (directionType == DirectionType::Axis) {
197 } else if (directionType == DirectionType::Point) {
198 auto* tsc = gameObject.get<helios::engine::modules::spatial::transform::components::TranslationStateComponent>();
206 sc->setTargetRotationAngle(helios::math::degrees(std::atan2(direction[1], direction[0])));
207 sc->setCurrentRotationAngle(helios::math::degrees(std::atan2(direction[1], direction[0])));
209 mc->move(direction, 1.0f);
220 explicit MoveInitializer(const DirectionType direction) : directionType_(direction) {}
230 explicit MoveInitializer(const helios::math::vec3f directionAxis) : directionType_(DirectionType::Axis), direction_(directionAxis) {}
242 explicit MoveInitializer(const helios::math::vec3f target, const DirectionType direction) : directionType_(direction), direction_(target) {}
255 void initialize(
256 helios::engine::ecs::GameObject gameObject,
257 const SpawnPlanCursor& cursor,
258 const SpawnContext& spawnContext
262 case DirectionType::Random:
265 case DirectionType::Right:
266 alignTo(gameObject, cursor, spawnContext, helios::math::X_AXISf);
268 case DirectionType::Left:
269 alignTo(gameObject, cursor, spawnContext, helios::math::X_AXISf * -1.0f);
271 case DirectionType::Axis:
275 case DirectionType::Point:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.