diff options
Diffstat (limited to 'src/actorspritemanager.cpp')
-rw-r--r-- | src/actorspritemanager.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 5308b3ad..a5f1a4b9 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -144,13 +144,17 @@ Being *ActorSpriteManager::findBeing(int x, int y, ActorSprite::Type type) const if (type != ActorSprite::UNKNOWN && actorType != type) return false; - auto *b = static_cast<Being*>(actor); + auto *being = static_cast<Being*>(actor); + + if (!being->isTargetSelection()) + return false; + uint16_t other_y = y + (actorType == ActorSprite::NPC ? 1 : 0); - const Vector &pos = b->getPosition(); + const Vector &pos = being->getPosition(); return ((int) pos.x / tileWidth == x && ((int) pos.y / tileHeight == y || (int) pos.y / tileHeight == other_y) && - b->isAlive()); + being->isAlive()); }); return it == mActors.end() ? nullptr : static_cast<Being*>(*it); @@ -174,6 +178,9 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y) const auto *being = static_cast<Being *>(actor); + if (!being->isTargetSelection()) + continue; + const int halfWidth = std::max(16, being->getWidth() / 2); const int height = std::max(32, being->getHeight()); const int halfHeight = height / 2; @@ -296,6 +303,10 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, continue; auto *being = static_cast<Being *>(actor); + + if (!being->isTargetSelection()) + continue; + const Vector &pos = being->getPosition(); int d = abs(((int)pos.x) - x) + abs(((int)pos.y) - y); |