15 if (playerEntities.empty())
17 auto &[playerEntity, player] = *playerEntities.begin();
20 if (!transform || !beamCharge)
23 bool spacePressed =
false;
24 if (!keyboardEntities.empty())
26 auto &[keyboardEntity, keyboardInput] = *keyboardEntities.begin();
38 if (beamCharge->current_charge > beamCharge->max_charge)
39 beamCharge->current_charge = beamCharge->max_charge;
40 if (beamCharge->current_charge < beamCharge->max_charge)
58 if (
const float chargeThreshold = beamCharge->max_charge * 0.5F;
59 beamCharge->current_charge >= chargeThreshold)
63 beamCharge->current_charge = 0.0f;
78 if (m_fireCooldown > 0.0f)
90 ensureSuperShotAudio(registry);
105 const auto &entity : loadingEntities | std::views::keys)
119 .with<ecs::Rect>(
"loading_rect", 0.0f, 0.0f,
122 .with<
ecs::Scale>(
"loading_scale", 1.0f, 1.0f)
135 std::vector<ecs::Entity> toRemove;
137 for (
const auto &entity : loadingEntities | std::views::keys)
139 toRemove.push_back(entity);
142 for (
const auto entity : toRemove)
174 m_superShotAudioEntity =
Configuration constants for the multiplayer game.
Manages projectile creation and configuration.
Handles weapon firing logic.
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)
static ecs::Entity createSuperchargedProjectile(ecs::Registry ®istry, float x, float y, float velocityX, float velocityY)
Create a supercharged projectile.
static ecs::Entity createBasicProjectile(ecs::Registry ®istry, float x, float y, float velocityX, float velocityY)
Create a basic projectile.
static void hideLoadingAnimation(ecs::Registry ®istry, ecs::Entity playerEntity)
Hide/remove the charging animation.
static void showLoadingAnimation(ecs::Registry ®istry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
Display charging/loading animation in front of player.
bool m_isCharging
Whether weapon is currently charging.
void ensureSuperShotAudio(ecs::Registry ®istry)
Ensure super shot audio entity exists.
void update(ecs::Registry ®istry, float dt) override
Update weapon system (called each frame)
float m_fireCooldown
Remaining cooldown time before next shot (seconds)
bool tryFireBasic(ecs::Registry ®istry, float x, float y)
Try to fire basic projectile.
bool tryFireSupercharged(ecs::Registry ®istry, float x, float y)
Try to fire supercharged projectile.
This file contains common definitions and constants.
constexpr Entity INVALID_ENTITY
constexpr float CHARGE_RATE
constexpr float ANIMATION_DURATION
constexpr int ANIMATION_FRAMES
constexpr float SPRITE_WIDTH
constexpr float SPRITE_HEIGHT
constexpr float SPRITE_HEIGHT
constexpr float SPRITE_WIDTH
constexpr float FIRE_COOLDOWN
constexpr float FIRE_COOLDOWN
constexpr auto AUDIO_SUPERCHARGED_SHOT
constexpr auto TEXTURE_SHOOT_LOADING