SupaLidlGame/BoundingBoxes/Hurtbox.cs

41 lines
1.0 KiB
C#
Raw Permalink Normal View History

2022-11-13 19:52:09 -08:00
using Godot;
using SupaLidlGame.Characters;
2022-11-19 21:21:12 -08:00
using SupaLidlGame.Utils;
2022-11-13 19:52:09 -08:00
namespace SupaLidlGame.BoundingBoxes
{
2022-11-25 09:11:46 -08:00
public partial class Hurtbox : BoundingBox, IFaction
2022-11-13 19:52:09 -08:00
{
[Signal]
2022-11-19 21:21:12 -08:00
public delegate void ReceivedDamageEventHandler(
float damage,
Character inflictor,
float knockback,
Vector2 knockbackOrigin = default,
Vector2 knockbackVector = default);
public override void _Ready()
{
2023-03-19 16:17:33 -07:00
if (GetParent() is IFaction factionEntity)
2022-11-19 21:21:12 -08:00
{
Faction = factionEntity.Faction;
}
}
2022-11-13 19:52:09 -08:00
public void InflictDamage(
float damage,
Character inflictor,
float knockback,
Vector2 knockbackOrigin = default,
Vector2 knockbackVector = default)
{
EmitSignal(
2022-11-19 21:21:12 -08:00
SignalName.ReceivedDamage,
2022-11-13 19:52:09 -08:00
damage,
inflictor,
knockback,
knockbackOrigin, knockbackVector);
}
}
}