feat: Implement Death effect

This commit is contained in:
Vsevolod Kremianskii 2020-12-29 16:33:18 +07:00
parent 070d54d7b2
commit aca9943009
4 changed files with 20 additions and 5 deletions

View file

@ -227,11 +227,7 @@ void Creature::updateModelAnimation() {
void Creature::updateHealth() {
if (_currentHitPoints > 0 || _immortal || _dead) return;
playAnimation(_animResolver.getDieAnimation());
_dead = true;
_name = Resources::instance().getString(kStrRefRemains);
debug(boost::format("Creature: '%s' is dead") % _tag, 2);
die();
}
void Creature::clearAllActions() {
@ -489,6 +485,16 @@ void Creature::giveXP(int amount) {
_xp += amount;
}
void Creature::die() {
_currentHitPoints = 0;
_dead = true;
_name = Resources::instance().getString(kStrRefRemains);
debug(boost::format("Creature: '%s' is dead") % _tag, 2);
playAnimation(_animResolver.getDieAnimation());
}
} // namespace game
} // namespace reone

View file

@ -79,6 +79,7 @@ public:
void update(float dt) override;
void clearAllActions() override;
void die() override;
bool isSelectable() const override;

View file

@ -154,6 +154,9 @@ void SpatialObject::applyInstantEffect(Effect &effect) {
_currentHitPoints = glm::max(_minOneHP ? 1 : 0, _currentHitPoints - damageEffect.amount());
break;
}
case EffectType::Death:
die();
break;
default:
warn("SpatialObject: applyInstantEffect: effect not implement: " + to_string(static_cast<int>(effect.type())));
break;
@ -311,6 +314,9 @@ void SpatialObject::clearAllEffects() {
_effects.clear();
}
void SpatialObject::die() {
}
} // namespace game
} // namespace reone

View file

@ -48,6 +48,8 @@ class SpatialObject : public Object {
public:
void update(float dt) override;
virtual void die();
void face(const SpatialObject &other);
void face(const glm::vec3 &point);
void faceAwayFrom(const SpatialObject &other);