Simple knockback implementation

This commit is contained in:
Marco 2025-05-06 16:06:00 +02:00
commit 78fe44e6ec
10 changed files with 96 additions and 8 deletions

View file

@ -23,6 +23,8 @@ public partial class GenericDamageReceiver : Area2D, IHittable
[Signal]
public delegate void ShieldHitEventHandler();
[Signal] public delegate void BulletHitEventHandler(Bullet bullet, Vector2 position, Vector2 direction);
//[Signal] public delegate void DeathEventHandler();
private Node2D _parent;
@ -54,6 +56,9 @@ public partial class GenericDamageReceiver : Area2D, IHittable
if (BulletGroup is BulletOwner.None)
{
this.Hit(bullet.Damage, bullet.DamageType);
EmitSignalBulletHit(bullet, area.GlobalPosition, (this.GlobalPosition - area.GlobalPosition).Normalized());
bullet.RequestCollisionDestruction();
return;
}
@ -61,6 +66,9 @@ public partial class GenericDamageReceiver : Area2D, IHittable
if (bullet.BulletInfo.Owner == BulletGroup) return;
this.Hit(bullet.Damage, bullet.DamageType);
EmitSignalBulletHit(bullet, area.GlobalPosition, (this.GlobalPosition - area.GlobalPosition).Normalized());
bullet.RequestCollisionDestruction();
}