Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::server::CollisionSystem Class Reference

#include <CollisionSystem.hpp>

Inheritance diagram for rtp::server::CollisionSystem:
Collaboration diagram for rtp::server::CollisionSystem:

Public Member Functions

 CollisionSystem (ecs::Registry &registry, RoomSystem &roomSystem, NetworkSyncSystem &networkSync)
 Constructor for CollisionSystem.
 
void update (float dt) override
 Update system logic for one frame.
 
void setInvincible (bool enabled)
 Set invincibility mode for all players.
 
bool isInvincible () const
 Check if invincibility mode is enabled.
 
- Public Member Functions inherited from rtp::ecs::ISystem
virtual ~ISystem () noexcept=default
 

Private Member Functions

bool overlaps (const ecs::components::Transform &a, const ecs::components::BoundingBox &ab, const ecs::components::Transform &b, const ecs::components::BoundingBox &bb) const
 Check if two entities overlap based on their transforms and bounding boxes.
 
void despawn (const ecs::Entity &entity, uint32_t roomId)
 Handle collision between two entities.
 
void spawnPowerup (const Vec2f &position, uint32_t roomId, int dropRoll)
 Spawn a power-up at given position.
 

Private Attributes

ecs::Registry_registry
 Reference to the ECS registry.
 
RoomSystem_roomSystem
 Reference to the RoomSystem.
 
NetworkSyncSystem_networkSync
 Reference to the NetworkSyncSystem.
 
bool _invincibleMode = false
 Debug: players are invincible.
 

Detailed Description

Definition at line 34 of file CollisionSystem.hpp.

Constructor & Destructor Documentation

◆ CollisionSystem()

rtp::server::CollisionSystem::CollisionSystem ( ecs::Registry registry,
RoomSystem roomSystem,
NetworkSyncSystem networkSync 
)

Constructor for CollisionSystem.

Parameters
registryReference to the ECS registry
roomSystemReference to the RoomSystem
networkSyncReference to the NetworkSyncSystem

Definition at line 40 of file CollisionSystem.cpp.

Member Function Documentation

◆ despawn()

void rtp::server::CollisionSystem::despawn ( const ecs::Entity entity,
uint32_t  roomId 
)
private

Handle collision between two entities.

Parameters
entityAFirst entity involved in the collision
entityBSecond entity involved in the collision

Definition at line 640 of file CollisionSystem.cpp.

References _networkSync, _registry, _roomSystem, rtp::log::debug(), rtp::net::EntityDeath, rtp::ecs::Registry::get(), rtp::server::RoomSystem::getRoom(), rtp::ecs::Entity::index(), rtp::ecs::Registry::kill(), rtp::net::EntityDeathPayload::netId, rtp::server::NetworkSyncSystem::sendPacketToSession(), and rtp::net::TCP.

Referenced by update().

◆ isInvincible()

bool rtp::server::CollisionSystem::isInvincible ( ) const
inline

Check if invincibility mode is enabled.

Returns
true if invincibility is enabled

Definition at line 62 of file CollisionSystem.hpp.

References _invincibleMode.

◆ overlaps()

bool rtp::server::CollisionSystem::overlaps ( const ecs::components::Transform a,
const ecs::components::BoundingBox ab,
const ecs::components::Transform b,
const ecs::components::BoundingBox bb 
) const
private

Check if two entities overlap based on their transforms and bounding boxes.

Parameters
aTransform of the first entity
abBoundingBox of the first entity
bTransform of the second entity
bbBoundingBox of the second entity
Returns
true if the entities overlap, false otherwise

Definition at line 622 of file CollisionSystem.cpp.

References rtp::ecs::components::BoundingBox::height, rtp::ecs::components::Transform::position, rtp::ecs::components::BoundingBox::width, rtp::Vec2< T >::x, and rtp::Vec2< T >::y.

Referenced by update().

◆ setInvincible()

void rtp::server::CollisionSystem::setInvincible ( bool  enabled)
inline

Set invincibility mode for all players.

Parameters
enabledWhether invincibility is enabled

Definition at line 56 of file CollisionSystem.hpp.

References _invincibleMode.

◆ spawnPowerup()

void rtp::server::CollisionSystem::spawnPowerup ( const Vec2f position,
uint32_t  roomId,
int  dropRoll 
)
private

◆ update()

Member Data Documentation

◆ _invincibleMode

bool rtp::server::CollisionSystem::_invincibleMode = false
private

Debug: players are invincible.

Definition at line 97 of file CollisionSystem.hpp.

Referenced by isInvincible(), setInvincible(), and update().

◆ _networkSync

NetworkSyncSystem& rtp::server::CollisionSystem::_networkSync
private

Reference to the NetworkSyncSystem.

Definition at line 96 of file CollisionSystem.hpp.

Referenced by despawn(), spawnPowerup(), and update().

◆ _registry

ecs::Registry& rtp::server::CollisionSystem::_registry
private

Reference to the ECS registry.

Definition at line 94 of file CollisionSystem.hpp.

Referenced by despawn(), spawnPowerup(), and update().

◆ _roomSystem

RoomSystem& rtp::server::CollisionSystem::_roomSystem
private

Reference to the RoomSystem.

Definition at line 95 of file CollisionSystem.hpp.

Referenced by despawn(), spawnPowerup(), and update().


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