7#include "components/Transform.hpp"
8#include "events/busEvents.hpp"
10#include "components/Dead.hpp"
11#include "components/Enemy.hpp"
12#include "components/EnemyEvent.hpp"
14namespace rtk::systems {
35 void onStart(rtk::ecs::Registry &)
override {}
41 void update(rtk::ecs::Registry ®,
float)
override {
45 std::vector<std::size_t> entitiesToDestroy;
47 for (
auto entity : view) {
48 auto *transform = transforms.get(entity);
52 if (transform->position.x < -100.0f) {
53 entitiesToDestroy.push_back(entity);
57 for (
auto entity : entitiesToDestroy) {
66 void onStop(rtk::ecs::Registry &)
override {}
Type indexed publish and subscribe event bus.
Definition busEvents.hpp:20
void publish(const E &event)
Calls every handler registered for the event type.
Definition busEvents.hpp:52
Removes enemies that left the screen on the left side.
Definition EnemyGarbageCollectorSystem.hpp:23
void update(rtk::ecs::Registry ®, float) override
Marks enemies with x below -100 as dead and publishes an event.
Definition EnemyGarbageCollectorSystem.hpp:41
void onStart(rtk::ecs::Registry &) override
Does nothing.
Definition EnemyGarbageCollectorSystem.hpp:35
void onStop(rtk::ecs::Registry &) override
Does nothing.
Definition EnemyGarbageCollectorSystem.hpp:66
EnemyGCSystem(busEvent &eventBus)
Creates the system.
Definition EnemyGarbageCollectorSystem.hpp:29
Tag marking an entity for destruction at the end of the frame.
Definition Dead.hpp:17
Marks an entity as a Bydos enemy.
Definition Enemy.hpp:17
Published when an enemy leaves the screen on the left side.
Definition EnemyEvent.hpp:17