Skip to content

Struct Engine::ColliderComponent

ClassList > Engine > ColliderComponent

2D Axis-aligned bounding box collider integrated with Raylib Rectangle. More...

  • #include <ColliderComponent.hpp>

Public Attributes

Type Name
bool enabled = true
When false, skipped by CollisionSystem .
bool isStatic = false
When true, this collider does not move during resolution (acts like a wall/floor).
bool isTrigger = false
When true, reports trigger events without solid blocking.
int layer = [**CollisionLayers::kDefaultLayer**](namespaceEngine_1_1CollisionLayers.md#variable-kdefaultlayer)
Layer this collider belongs to, in [0, CollisionLayers::kLayerCount ).
std::uint32_t mask = [**CollisionLayers::kAllLayers**](namespaceEngine_1_1CollisionLayers.md#variable-kalllayers)
Bitmask of the layers this collider is willing to touch. Defaults to CollisionLayers::kAllLayers .
std::optional< ShapeComponent > shape
Optional as the entity already has a shape, if a shape is defined in the collider, the one in the collider takes preference to designate the area.

Public Functions

Type Name
bool Accepts (const ColliderComponent & other) const
True when other's layer is in this collider'smask .

Public Static Functions

Type Name
bool CanCollide (const ColliderComponent & a, const ColliderComponent & b)
The pair filter used by CollisionSystem: both sides must accept each other, so a single restrictive mask skips the whole pair (detection, resolution and enter/stay/exit events).
ColliderComponent Create (const bool enabled=true, const bool isTrigger=false)
Creates a collider with explicit dimensions and offsets.
ColliderComponent Create (const std::optional< ShapeComponent > & shape, const bool enabled=true, const bool isTrigger=false)
Creates a collider directly from a Raylib Rectangle (x = offsetX, y = offsetY).

Detailed Description

Two colliders only interact when each one's mask contains the other's layer, so either side can restrict what it touches (see CollisionLayers). With the defaults every collider touches every other, which is the behaviour scenes saved before layers existed keep having.

Public Attributes Documentation

variable enabled

When false, skipped by CollisionSystem .

bool Engine::ColliderComponent::enabled;


variable isStatic

When true, this collider does not move during resolution (acts like a wall/floor).

bool Engine::ColliderComponent::isStatic;


variable isTrigger

When true, reports trigger events without solid blocking.

bool Engine::ColliderComponent::isTrigger;


variable layer

Layer this collider belongs to, in [0, CollisionLayers::kLayerCount ).

int Engine::ColliderComponent::layer;


variable mask

Bitmask of the layers this collider is willing to touch. Defaults to CollisionLayers::kAllLayers .

std::uint32_t Engine::ColliderComponent::mask;


variable shape

Optional as the entity already has a shape, if a shape is defined in the collider, the one in the collider takes preference to designate the area.

std::optional<ShapeComponent> Engine::ColliderComponent::shape;


Public Functions Documentation

function Accepts

True when other's layer is in this collider'smask .

inline bool Engine::ColliderComponent::Accepts (
    const ColliderComponent & other
) const


Public Static Functions Documentation

function CanCollide

The pair filter used by CollisionSystem: both sides must accept each other, so a single restrictive mask skips the whole pair (detection, resolution and enter/stay/exit events).

static inline bool Engine::ColliderComponent::CanCollide (
    const ColliderComponent & a,
    const ColliderComponent & b
) 


function Create [½]

Creates a collider with explicit dimensions and offsets.

static inline ColliderComponent Engine::ColliderComponent::Create (
    const bool enabled=true,
    const bool isTrigger=false
) 


function Create [2/2]

Creates a collider directly from a Raylib Rectangle (x = offsetX, y = offsetY).

static inline ColliderComponent Engine::ColliderComponent::Create (
    const std::optional< ShapeComponent > & shape,
    const bool enabled=true,
    const bool isTrigger=false
) 



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