added player hurtbox
This commit is contained in:
parent
7bb6854335
commit
5a6c711296
8 changed files with 54 additions and 35 deletions
|
|
@ -3,8 +3,8 @@ using System.Collections.Generic;
|
|||
namespace Dancer;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||
IProvide<IHitboxOwner>
|
||||
public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, IHurtboxOwner,
|
||||
IProvide<IHitboxOwner>, IProvide<IHurtboxOwner>
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
|
@ -456,8 +456,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
GlobalDamageImmunityTimer.Start();
|
||||
}
|
||||
|
||||
public void OnHitboxAdded(Hitbox hitbox) => hitbox.BodyHit += OnEnemyHit;
|
||||
public void OnHitboxRemoved(Hitbox hitbox) => hitbox.BodyHit -= OnEnemyHit;
|
||||
public void OnHitboxAdded(Hitbox hitbox) => hitbox.TargetHit += OnEnemyHit;
|
||||
public void OnHitboxRemoved(Hitbox hitbox) => hitbox.TargetHit -= OnEnemyHit;
|
||||
|
||||
IHitboxOwner IProvide<IHitboxOwner>.
|
||||
Value() => this;
|
||||
|
|
@ -466,6 +466,23 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnAttacked(Hurtbox hurtbox, in Attack attack)
|
||||
{
|
||||
TakeDamage(attack.Damage);
|
||||
}
|
||||
|
||||
public void OnHurtboxAdded(Hurtbox hurtbox)
|
||||
{
|
||||
hurtbox.Attacked += OnAttacked;
|
||||
}
|
||||
|
||||
public void OnHurtboxRemoved(Hurtbox hurtbox)
|
||||
{
|
||||
hurtbox.Attacked -= OnAttacked;
|
||||
}
|
||||
|
||||
public IHurtboxOwner Value() => this;
|
||||
}
|
||||
|
||||
public static class GameActionExtensions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue