aboutsummaryrefslogtreecommitdiffstats
path: root/src/components.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components.cpp')
-rw-r--r--src/components.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/components.cpp b/src/components.cpp
index dee56a6..14599c2 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -3,6 +3,7 @@
#include <entityx/entityx.h>
#include <events.hpp>
+#include <attack.hpp>
#include <render.hpp>
#include <ui.hpp>
#include <engine.hpp>
@@ -50,15 +51,18 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e
// make the entity wander
// TODO initialX and range?
- if (0 && entity.has_component<Aggro>()) {
+ if (entity.has_component<Aggro>()) {
auto ppos = game::engine.getSystem<PlayerSystem>()->getPosition();
if (ppos.x > position.x && ppos.x < position.x + entity.component<Solid>()->width) {
- auto& h = entity.component<Health>()->health;
+ auto dim = entity.component<Solid>();
+ ev.emit<AttackEvent>(vec2(position.x + dim->width, position.y + dim->height),
+ AttackType::ShortSlash, false);
+ /*auto& h = entity.component<Health>()->health;
if (h > 0) {
fight = true;
toFight = entity;
h = 0;
- }
+ }*/
} else
direction.x = (ppos.x > position.x) ? .01 : -.01;
} else if (entity.has_component<Wander>()) {