32 lines
824 B
C#
32 lines
824 B
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
using Zennysoft.Game.Ma;
|
|
using Zennysoft.Ma.Adapter;
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class EnemyProjectile : RigidBody3D
|
|
{
|
|
public override void _Notification(int what) => this.Notify(what);
|
|
|
|
[Export] public AttackDataResource AttackData { get; set; }
|
|
|
|
[Node] private Area3D _area3D { get; set; }
|
|
|
|
public override void _Ready()
|
|
{
|
|
BodyEntered += Hitbox_AreaEntered;
|
|
_area3D.AreaEntered += AreaEntered;
|
|
}
|
|
|
|
private void AreaEntered(Area3D area)
|
|
{
|
|
if (area.GetOwner() is IPlayer player)
|
|
{
|
|
player.TakeDamage(new AttackData(AttackData.Damage, AttackData.ElementType));
|
|
CallDeferred(MethodName.QueueFree);
|
|
}
|
|
}
|
|
|
|
private void Hitbox_AreaEntered(Node area) => CallDeferred(MethodName.QueueFree);
|
|
} |