Character: Moved setDelete from onDeath to onDamage.

This means the default implemenation does not need to be called
by implementations.
This commit is contained in:
Felix Ableitner 2012-10-04 19:30:50 +02:00
parent f013b3c000
commit afdd8a03b1
1 changed files with 4 additions and 5 deletions

View File

@ -52,7 +52,8 @@ Character::think(float elapsedTime) {
}
/**
* Subtracts health from Actor.
* Subtracts health from Actor. Calls onDeath() when health reaches zero and marks
* object for deletion.
*
* @param damage Amount of health to subtract.
*/
@ -62,15 +63,13 @@ Character::onDamage(int damage) {
if (mCurrentHealth <= 0) {
mCurrentHealth = 0;
onDeath();
setDelete(true);
}
}
/**
* Called when health reaches zero. Marks the object for deletion.
*
* @warning Implementations should call the default implementation.
* Called when health reaches zero. Default immplementation does nothing.
*/
void
Character::onDeath() {
setDelete(true);
}