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()
|
|
|
|
{
|
|
|
|
if (Faction == default && GetParent() is IFaction factionEntity)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|