15 : _registry(registry), _roomSystem(roomSystem), _networkSync(networkSync)
24 if (!transformRes || !typeRes || !netRes) {
28 auto &transforms = transformRes->get();
29 auto &types = typeRes->get();
30 auto &nets = netRes->get();
31 if (!transforms.has(entity) || !types.has(entity) || !nets.has(entity)) {
35 const auto &transform = transforms[entity];
36 const auto &type = types[entity];
37 const auto &
net = nets[entity];
45 const auto players = room->getPlayers();
46 if (players.empty()) {
54 payload.type =
static_cast<uint8_t
>(type.type);
55 payload.position = transform.position;
58 for (
const auto& player : players) {
72 if (!transformsRes || !typesRes || !roomsRes) {
76 auto &transforms = transformsRes->get();
77 auto &types = typesRes->get();
78 auto &rooms = roomsRes->get();
80 std::vector<std::pair<ecs::Entity, uint32_t>> pending;
82 for (
auto entity : types.entities()) {
83 if (!types.has(entity)) {
86 const auto etype = types[entity].
type;
98 if (!transforms.has(entity) || !rooms.has(entity)) {
102 const auto &tf = transforms[entity];
103 if (tf.position.x <
_minX || tf.position.x >
_maxX) {
104 pending.emplace_back(entity, rooms[entity].
id);
108 for (
const auto& [entity, roomId] : pending) {
Represents an entity in the ECS (Entity-Component-System) architecture.
auto get(this const Self &self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >
Network packet with header and serializable body.
float _minX
Left boundary for bullet despawn.
void despawn(const ecs::Entity &entity, uint32_t roomId)
Despawn an entity and notify players in the room.
RoomSystem & _roomSystem
Reference to the RoomSystem.
BulletCleanupSystem(ecs::Registry ®istry, RoomSystem &roomSystem, NetworkSyncSystem &networkSync)
Constructor for BulletCleanupSystem.
void update(float dt) override
Update system logic for one frame.
float _maxX
Right boundary for bullet despawn.
NetworkSyncSystem & _networkSync
Reference to the NetworkSyncSystem.
ecs::Registry & _registry
Reference to the ECS registry.
System to handle network-related operations on the server side.
void sendPacketToSession(uint32_t sessionId, const net::Packet &packet, net::NetworkMode mode)
Send a packet to a specific session.
System to handle room-related operations on the server side.
std::shared_ptr< Room > getRoom(uint32_t roomId)
Get a room by its ID.
File : Network.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue.hajjar-llauquen@epit...
@ EntityDeath
Entity death notification.
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
rtp::net::EntityType type
Component representing a network identifier for an entity.
Component representing a network identifier for an entity.
Entity death notification data.
uint32_t netId
Network entity identifier.