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)
|
||||
|
||||
Reference in New Issue
Block a user