Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
PlayerShootSystem.hpp
Go to the documentation of this file.
1
8#ifndef RTYPE_PLAYER_SHOOT_SYSTEM_HPP_
9 #define RTYPE_PLAYER_SHOOT_SYSTEM_HPP_
10
11 #include "RType/ECS/ISystem.hpp"
12 #include "RType/ECS/Registry.hpp"
13
25
26 #include "Systems/RoomSystem.hpp"
27 #include "Systems/NetworkSyncSystem.hpp"
28
29 #include <unordered_map>
30
35namespace rtp::server {
41 public:
49 RoomSystem& roomSystem,
50 NetworkSyncSystem& networkSync);
51
56 void update(float dt) override;
57
58 private:
65 void spawnBullet(ecs::Entity owner,
67 const ecs::components::RoomId& roomId,
68 bool doubleFire = false);
69
79 const ecs::components::RoomId& roomId,
80 float chargeRatio,
81 bool doubleFire = false);
82
88 void sendAmmoUpdate(uint32_t netId, const ecs::components::Ammo& ammo);
89
96 void spawnDebugPowerup(const Vec2f& position, uint32_t roomId, int dropRoll);
97
98 private:
103 float _bulletSpeed = 500.0f;
104 float _chargedBulletSpeed = 280.0f;
105 float _spawnOffsetX = 20.0f;
107 // Beam tick timers per-owner (accumulator for periodic damage ticks)
108 std::unordered_map<uint32_t, float> _beamTickTimers;
109 };
110}
111
112#endif /* !RTYPE_PLAYER_SHOOT_SYSTEM_HPP_ */
Interface for ECS systems.
Represents an entity in the ECS (Entity-Component-System) architecture.
Definition Entity.hpp:63
Abstract base class for all ECS systems.
Definition ISystem.hpp:57
System to handle network-related operations on the server side.
Spawns bullets from player input on the server.
ecs::Registry & _registry
Reference to the entity registry.
float _bulletSpeed
Speed of the spawned bullets.
void sendAmmoUpdate(uint32_t netId, const ecs::components::Ammo &ammo)
Send an ammo update to the client for a specific network ID.
float _chargedBulletSpeed
Speed of the charged bullets.
void spawnDebugPowerup(const Vec2f &position, uint32_t roomId, int dropRoll)
Spawn a debug powerup for testing (triggered by P key)
RoomSystem & _roomSystem
Reference to the RoomSystem.
NetworkSyncSystem & _networkSync
Reference to the NetworkSyncSystem.
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.
std::unordered_map< uint32_t, float > _beamTickTimers
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 update(float dt) override
Update player shoot system logic for one frame.
float _spawnOffsetX
X offset for bullet spawn position.
System to handle room-related operations on the server side.
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
Ammo tracking for weapons.
Definition Ammo.hpp:18
Component representing a network identifier for an entity.
Definition RoomId.hpp:22
Component representing position, rotation, and scale of an entity.
Definition Transform.hpp:23