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::PlayerShootSystem Class Reference

Spawns bullets from player input on the server. More...

#include <PlayerShootSystem.hpp>

Inheritance diagram for rtp::server::PlayerShootSystem:
Collaboration diagram for rtp::server::PlayerShootSystem:

Public Member Functions

 PlayerShootSystem (ecs::Registry &registry, RoomSystem &roomSystem, NetworkSyncSystem &networkSync)
 Constructor for PlayerShootSystem.
 
void update (float dt) override
 Update player shoot system logic for one frame.
 
- Public Member Functions inherited from rtp::ecs::ISystem
virtual ~ISystem () noexcept=default
 

Private Member Functions

void spawnBullet (ecs::Entity owner, const ecs::components::Transform &tf, const ecs::components::RoomId &roomId, bool doubleFire=false)
 Spawn a bullet entity based on the player's transform and room ID.
 
void spawnChargedBullet (ecs::Entity owner, const ecs::components::Transform &tf, const ecs::components::RoomId &roomId, float chargeRatio, bool doubleFire=false)
 Spawn a charged bullet based on the player's transform and room ID.
 
void sendAmmoUpdate (uint32_t netId, const ecs::components::Ammo &ammo)
 Send an ammo update to the client for a specific network ID.
 
void spawnDebugPowerup (const Vec2f &position, uint32_t roomId, int dropRoll)
 Spawn a debug powerup for testing (triggered by P key)
 

Private Attributes

ecs::Registry_registry
 Reference to the entity registry.
 
RoomSystem_roomSystem
 Reference to the RoomSystem.
 
NetworkSyncSystem_networkSync
 Reference to the NetworkSyncSystem.
 
float _bulletSpeed = 500.0f
 Speed of the spawned bullets.
 
float _chargedBulletSpeed = 280.0f
 Speed of the charged bullets.
 
float _spawnOffsetX = 20.0f
 X offset for bullet spawn position.
 
std::unordered_map< uint32_t, float > _beamTickTimers
 

Detailed Description

Spawns bullets from player input on the server.

Definition at line 40 of file PlayerShootSystem.hpp.

Constructor & Destructor Documentation

◆ PlayerShootSystem()

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

Constructor for PlayerShootSystem.

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

Definition at line 46 of file PlayerShootSystem.cpp.

Member Function Documentation

◆ sendAmmoUpdate()

void rtp::server::PlayerShootSystem::sendAmmoUpdate ( uint32_t  netId,
const ecs::components::Ammo ammo 
)
private

◆ spawnBullet()

◆ spawnChargedBullet()

◆ spawnDebugPowerup()

void rtp::server::PlayerShootSystem::spawnDebugPowerup ( const Vec2f position,
uint32_t  roomId,
int  dropRoll 
)
private

◆ update()

Member Data Documentation

◆ _beamTickTimers

std::unordered_map<uint32_t, float> rtp::server::PlayerShootSystem::_beamTickTimers
private

Definition at line 108 of file PlayerShootSystem.hpp.

Referenced by update().

◆ _bulletSpeed

float rtp::server::PlayerShootSystem::_bulletSpeed = 500.0f
private

Speed of the spawned bullets.

Definition at line 103 of file PlayerShootSystem.hpp.

Referenced by spawnBullet().

◆ _chargedBulletSpeed

float rtp::server::PlayerShootSystem::_chargedBulletSpeed = 280.0f
private

Speed of the charged bullets.

Definition at line 104 of file PlayerShootSystem.hpp.

Referenced by spawnChargedBullet().

◆ _networkSync

NetworkSyncSystem& rtp::server::PlayerShootSystem::_networkSync
private

Reference to the NetworkSyncSystem.

Definition at line 101 of file PlayerShootSystem.hpp.

Referenced by sendAmmoUpdate(), spawnBullet(), spawnChargedBullet(), spawnDebugPowerup(), and update().

◆ _registry

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

Reference to the entity registry.

Definition at line 99 of file PlayerShootSystem.hpp.

Referenced by spawnBullet(), spawnChargedBullet(), spawnDebugPowerup(), and update().

◆ _roomSystem

RoomSystem& rtp::server::PlayerShootSystem::_roomSystem
private

Reference to the RoomSystem.

Definition at line 100 of file PlayerShootSystem.hpp.

Referenced by spawnBullet(), spawnChargedBullet(), spawnDebugPowerup(), and update().

◆ _spawnOffsetX

float rtp::server::PlayerShootSystem::_spawnOffsetX = 20.0f
private

X offset for bullet spawn position.

Definition at line 105 of file PlayerShootSystem.hpp.

Referenced by spawnBullet(), and spawnChargedBullet().


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