r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
ProjectileManager.cpp
Go to the documentation of this file.
1///
2/// @file ProjectileManager.cpp
3/// @brief Implementation of ProjectileManager
4/// @namespace cli
5///
6
8#include "Client/Common.hpp"
9#include "ECS/Registry.hpp"
10
11namespace cli
12{
13 ecs::Entity ProjectileManager::createBasicProjectile(ecs::Registry &registry, float x, float y, float velocityX,
14 float velocityY)
15 {
16 return createProjectile(registry, ecs::Projectile::BASIC, x, y, velocityX, velocityY);
17 }
18
20 float velocityX, float velocityY)
21 {
22 return createProjectile(registry, ecs::Projectile::SUPERCHARGED, x, y, velocityX, velocityY);
23 }
24
26 float y, float velocityX, float velocityY)
27 {
28 using namespace GameConfig::Projectile;
29
30 if (type == ecs::Projectile::BASIC)
31 {
32 return registry.createEntity()
33 .with<ecs::Transform>("projectile_transform", x, y, 0.F)
34 .with<ecs::Velocity>("projectile_velocity", velocityX, velocityY)
35 .with<ecs::Rect>("projectile_rect", 0.F, 0.F, static_cast<int>(Basic::SPRITE_WIDTH),
36 static_cast<int>(Basic::SPRITE_HEIGHT))
37 .with<ecs::Scale>("projectile_scale", Basic::SCALE, Basic::SCALE)
38 .with<ecs::Texture>("projectile_texture", Path::Texture::TEXTURE_SHOOT)
39 .with<ecs::Projectile>("projectile", type, Basic::DAMAGE, Basic::LIFETIME, 0.0f)
41 .build();
42 }
43 else
44 {
45 return registry.createEntity()
46 .with<ecs::Transform>("projectile_transform", x, y, 0.F)
47 .with<ecs::Velocity>("projectile_velocity", velocityX, velocityY)
48 .with<ecs::Rect>("projectile_rect", 0.F, 0.F, static_cast<int>(Supercharged::SPRITE_WIDTH),
49 static_cast<int>(Supercharged::SPRITE_HEIGHT))
50 .with<ecs::Scale>("projectile_scale", Supercharged::SCALE, Supercharged::SCALE)
51 .with<ecs::Texture>("projectile_texture", Path::Texture::TEXTURE_SHOOT_CHARGED)
52 .with<ecs::Projectile>("projectile", type, Supercharged::DAMAGE, Supercharged::LIFETIME, 0.0f)
53 .with<ecs::Animation>("projectile_animation", 0, Supercharged::ANIMATION_FRAMES,
54 Supercharged::ANIMATION_DURATION, 0.0f,
55 static_cast<int>(Supercharged::SPRITE_WIDTH),
56 static_cast<int>(Supercharged::SPRITE_HEIGHT), Supercharged::ANIMATION_FRAMES)
57 .with<ecs::Hitbox>("projectile_hitbox", GameConfig::Hitbox::PROJECTILE_SUPERCHARGED_RADIUS)
58 .build();
59 }
60 }
61} // namespace cli
Manages projectile creation and configuration.
This file contains the Registry class declaration.
static ecs::Entity createBasicProjectile(ecs::Registry &registry, float x, float y, float velocityX, float velocityY)
Create a basic projectile.
static ecs::Entity createSuperchargedProjectile(ecs::Registry &registry, float x, float y, float velocityX, float velocityY)
Create a supercharged projectile.
static ecs::Entity createProjectile(ecs::Registry &registry, ecs::Projectile::Type type, float x, float y, float velocityX, float velocityY)
Create a projectile with given parameters.
EntityBuilder & with(Args &&...args)
Definition Registry.hpp:40
Class for managing entities and their components.
Definition Registry.hpp:25
EntityBuilder createEntity()
Definition Registry.hpp:53
This file contains common definitions and constants.
constexpr float PROJECTILE_BASIC_RADIUS
constexpr float PROJECTILE_SUPERCHARGED_RADIUS
constexpr auto TEXTURE_SHOOT_CHARGED
Definition Common.hpp:65
constexpr auto TEXTURE_SHOOT
Definition Common.hpp:64
std::uint32_t Entity
Definition Entity.hpp:13