namespace systems {
class BossSystems : public ISystems {
public:
void operator()(Registry &, std::shared_ptr<IContext> ctx) override;
void createNewProjectile(
Registry &r,
const ecs::component::Position &bossPos,
std::shared_ptr<IContext> ctx
);
void createFirstBoss(Registry &r, std::shared_ptr<IContext> ctx);
bool isABoss(Registry &r);
void moveProjectileTowardsPlayer(
Registry &r,
ecs::component::Position &projectilePos,
const std::size_t &idx,
std::shared_ptr<IContext> ctx
);
private:
ecs::Clock _bossClock;
ecs::Clock _shootingClock;
ecs::Clock _projectileClock;
std::size_t times = 0;
std::array<std::function<void(Registry &r, std::shared_ptr<IContext> ctx)>, 1> _bosses{
{[this](Registry &r, std::shared_ptr<IContext> ctx) { createFirstBoss(r, ctx); }},
};
};
} // namespace systems
operator():
Updates boss behavior and handles actions like shooting and movement during each game cycle.
Registry: Manages entities and components, including bosses and projectiles.IContext: Provides game context, such as player state or boss attributes.createNewProjectile:
Spawns a projectile at the boss's position to attack the player.
Registry: Manages entities and projectile components.bossPos: The current position of the boss entity.IContext: Game context for projectile settings.createFirstBoss:
Creates the first boss entity in the game.
Registry: Manages boss entities and their components.IContext: Context for boss attributes and game state.isABoss:
Checks if a boss exists in the game.
Registry: Holds and tracks boss entities.moveProjectileTowardsPlayer:
Moves a boss's projectile toward the player's position.
Registry: Manages entities and components, including the projectile.projectilePos: The current position of the projectile.idx: Index of the projectile to identify and track it.IContext: Provides access to player position or game state for accurate movement._bossClock:
Tracks boss-related actions and timing.
_shootingClock:
Manages shooting intervals for boss attacks.
_projectileClock:
Controls the timing of projectile movement.
_bosses:
An array of boss creation functions, currently only holding the createFirstBoss function.
times:
A counter to track the number of times boss-related actions have occurred.