LevelBoundsBehaviorSystem.ixx File
System for handling entity behavior at level boundaries. More...
Included Headers
#include <cassert>
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.engine.runtime.spawn.commands.DespawnCommand>
#include <helios.engine.ecs.View>
#include <helios.engine.modules.scene.components.SceneNodeComponent>
#include <helios.engine.modules.spatial.transform.components.RotationStateComponent>
#include <helios.engine.modules.rendering.model.components.ModelAabbComponent>
#include <helios.engine.mechanics.spawn.components.SpawnedByProfileComponent>
#include <helios.engine.modules.physics.collision.components.AabbColliderComponent>
#include <helios.engine.ecs.System>
#include <helios.math>
#include <helios.engine.runtime.messaging.command.CommandBuffer>
#include <helios.engine.mechanics.lifecycle.components.Active>
#include <helios.engine.modules.physics.collision.types.CollisionBehavior>
#include <helios.engine.modules.physics.motion.components.Move2DComponent>
#include <helios.engine.modules.physics.motion.components.DirectionComponent>
#include <helios.engine.modules.physics.collision.types.CollisionResponse>
#include <helios.engine.ecs.GameObject>
#include <helios.engine.runtime.world.GameWorld>
#include <helios.scene.SceneNode>
#include <helios.engine.modules.spatial.transform.components.ComposeTransformComponent>
#include <helios.engine.modules.spatial.transform.components.TranslationStateComponent>
#include <helios.engine.modules.physics.motion.components.SteeringComponent>
#include <helios.engine.mechanics.bounds.components.LevelBoundsBehaviorComponent>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | mechanics |
|
High-level gameplay systems and components for game logic. More... | |
| namespace | bounds |
| namespace | systems |
|
Boundary detection and response systems. More... | |
Classes Index
| class | LevelBoundsBehaviorSystem |
|
System that handles entity behavior when colliding with level boundaries. More... | |
| struct | BounceResult |
|
Result of a bounce calculation against level bounds. More... | |
Description
System for handling entity behavior at level boundaries.
File Listing
The file content with the documentation metadata removed is:
46export namespace helios::engine::mechanics::bounds::systems {
56 class LevelBoundsBehaviorSystem : public helios::engine::ecs::System {
67 helios::math::vec3f translation;
69 helios::math::vec3f velocity;
71 helios::math::vec3f direction;
85 void update(helios::engine::runtime::world::UpdateContext& updateContext) noexcept override {
87 using namespace helios::engine::modules::physics::collision::types;
89 for (auto [entity, m2d, ab, sc, dc, tsc, bc, bbc, active] : gameWorld_->view<
102 auto levelBounds = gameWorld_->level()->bounds();
106 helios::math::mat4f parentWorldTransform = sc->sceneNode()->parent()->worldTransform();
107 helios::math::vec4f childWorldTranslation = parentWorldTransform * tsc->translation().toVec4(1.0f);
109 helios::math::vec3f bouncedWorldTranslation;
113 if (bbc->collisionBehavior() == CollisionBehavior::Reflect || bbc->collisionBehavior() == CollisionBehavior::Bounce) {
116 childWorldTranslation.toVec3(), objectBounds, levelBounds,
117 bbc->collisionBehavior() == CollisionBehavior::Reflect ? 1.0f : bbc->restitution(),
124 } else if (bbc->collisionBehavior() == CollisionBehavior::Despawn) {
128 auto* sbp = entity.get<helios::engine::mechanics::spawn::components::SpawnedByProfileComponent>();
131 updateContext.commandBuffer().add<helios::engine::runtime::spawn::commands::DespawnCommand>(
143 auto parentTransform_inverse = parentWorldTransform.inverse();
144 auto childLocalTranslation = parentTransform_inverse * bouncedWorldTranslation.toVec4(1.0f);
148 parentWorldTransform.withTranslation(bouncedWorldTranslation)
169 helios::engine::ecs::GameObject go,
171 helios::engine::modules::physics::collision::types::CollisionResponse collisionResponse) {
173 if (collisionResponse == helios::engine::modules::physics::collision::types::CollisionResponse::AlignHeadingToDirection) {
174 auto* psc = go.get<helios::engine::modules::physics::motion::components::SteeringComponent>();
205 helios::math::vec3f worldTranslation,
206 helios::math::aabbf objectBounds,
207 helios::math::aabbf levelBounds,
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.