|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Base class for systems that operate on entities in the ECS. More...
#include <EntitySystem.hpp>
Public Member Functions | |
| EntitySystem (ecs::Registry ®istry, ServerNetwork &network, NetworkSyncSystem &networkSync) | |
| Constructor for EntitySystem. | |
| void | update (float dt) override |
| Update movement system logic for one frame. | |
| ecs::Entity | createPlayerEntity (PlayerPtr player) |
| Create a new player entity in the ECS. | |
| ecs::Entity | createPlayerEntity (PlayerPtr player, const Vec2f &spawnPos) |
| ecs::Entity | createEnemyEntity (uint32_t roomId, const Vec2f &pos, ecs::components::Patterns pattern, float speed, float amplitude, float frequency, net::EntityType type=net::EntityType::Scout) |
| Create a new enemy entity in the ECS. | |
| ecs::Entity | creaetEnemyEntity (uint32_t roomId, const Vec2f &pos, ecs::components::Patterns pattern, float speed, float amplitude, float frequency) |
| Create a new enemy entity in the ECS with default type Scout. | |
| ecs::Entity | createPowerupEntity (uint32_t roomId, const Vec2f &pos, ecs::components::PowerupType type, float value, float duration) |
| Create a new powerup entity in the ECS. | |
| ecs::Entity | createObstacleEntity (uint32_t roomId, const Vec2f &pos, const Vec2f &size, int health, net::EntityType type=net::EntityType::Obstacle) |
| Create a new obstacle entity in the ECS. | |
| void | applyWeaponToEntity (ecs::Entity entity, ecs::components::WeaponKind weaponKind) |
| Apply a weapon configuration to an existing entity (player) | |
Public Member Functions inherited from rtp::ecs::ISystem | |
| virtual | ~ISystem () noexcept=default |
Protected Attributes | |
| ecs::Registry & | _registry |
| Reference to the entity registry. | |
| ServerNetwork & | _network |
| Reference to the server network manager. | |
| NetworkSyncSystem & | _networkSync |
| Reference to the network sync system. | |
Base class for systems that operate on entities in the ECS.
Definition at line 44 of file EntitySystem.hpp.
| rtp::server::EntitySystem::EntitySystem | ( | ecs::Registry & | registry, |
| ServerNetwork & | network, | ||
| NetworkSyncSystem & | networkSync | ||
| ) |
Constructor for EntitySystem.
| registry | Reference to the entity registry |
Definition at line 18 of file EntitySystem.cpp.
| void rtp::server::EntitySystem::applyWeaponToEntity | ( | ecs::Entity | entity, |
| ecs::components::WeaponKind | weaponKind | ||
| ) |
Apply a weapon configuration to an existing entity (player)
| entity | Target entity |
| weaponKind | Weapon kind to apply |
Definition at line 125 of file EntitySystem.cpp.
References _registry, rtp::ecs::Registry::add(), rtp::ecs::components::SimpleWeapon::ammo, rtp::ecs::components::Beam, rtp::ecs::components::SimpleWeapon::beamCooldown, rtp::ecs::Registry::get(), rtp::config::getWeaponDef(), rtp::config::hasWeaponConfigs(), rtp::ecs::Entity::index(), rtp::log::info(), rtp::ecs::components::SimpleWeapon::kind, rtp::ecs::components::Ammo::max, rtp::ecs::components::SimpleWeapon::maxAmmo, and rtp::log::warning().
| ecs::Entity rtp::server::EntitySystem::creaetEnemyEntity | ( | uint32_t | roomId, |
| const Vec2f & | pos, | ||
| ecs::components::Patterns | pattern, | ||
| float | speed, | ||
| float | amplitude, | ||
| float | frequency | ||
| ) |
Create a new enemy entity in the ECS with default type Scout.
| roomId | ID of the room the enemy belongs to |
| pos | Position to spawn the enemy at |
| pattern | Movement pattern for the enemy |
| speed | Movement speed of the enemy |
| amplitude | Amplitude for movement patterns that require it |
| frequency | Frequency for movement patterns that require it |
Definition at line 268 of file EntitySystem.cpp.
References createEnemyEntity(), and rtp::net::Scout.
| ecs::Entity rtp::server::EntitySystem::createEnemyEntity | ( | uint32_t | roomId, |
| const Vec2f & | pos, | ||
| ecs::components::Patterns | pattern, | ||
| float | speed, | ||
| float | amplitude, | ||
| float | frequency, | ||
| net::EntityType | type = net::EntityType::Scout |
||
| ) |
Create a new enemy entity in the ECS.
Definition at line 167 of file EntitySystem.cpp.
References _registry, rtp::ecs::Registry::add(), rtp::net::Boss, rtp::net::Boss2, rtp::net::BossShield, rtp::ecs::components::Classic, rtp::ecs::components::SimpleWeapon::damage, rtp::log::error(), rtp::ecs::components::SimpleWeapon::fireRate, rtp::ecs::Entity::index(), rtp::ecs::components::SimpleWeapon::isBoomerang, rtp::ecs::components::SimpleWeapon::kind, rtp::ecs::components::SimpleWeapon::lastShotTime, rtp::ecs::Registry::spawn(), rtp::net::Tank, rtp::Vec2< T >::x, and rtp::Vec2< T >::y.
Referenced by creaetEnemyEntity(), and rtp::server::LevelSystem::update().
| ecs::Entity rtp::server::EntitySystem::createObstacleEntity | ( | uint32_t | roomId, |
| const Vec2f & | pos, | ||
| const Vec2f & | size, | ||
| int | health, | ||
| net::EntityType | type = net::EntityType::Obstacle |
||
| ) |
Create a new obstacle entity in the ECS.
| roomId | ID of the room the obstacle belongs to |
| pos | Position to spawn the obstacle at |
| size | Size of the obstacle |
| health | Health points of the obstacle |
| type | Type of the obstacle entity |
Definition at line 323 of file EntitySystem.cpp.
References _registry, rtp::ecs::Registry::add(), rtp::log::error(), rtp::ecs::Entity::index(), rtp::ecs::Registry::spawn(), rtp::Vec2< T >::x, and rtp::Vec2< T >::y.
Referenced by rtp::server::LevelSystem::update().
| ecs::Entity rtp::server::EntitySystem::createPlayerEntity | ( | PlayerPtr | player | ) |
Create a new player entity in the ECS.
Definition at line 32 of file EntitySystem.cpp.
References createPlayerEntity().
Referenced by createPlayerEntity().
| ecs::Entity rtp::server::EntitySystem::createPlayerEntity | ( | PlayerPtr | player, |
| const Vec2f & | spawnPos | ||
| ) |
Definition at line 38 of file EntitySystem.cpp.
References _registry, rtp::ecs::Registry::add(), rtp::ecs::components::Beam, rtp::log::error(), rtp::config::getWeaponDef(), rtp::config::hasWeaponConfigs(), rtp::ecs::components::SimpleWeapon::kind, rtp::ecs::components::Ammo::max, rtp::net::Player, rtp::ecs::Registry::spawn(), rtp::log::warning(), rtp::Vec2< T >::x, and rtp::Vec2< T >::y.
| ecs::Entity rtp::server::EntitySystem::createPowerupEntity | ( | uint32_t | roomId, |
| const Vec2f & | pos, | ||
| ecs::components::PowerupType | type, | ||
| float | value, | ||
| float | duration | ||
| ) |
Create a new powerup entity in the ECS.
| roomId | ID of the room the powerup belongs to |
| pos | Position to spawn the powerup at |
| type | Type of the powerup |
| value | Value associated with the powerup |
| duration | Duration the powerup effect lasts |
Definition at line 277 of file EntitySystem.cpp.
References _registry, rtp::ecs::Registry::add(), rtp::log::error(), rtp::ecs::Entity::index(), rtp::net::PowerupHeal, rtp::net::PowerupSpeed, rtp::ecs::Registry::spawn(), rtp::ecs::components::Speed, rtp::Vec2< T >::x, and rtp::Vec2< T >::y.
Referenced by rtp::server::LevelSystem::update().
|
overridevirtual |
Update movement system logic for one frame.
| dt | Time elapsed since last update in seconds |
Implements rtp::ecs::ISystem.
Definition at line 27 of file EntitySystem.cpp.
|
protected |
Reference to the server network manager.
Definition at line 141 of file EntitySystem.hpp.
|
protected |
Reference to the network sync system.
Definition at line 142 of file EntitySystem.hpp.
|
protected |
Reference to the entity registry.
Definition at line 140 of file EntitySystem.hpp.
Referenced by applyWeaponToEntity(), createEnemyEntity(), createObstacleEntity(), createPlayerEntity(), and createPowerupEntity().