SupaLidlGame/BoundingBoxes/Hurtbox.cs

40 lines
937 B
C#
Raw 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
2023-06-03 18:21:46 -07:00
namespace SupaLidlGame.BoundingBoxes;
public partial class Hurtbox : BoundingBox, IFaction
2022-11-13 19:52:09 -08:00
{
2023-06-03 18:21:46 -07:00
[Signal]
public delegate void ReceivedDamageEventHandler(
float damage,
Character inflictor,
float knockback,
Vector2 knockbackOrigin = default,
Vector2 knockbackVector = default);
2022-11-19 21:21:12 -08:00
2023-06-03 18:21:46 -07:00
public override void _Ready()
{
if (GetParent() is IFaction factionEntity)
2022-11-19 21:21:12 -08:00
{
2023-06-03 18:21:46 -07:00
Faction = factionEntity.Faction;
2022-11-19 21:21:12 -08:00
}
2023-06-03 18:21:46 -07:00
}
2022-11-13 19:52:09 -08:00
2023-06-03 18:21:46 -07:00
public void InflictDamage(
float damage,
Character inflictor,
float knockback,
Vector2 knockbackOrigin = default,
Vector2 knockbackVector = default)
{
EmitSignal(
SignalName.ReceivedDamage,
damage,
inflictor,
knockback,
knockbackOrigin, knockbackVector);
2022-11-13 19:52:09 -08:00
}
}