Skip to content

Class Engine::CollisionSystem

ClassList > Engine > CollisionSystem

Detects overlaps between colliders using Raylib and fires enter/stay/exit events. More...

  • #include <CollisionSystem.hpp>

Inherits the following classes: Engine::System

Public Types

Type Name
typedef std::pair< Entity, Entity > EntityPair

Public Attributes inherited from Engine::System

See Engine::System

Type Name
std::set< Entity > m_Entities

Public Functions

Type Name
const std::set< EntityPair > & GetActiveContacts () noexcept const
Returns a const reference to all active contact pairs this frame.
virtual void OnSceneUnloaded (Registry & registry) override
Forgets all contacts. Entity IDs restart after a switch, so an old pair would otherwise send stay/exit events to unrelated new entities. No exit events are fired: the entities are being destroyed anyway.
virtual void Update (Registry & registry, float dt) override
Runs overlap detection and updates contact state for this frame.
~CollisionSystem () noexcept override

Public Functions inherited from Engine::System

See Engine::System

Type Name
virtual void OnSceneUnloaded (Registry & registry)
Called right before the current scene's entities are destroyed.
virtual void Render (Registry & registry)
World pass: drawn inside the active camera.
virtual void RenderScreen (Registry & registry)
Screen pass: drawn after the world, in window pixels.
virtual void Update (Registry & registry, float dt)
virtual ~System () = default

Detailed Description

Pairs are filtered by ColliderComponent::CanCollide before detection, so a restrictive layer mask silences resolution and events for that pair too.

Public Types Documentation

typedef EntityPair

using Engine::CollisionSystem::EntityPair =  std::pair<Entity, Entity>;

Public Functions Documentation

function GetActiveContacts

Returns a const reference to all active contact pairs this frame.

inline const std::set< EntityPair > & Engine::CollisionSystem::GetActiveContacts () noexcept const


function OnSceneUnloaded

Forgets all contacts. Entity IDs restart after a switch, so an old pair would otherwise send stay/exit events to unrelated new entities. No exit events are fired: the entities are being destroyed anyway.

inline virtual void Engine::CollisionSystem::OnSceneUnloaded (
    Registry & registry
) override

Implements Engine::System::OnSceneUnloaded


function Update

Runs overlap detection and updates contact state for this frame.

virtual void Engine::CollisionSystem::Update (
    Registry & registry,
    float dt
) override

Parameters:

  • registry ECS registry with positions and colliders.
  • dt Delta time.

Implements Engine::System::Update


function ~CollisionSystem

Engine::CollisionSystem::~CollisionSystem () noexcept override


The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Systems/CollisionSystem.hpp