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

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. * @param damage Amount of health to subtract.
*/ */
@ -62,15 +63,13 @@ Character::onDamage(int damage) {
if (mCurrentHealth <= 0) { if (mCurrentHealth <= 0) {
mCurrentHealth = 0; mCurrentHealth = 0;
onDeath(); onDeath();
setDelete(true);
} }
} }
/** /**
* Called when health reaches zero. Marks the object for deletion. * Called when health reaches zero. Default immplementation does nothing.
*
* @warning Implementations should call the default implementation.
*/ */
void void
Character::onDeath() { Character::onDeath() {
setDelete(true);
} }