Fixed character removal and getCharacters returning self.
This commit is contained in:
parent
c6cd8483e0
commit
5f7c2a8ee4
1 changed files with 8 additions and 2 deletions
|
@ -232,6 +232,8 @@ std::vector<std::shared_ptr<Character> >
|
|||
World::getCharacters(const sf::Vector2f& position, float maxDistance) const {
|
||||
std::vector<std::shared_ptr<Character> > visible;
|
||||
for (auto it : mCharacters) {
|
||||
if (position == it->getPosition())
|
||||
continue;
|
||||
if (thor::squaredLength(position - it->getPosition()) <=
|
||||
maxDistance * maxDistance)
|
||||
visible.push_back(it);
|
||||
|
@ -288,13 +290,17 @@ World::step(int elapsed) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Calls Character::onThink for each character.
|
||||
* Calls Character::onThink for each character. Must be called
|
||||
* before step (due to character removal).
|
||||
*
|
||||
* @param elapsed Time since last call.
|
||||
*/
|
||||
void
|
||||
World::think(int elapsed) {
|
||||
for (auto it : mCharacters) {
|
||||
if (it->getDelete())
|
||||
removeCharacter(it);
|
||||
else
|
||||
it->onThink(elapsed);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue