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

View file

@ -79,6 +79,7 @@ public:
void update(float dt) override; void update(float dt) override;
void clearAllActions() override; void clearAllActions() override;
void die() override;
bool isSelectable() const 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()); _currentHitPoints = glm::max(_minOneHP ? 1 : 0, _currentHitPoints - damageEffect.amount());
break; break;
} }
case EffectType::Death:
die();
break;
default: default:
warn("SpatialObject: applyInstantEffect: effect not implement: " + to_string(static_cast<int>(effect.type()))); warn("SpatialObject: applyInstantEffect: effect not implement: " + to_string(static_cast<int>(effect.type())));
break; break;
@ -311,6 +314,9 @@ void SpatialObject::clearAllEffects() {
_effects.clear(); _effects.clear();
} }
void SpatialObject::die() {
}
} // namespace game } // namespace game
} // namespace reone } // namespace reone

View file

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