|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
#include <CollisionSystem.hpp>
Public Member Functions | |
| CollisionSystem (ecs::Registry ®istry, 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. | |
Definition at line 34 of file CollisionSystem.hpp.
| rtp::server::CollisionSystem::CollisionSystem | ( | ecs::Registry & | registry, |
| RoomSystem & | roomSystem, | ||
| NetworkSyncSystem & | networkSync | ||
| ) |
Constructor for CollisionSystem.
| registry | Reference to the ECS registry |
| roomSystem | Reference to the RoomSystem |
| networkSync | Reference to the NetworkSyncSystem |
Definition at line 40 of file CollisionSystem.cpp.
|
private |
Handle collision between two entities.
| entityA | First entity involved in the collision |
| entityB | Second 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().
|
inline |
Check if invincibility mode is enabled.
Definition at line 62 of file CollisionSystem.hpp.
References _invincibleMode.
|
private |
Check if two entities overlap based on their transforms and bounding boxes.
| a | Transform of the first entity |
| ab | BoundingBox of the first entity |
| b | Transform of the second entity |
| bb | BoundingBox of the second entity |
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().
|
inline |
Set invincibility mode for all players.
| enabled | Whether invincibility is enabled |
Definition at line 56 of file CollisionSystem.hpp.
References _invincibleMode.
|
private |
Spawn a power-up at given position.
| position | Position to spawn the power-up |
| roomId | Room ID |
| dropRoll | Random value to determine power-up type |
Definition at line 695 of file CollisionSystem.cpp.
References _networkSync, _registry, _roomSystem, rtp::ecs::Registry::add(), rtp::ecs::components::DoubleFire, rtp::net::EntitySpawn, rtp::log::error(), rtp::server::RoomSystem::getRoom(), rtp::ecs::components::Heal, rtp::log::info(), rtp::net::EntitySpawnPayload::netId, rtp::net::PowerupDoubleFire, rtp::net::PowerupHeal, rtp::net::PowerupShield, rtp::server::NetworkSyncSystem::sendPacketToSession(), rtp::ecs::components::Shield, rtp::ecs::Registry::spawn(), rtp::net::TCP, rtp::Vec2< T >::x, and rtp::Vec2< T >::y.
Referenced by update().
|
overridevirtual |
Update system logic for one frame.
| dt | Time elapsed since last update in seconds |
Implements rtp::ecs::ISystem.
Definition at line 49 of file CollisionSystem.cpp.
References _invincibleMode, _networkSync, _registry, _roomSystem, rtp::ecs::Registry::add(), rtp::net::AmmoUpdate, rtp::net::Boss, rtp::net::Boss2, rtp::net::BossShield, rtp::net::Bullet, rtp::net::ChargedBullet, rtp::net::AmmoUpdatePayload::current, despawn(), rtp::ecs::components::DoubleFire, rtp::net::EnemyBullet, rtp::net::GameOver, rtp::ecs::Registry::get(), rtp::server::RoomSystem::getRoom(), rtp::ecs::components::Heal, rtp::net::HealthUpdate, rtp::ecs::Entity::index(), rtp::log::info(), rtp::server::Room::InGame, rtp::ecs::NullEntity, rtp::net::Obstacle, rtp::net::ObstacleSolid, overlaps(), rtp::net::Player, rtp::net::PowerupDoubleFire, rtp::net::PowerupHeal, rtp::net::PowerupShield, rtp::net::PowerupSpeed, rtp::ecs::Registry::remove(), rtp::net::ScoreUpdate, rtp::net::Scout, rtp::server::NetworkSyncSystem::sendPacketToSession(), rtp::ecs::components::Shield, spawnPowerup(), rtp::server::Room::Spectator, rtp::ecs::components::Speed, rtp::net::Tank, rtp::net::TCP, rtp::server::NetworkSyncSystem::unbindSession(), and rtp::log::warning().
|
private |
Debug: players are invincible.
Definition at line 97 of file CollisionSystem.hpp.
Referenced by isInvincible(), setInvincible(), and update().
|
private |
Reference to the NetworkSyncSystem.
Definition at line 96 of file CollisionSystem.hpp.
Referenced by despawn(), spawnPowerup(), and update().
|
private |
Reference to the ECS registry.
Definition at line 94 of file CollisionSystem.hpp.
Referenced by despawn(), spawnPowerup(), and update().
|
private |
Reference to the RoomSystem.
Definition at line 95 of file CollisionSystem.hpp.
Referenced by despawn(), spawnPowerup(), and update().