can plant weapon in targetables, dash towards it, jump in the air.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Godot;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class Enemy : CharacterBody3D,
|
||||
@@ -22,6 +23,8 @@ public partial class Enemy : CharacterBody3D,
|
||||
// Public export components
|
||||
[Export]
|
||||
public Node3D Target { get; set; }
|
||||
[Export]
|
||||
public float EnemyHeight { get; set; } = 1f;
|
||||
|
||||
[ExportGroup("Health")]
|
||||
[Export]
|
||||
@@ -162,11 +165,23 @@ public partial class Enemy : CharacterBody3D,
|
||||
|
||||
public void Kill(IHealthable source)
|
||||
{
|
||||
// Remove weapon that might be planted there
|
||||
foreach (var child in GetChildren())
|
||||
{
|
||||
if (child is WeaponSystem system)
|
||||
{
|
||||
CallDeferred(Node.MethodName.RemoveChild, system);
|
||||
GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, system);
|
||||
system.CallDeferred(Node3D.MethodName.SetGlobalPosition, GlobalPosition + Vector3.Up*EnemyHeight);
|
||||
system.CallDeferred(WeaponSystem.MethodName.RethrowWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var killable in DeathEffects.ToIKillables())
|
||||
{
|
||||
killable.Kill(source);
|
||||
}
|
||||
QueueFree();
|
||||
CallDeferred(Node.MethodName.QueueFree);
|
||||
}
|
||||
|
||||
public void RegisterKnockback(IDamageable source, DamageRecord damageRecord)
|
||||
|
||||
@@ -48,6 +48,7 @@ collision_layer = 16
|
||||
collision_mask = 273
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_q8l7o")
|
||||
EnemyHeight = 0.5
|
||||
RHealth = ExtResource("2_ma2bq")
|
||||
DeathEffects = Array[Object]([])
|
||||
RDamage = ExtResource("2_on7rt")
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_jht15")
|
||||
StartingHealth = 50.0
|
||||
StartingHealth = 10.0
|
||||
metadata/_custom_type_script = "uid://baiapod3csndf"
|
||||
|
||||
@@ -43,6 +43,7 @@ size = Vector3(1, 2, 1.5)
|
||||
collision_layer = 16
|
||||
collision_mask = 273
|
||||
script = ExtResource("1_r6506")
|
||||
EnemyHeight = 2.0
|
||||
RHealth = ExtResource("2_w4lm8")
|
||||
DeathEffects = Array[Object]([])
|
||||
RDamage = ExtResource("2_bn56u")
|
||||
|
||||
Reference in New Issue
Block a user