mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 00:05:54 +00:00
Fix for phase switch animation
This commit is contained in:
parent
bfdb71dd84
commit
95979bd3b8
7 changed files with 21 additions and 14 deletions
|
|
@ -31,7 +31,9 @@ public partial class Enemy : CharacterBody2D
|
|||
private bool _isDestroyed = false;
|
||||
|
||||
private NavigationAgent2D _navigationAgent;
|
||||
|
||||
|
||||
protected bool _invulnerable = false;
|
||||
|
||||
private bool IsPlayerInRange => _playerDetection is { IsPlayerInRange: true };
|
||||
|
||||
private bool IsPlayerInSight => _playerDetection is not null && _playerDetection.IsPlayerInSight(CollisionMask);
|
||||
|
|
@ -203,7 +205,9 @@ public partial class Enemy : CharacterBody2D
|
|||
private void _on_damage_hitbox_area_entered(Area2D area)
|
||||
{
|
||||
if (area is not Bullet bullet) return;
|
||||
GD.Print("Enemy Received damage");
|
||||
if (_invulnerable) return;
|
||||
if (bullet.BulletInfo.Owner == BulletOwner.Enemy) return;
|
||||
|
||||
this.Hit(bullet.Damage);
|
||||
bullet.QueueFree();
|
||||
}
|
||||
|
|
@ -225,9 +229,10 @@ public partial class Enemy : CharacterBody2D
|
|||
public void Hit(float damage)
|
||||
{
|
||||
if (_isDestroyed) return;
|
||||
if (_invulnerable) return;
|
||||
|
||||
_currentHealth -= damage;
|
||||
EmitSignal(nameof(HealthChanged), _currentHealth);
|
||||
EmitSignal(SignalName.HealthChanged, _currentHealth);
|
||||
if (!(_currentHealth <= 0)) return;
|
||||
_isDestroyed = true;
|
||||
Explode();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue