Shield handling

This commit is contained in:
MaddoScientisto 2025-02-16 17:59:46 +01:00
commit e6c880e918

View file

@ -391,12 +391,30 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
GD.Print($"Player damaged for {damage}");
if (_isDestroyed) return;
CurrentHealth -= damage;
if (CurrentShield > 0 && type is not DamageType.Explosive or DamageType.Acid) {
// Reduce shield
CurrentShield -= damage;
if (_currentHealth < 0 ) {
CurrentHealth -= Math.Abs(CurrentShield);
CurrentShield = 0;
}
}
else {
if (type is DamageType.Fire) {
CurrentHealth -= damage * 2;
}
else {
CurrentHealth -= damage;
}
}
if (!(CurrentHealth <= 0)) return;
_isDestroyed = true;
Explode();
}
public bool IsDestroyed()
{
return _isDestroyed;