export target variables and made a targetable interface

This commit is contained in:
2026-01-21 14:21:47 +01:00
parent 04121f18a4
commit fb78add739
7 changed files with 41 additions and 16 deletions

View File

@@ -10,7 +10,8 @@ public partial class Enemy : CharacterBody3D,
IKillable,
IMoveable,
ISpawnable,
IKnockbackable
IKnockbackable,
ITargetable
{
// Signals and events
public event Action<IDamageable, DamageRecord> DamageTaken;
@@ -156,4 +157,11 @@ public partial class Enemy : CharacterBody3D,
if (CKnockback is null) return Vector3.Zero;
return CKnockback.ComputeKnockback();
}
public Vector3 GetTargetGlobalPosition()
{
var target = GetNode<Node3D>("CTarget");
if (target is null) return GlobalPosition;
return target.GlobalPosition;
}
}