15 using namespace GameConfig::Projectile;
16 using namespace GameConfig::Beam;
24 if (playerEntities.empty())
27 auto &[playerEntity, player] = *playerEntities.begin();
30 if (!transform || !beamCharge)
45 beamCharge->current_charge += CHARGE_RATE * dt;
46 if (beamCharge->current_charge > beamCharge->max_charge)
47 beamCharge->current_charge = beamCharge->max_charge;
50 if (beamCharge->current_charge < beamCharge->max_charge)
76 float chargeThreshold = beamCharge->max_charge * 0.5f;
77 if (beamCharge->current_charge >= chargeThreshold)
81 beamCharge->current_charge = 0.0f;
103 using namespace GameConfig::Projectile;
115 using namespace GameConfig::Projectile;
124 using namespace GameConfig::LoadingAnimation;
128 for (
auto &[entity, animation] : loadingEntities)
131 if (loadingTransform)
134 loadingTransform->
x = playerTransform->
x + OFFSET_X;
135 loadingTransform->y = playerTransform->
y + OFFSET_Y;
143 .
with<
ecs::Transform>(
"loading_transform", playerTransform->
x + OFFSET_X, playerTransform->
y + OFFSET_Y,
145 .with<ecs::Rect>(
"loading_rect", 0.0f, 0.0f,
static_cast<int>(SPRITE_WIDTH),
146 static_cast<int>(SPRITE_HEIGHT))
147 .with<
ecs::Scale>(
"loading_scale", 1.0f, 1.0f)
150 SPRITE_WIDTH, SPRITE_HEIGHT, ANIMATION_FRAMES)
158 std::vector<ecs::Entity> toRemove;
160 for (
auto &[entity, animation] : loadingEntities)
162 toRemove.push_back(entity);
165 for (
auto entity : toRemove)
Manages projectile creation and configuration.
static ecs::Entity createBasicProjectile(ecs::Registry ®istry, float x, float y, float velocityX, float velocityY)
Create a basic projectile.
static ecs::Entity createSuperchargedProjectile(ecs::Registry ®istry, float x, float y, float velocityX, float velocityY)
Create a supercharged projectile.
void reset()
Reset weapon state.
void update(ecs::Registry ®istry, float dt, bool spacePressed)
Update weapon system.
bool tryFireSupercharged(ecs::Registry ®istry, float x, float y)
Try to fire supercharged projectile.
void hideLoadingAnimation(ecs::Registry ®istry, ecs::Entity playerEntity)
Hide loading animation.
void showLoadingAnimation(ecs::Registry ®istry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
Show loading animation in front of the player.
bool tryFireBasic(ecs::Registry ®istry, float x, float y)
Try to fire basic projectile.
EntityBuilder & with(Args &&...args)
Class for managing entities and their components.
EntityBuilder createEntity()
bool hasComponent(Entity e)
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
void removeComponent(Entity e)
This file contains common definitions and constants.
constexpr float SPRITE_WIDTH
constexpr float SPRITE_HEIGHT
constexpr auto TEXTURE_SHOOT_LOADING