Fixed invisible enemies (for real this time).
This commit is contained in:
parent
da7b5f2d08
commit
cd169d9297
2 changed files with 15 additions and 14 deletions
|
@ -75,14 +75,15 @@ World::getCharacters(const Vector2f& position, float maxDistance) const {
|
||||||
void
|
void
|
||||||
World::step(int elapsed) {
|
World::step(int elapsed) {
|
||||||
for (auto v = mDrawables.begin(); v != mDrawables.end(); v++) {
|
for (auto v = mDrawables.begin(); v != mDrawables.end(); v++) {
|
||||||
for (auto it = v->second.begin(); it != v->second.end(); it++) {
|
for (auto it = v->second.begin(); it != v->second.end(); ) {
|
||||||
if ((*it)->getDelete()) {
|
if ((*it)->getDelete() && (*it)->getCategory() != Character::CATEGORY_ACTOR)
|
||||||
v->second.erase(it);
|
it = v->second.erase(it);
|
||||||
it--;
|
else {
|
||||||
|
// Don't run collision tests if sprite is not moving.
|
||||||
|
if ((*it)->getSpeed() != Vector2f())
|
||||||
|
applyMovement(*it, elapsed);
|
||||||
|
it++;
|
||||||
}
|
}
|
||||||
// Don't run collision tests if sprite is not moving.
|
|
||||||
else if ((*it)->getSpeed() != Vector2f())
|
|
||||||
applyMovement(*it, elapsed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,12 +122,13 @@ World::applyMovement(std::shared_ptr<Sprite> sprite, int elapsed) {
|
||||||
void
|
void
|
||||||
World::think(int elapsed) {
|
World::think(int elapsed) {
|
||||||
for (auto it = mCharacters.begin(); it != mCharacters.end(); ) {
|
for (auto it = mCharacters.begin(); it != mCharacters.end(); ) {
|
||||||
if ((*it)->getDelete()) {
|
auto value = *it;
|
||||||
mCharacters.erase(it);
|
if (value->getDelete()) {
|
||||||
remove(*it);
|
remove(value);
|
||||||
|
it = mCharacters.erase(it);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*it)->onThink(elapsed);
|
value->onThink(elapsed);
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ Character::~Character() {
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Character::onDamage(int damage) {
|
Character::onDamage(int damage) {
|
||||||
// Otherwise player might not respawn after death
|
// Avoid calling onDeath twice, or reviving Character.
|
||||||
if (mHealth <= 0)
|
if (mHealth <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -72,8 +72,7 @@ Character::onDamage(int damage) {
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Character::onThink(int elapsed) {
|
Character::onThink(int elapsed) {
|
||||||
if (mHealth <= 0)
|
assert(mHealth >= 0);
|
||||||
return;
|
|
||||||
|
|
||||||
mActiveWeapon->onThink(elapsed);
|
mActiveWeapon->onThink(elapsed);
|
||||||
if (mLeftGadget)
|
if (mLeftGadget)
|
||||||
|
|
Reference in a new issue