40 auto *being =
static_cast<Being *
>(actor);
41 if (!being->getName().empty())
42 names.push_back(being->getName());
58 auto *being =
static_cast<Being *
>(actor);
60 being->getType() ==
Being::NPC) && !being->getName().empty())
61 names.push_back(being->getName());
95 auto *being =
new Being(
id, type, subtype,
mMap);
128 return static_cast<Being *
>(actor);
144 const auto actorType = actor->getType();
145 if (actorType == ActorSprite::FLOOR_ITEM)
147 if (type != ActorSprite::UNKNOWN && actorType != type)
150 auto *being = static_cast<Being*>(actor);
152 if (!being->isTargetSelection())
155 uint16_t other_y = y + (actorType == ActorSprite::NPC ? 1 : 0);
156 const Vector &pos = being->getPosition();
157 return ((int) pos.x / tileWidth == x &&
158 ((int) pos.y / tileHeight == y
159 || (int) pos.y / tileHeight == other_y) &&
163 return it ==
mActors.end() ? nullptr :
static_cast<Being*
>(*it);
174 Being *closest =
nullptr;
182 auto *being =
static_cast<Being *
>(actor);
184 if (!being->isTargetSelection())
187 const int halfWidth = std::max(16, being->getWidth() / 2);
188 const int height = std::max(32, being->getHeight());
189 const int halfHeight = height / 2;
192 const int bottom = being->getPixelY() + halfTileHeight;
194 const int dist = std::max(std::abs(bottom - halfHeight - y),
195 std::abs(being->getPixelX() - x));
199 being->getPixelX() + halfWidth >= x && bottom - height <= y &&
201 (!closest || closestDist > dist)) {
224 int smallestDist = 0;
227 int dist = std::max(std::abs(actor->getTileX() - x),
228 std::abs(actor->getTileY() - y));
230 ((!item && dist <= maxDist) || dist < smallestDist))
248 auto *being =
static_cast<Being *
>(actor);
249 if (being->getName() == name &&
292 Being *excluded)
const
298 Being *closestBeing =
nullptr;
308 auto *being =
static_cast<Being *
>(actor);
310 if (!being->isTargetSelection())
313 const Vector &pos = being->getPosition();
314 int d = abs(((
int)pos.
x) - x) + abs(((
int)pos.
y) - y);
317 (d < dist || !closestBeing)
319 && being != excluded)
322 closestBeing = being;
326 return (maxDist >= dist) ? closestBeing :
nullptr;
360 auto *being =
static_cast<Being *
>(actor);
361 if (!being->getName().empty())
std::set< ActorSprite * > ActorSprites
ActorSpriteManager * actorSpriteManager
Being * createBeing(int id, ActorSprite::Type type, int subtype)
Create a Being and add it to the list of ActorSprites.
AutoCompleteLister * getPlayerNPCNameLister() const
FloorItem * findItem(int id) const
Returns a specific FloorItem, by id.
Being * findNearestLivingBeing(int x, int y, int maxTileDist, ActorSprite::Type type=Being::UNKNOWN, Being *excluded=nullptr) const
Returns a being nearest to specific coordinates.
void scheduleDelete(ActorSprite *actor)
Destroys the given ActorSprite at the end of ActorSpriteManager::logic.
std::unique_ptr< AutoCompleteLister > mPlayerNPCNames
Being * findBeingByName(const std::string &name, ActorSprite::Type type=Being::UNKNOWN) const
Finds a being by name and (optionally) by type.
void destroyActor(ActorSprite *actor)
Immediately destroys the given actor.
void setPlayer(LocalPlayer *player)
Sets the current player.
bool hasActorSprite(ActorSprite *someActor) const
Returns true if the given ActorSprite is in the manager's list, false otherwise.
Being * findBeingByPixel(int x, int y) const
Returns a being at the specific pixel.
const ActorSprites & getAll() const
Returns the whole list of beings.
ActorSprites mDeleteActors
std::unique_ptr< AutoCompleteLister > mPlayerNames
Being * findBeing(int id) const
Returns a specific Being, by id;.
void event(Event::Channel channel, const Event &event) override
void setMap(Map *map)
Sets the map on which ActorSprites are created.
FloorItem * createItem(int id, int itemId, const Vector &position)
Create a FloorItem and add it to the list of ActorSprites.
void clear()
Destroys all ActorSprites except the local player.
void logic()
Performs ActorSprite logic and deletes ActorSprite scheduled to be deleted.
AutoCompleteLister * getPlayerNameLister() const
int getPixelX() const
Returns the pixels X coordinate of the actor.
const Vector & getPosition() const
Returns the pixel position of this actor.
void setMap(Map *map) final
void logic() override
Performs being logic.
void listen(Event::Channel channel)
An item lying on the floor.
The main class responsible for running the game.
int getCurrentTileWidth() const
Convenience functions used to get the current tile width and height.
Map * getCurrentMap()
Returns the currently active map.
int getCurrentTileHeight() const
static Game * instance()
Provides access to the game instance.
The local player character.
int getTileHeight() const
Returns the tile height used by this map.
void getAutoCompleteList(std::vector< std::string > &names) const override
void getAutoCompleteList(std::vector< std::string > &names) const override
LocalPlayer * local_player