Skip to main content

CollisionStateResponseSystem Class

System that processes collision states and executes configured behaviors. More...

Declaration

class helios::engine::modules::physics::collision::systems::CollisionStateResponseSystem { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions Index

voidupdate (helios::engine::runtime::world::UpdateContext &updateContext) noexcept

Processes collision states and issues response commands. More...

Description

System that processes collision states and executes configured behaviors.

This system reads the CollisionStateComponent of each entity to determine how to respond to detected collisions. Based on the configured CollisionBehavior, the system issues appropriate commands (e.g., DespawnCommand for entities marked with Despawn behavior).

The system requires entities to have both a CollisionStateComponent (for collision data) and a SpawnedByProfileComponent.

Supported behaviors:

  • **Despawn:** Issues a DespawnCommand to return the entity to its object pool.

This system should run after collision detection but before collision state clearing.

Definition at line 61 of file CollisionStateResponseSystem.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::modules::physics::collision::systems::CollisionStateResponseSystem::EngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions

update()

void helios::engine::modules::physics::collision::systems::CollisionStateResponseSystem::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Processes collision states and issues response commands.

Iterates over all entities with CollisionStateComponent and PoolIdComponent. For entities with active collisions, reads the collision behavior and issues appropriate commands and/or events.

Parameters
updateContext

Context providing access to the command buffer and world.

Definition at line 76 of file CollisionStateResponseSystem.ixx.

77
78 for (auto [entity, csc, sbp, active] : updateContext.view<
82 >().whereEnabled()) {
83
84 if (!csc->hasCollision()) {
85 continue;
86 }
87
88 CollisionBehavior collisionBehavior = csc->collisionBehavior();
89
90 if (hasFlag(collisionBehavior, CollisionBehavior::PassEvent)) {
91
92 if (csc->isTrigger()) {
93 updateContext.pushPass<events::TriggerCollisionEvent>(
94 entity.entityHandle(),
95 csc->collisionContext()
96 );
97 }
98
99 if (csc->isSolid()) {
100 updateContext.pushPass<events::SolidCollisionEvent>(
101 entity.entityHandle(),
102 csc->collisionContext()
103 );
104 }
105 }
106
107
108 if (hasFlag(collisionBehavior, CollisionBehavior::Despawn)) {
109 updateContext.queueCommand<DespawnCommand>(
110 entity.entityHandle(), sbp->spawnProfileId());
111 }
112 }
113
114 }

References helios::engine::modules::physics::collision::types::Despawn, helios::engine::modules::physics::collision::types::hasFlag and helios::engine::modules::physics::collision::types::PassEvent.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.