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

View File

@@ -38,18 +38,14 @@ albedo_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_4yfjf"]
size = Vector3(1, 2, 1.5)
[node name="GroundedEnemy" type="CharacterBody3D" node_paths=PackedStringArray("CHealth", "CDamage", "CKnockback", "CMovement")]
[node name="GroundedEnemy" type="CharacterBody3D"]
collision_layer = 16
collision_mask = 273
script = ExtResource("1_r6506")
CHealth = NodePath("CHealth")
RHealth = ExtResource("2_w4lm8")
DeathEffects = Array[Object]([])
CDamage = NodePath("CDamageable")
RDamage = ExtResource("2_bn56u")
CKnockback = NodePath("CKnockback")
RKnockback = ExtResource("11_8k3xb")
CMovement = NodePath("CMovement")
RMovement = ExtResource("4_na24f")
[node name="CHealth" type="Node" parent="."]
@@ -68,6 +64,9 @@ WallInFrontRayCast = NodePath("../WallInFrontRayCast")
[node name="CKnockback" parent="." instance=ExtResource("10_jqqi6")]
[node name="CTarget" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_62kkh")