Files
GameJamDungeon/Zennysoft.Game.Ma/src/system/EnemyProjectile.cs
Zenny f19cb7edda Rework projectiles and fix some demon wall attacks
Still working on Demon Wall boss fight overall
2026-03-09 22:05:53 -07:00

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);
}