1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- /*
- * 2D Game Engine
- * Damage.h:
- * Based on pikuma.com 2D game engine in C++ and Lua course
- * Copyright (c) 2021 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 16/02/2021.
- */
- #ifndef GAMEENGINE_SOURCE_INCLUDE_SYSTEMS_DAMAGE_H
- #define GAMEENGINE_SOURCE_INCLUDE_SYSTEMS_DAMAGE_H
- #include <ECS.h>
- #include <EventBus.h>
- #include <Logger.h>
- #include <Events/Collision.h>
- #include <Components/BoxCollider.h>
- class DamageSystem : public System
- {
- public:
- DamageSystem()
- {
- this->requireComponent<BoxColliderComponent>();
- }
- void subscriptToEvents(std::unique_ptr<EventBus> &eventBus)
- {
- eventBus->subscribeToEvent<CollisionEvent>(this, &DamageSystem::onCollision);
- }
- void onCollision(CollisionEvent &event)
- {
- Logger::Debug("Damage: Got an event from A id#%d and B id#%d", event.a.getId(), event.b.getId());
- event.a.kill();
- event.b.kill();
- }
- void Update()
- {
- }
- };
- #endif /* GAMEENGINE_SOURCE_INCLUDE_SYSTEMS_DAMAGE_H */
|