Moved corpse dropping to Character::onDeath to allow overloading.
This commit is contained in:
parent
310816eba6
commit
12655e0319
1 changed files with 4 additions and 4 deletions
|
@ -41,14 +41,12 @@ Character::Character(World& world, Pathfinder& pathfinder,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes pointer from static variable mCharacterInstances, inserts body into world.
|
* Deletes pointer from static variable mCharacterInstances.
|
||||||
*/
|
*/
|
||||||
Character::~Character() {
|
Character::~Character() {
|
||||||
auto it = std::find(mCharacterInstances.begin(), mCharacterInstances.end(), this);
|
auto it = std::find(mCharacterInstances.begin(), mCharacterInstances.end(), this);
|
||||||
assert(it != mCharacterInstances.end());
|
assert(it != mCharacterInstances.end());
|
||||||
mCharacterInstances.erase(it);
|
mCharacterInstances.erase(it);
|
||||||
|
|
||||||
mWorld.insert(std::shared_ptr<Sprite>(new Corpse(getPosition(), Yaml("body.yaml"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,10 +88,12 @@ Character::onThink(float elapsedTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when health reaches zero. Default immplementation does nothing.
|
* Called when health reaches zero. Default implementation drops a corpse at
|
||||||
|
* the current position.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Character::onDeath() {
|
Character::onDeath() {
|
||||||
|
mWorld.insert(std::shared_ptr<Sprite>(new Corpse(getPosition(), Yaml("body.yaml"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue