(void)ev;
(void)dt;
- // handle attacking entities
+ // handle painful entities (e.g. arrow)
en.each<Hit, Position>([&](entityx::Entity p, Hit& hit, Position& ppos) {
bool die = false;
en.each<Health, Position, Solid>([&](entityx::Entity e, Health& health, Position& pos, Solid& dim) {
if (!e.has_component<Player>() && inrange(ppos.x, pos.x, pos.x + dim.width) && inrange(ppos.y, pos.y - 2, pos.y + dim.height)) {
health.health -= hit.damage;
+ e.replace<Flash>(Color(255, 0, 0));
ParticleSystem::addMultiple(15, ParticleType::SmallBlast,
[&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
die = !hit.pierce;
p.destroy();
});
- // handle emitted attacks
+ // handle emitted attacks (player's)
for (const auto& a : attacks) {
switch (a.type) {
case AttackType::ShortSlash:
if (inrange(a.pos.x, pos.x, pos.x + dim.width, HLINES(shortSlashLength)) &&
inrange(a.pos.y, pos.y, pos.y + dim.height)) {
h.health -= a.power;
+ e.replace<Flash>(Color(255, 0, 0));
ParticleSystem::addMultiple(15, ParticleType::DownSlash,
[&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
}
if (((mce.position.x > pos.x) & (mce.position.x < pos.x + dim.width)) &&
((mce.position.y > pos.y) & (mce.position.y < pos.y + dim.height))) {
- if (e.has_component<Flash>())
- e.remove<Flash>();
- e.assign<Flash>(Color(0, 255, 255));
+ e.replace<Flash>(Color(0, 255, 255));
if (!dialogRun.load()) {
// copy entity, windows destroys the original after thread detach