fixed a few issues
This commit is contained in:
@@ -26,7 +26,6 @@ public partial class Enemy : CharacterBody3D,
|
||||
ISpawnable,
|
||||
IKnockbackable,
|
||||
ITargetable,
|
||||
IStunnable,
|
||||
IForgeEntity
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
@@ -166,7 +165,7 @@ public partial class Enemy : CharacterBody3D,
|
||||
|
||||
public void ProcessGameplay(double delta)
|
||||
{
|
||||
if (IsStunned || _hitAbilityHandle == null) return;
|
||||
if (_hitAbilityHandle == null) return;
|
||||
|
||||
var bodies = DamageBox.GetOverlappingBodies();
|
||||
foreach (var body in bodies)
|
||||
@@ -186,16 +185,16 @@ public partial class Enemy : CharacterBody3D,
|
||||
|
||||
public void OnDamageReceived(EventData<DamageDone> data)
|
||||
{
|
||||
var source = data.Source as Node;
|
||||
var sourceName = source?.Name ?? "unknown damage dealer";
|
||||
GD.Print($"Ouch! Fuck you {sourceName}!");
|
||||
if (data.Payload.OverkillDamage > 0) GD.Print($"Overkill! {data.Payload.OverkillDamage} damage");
|
||||
// var source = data.Source as Node;
|
||||
// var sourceName = source?.Name ?? "unknown damage dealer";
|
||||
// GD.Print($"Ouch! Fuck you {sourceName}!");
|
||||
// if (data.Payload.OverkillDamage > 0) GD.Print($"Overkill! {data.Payload.OverkillDamage} damage");
|
||||
}
|
||||
|
||||
private void OnHealthChanged(EntityAttribute healthAttribute, int i)
|
||||
{
|
||||
if (healthAttribute.CurrentValue > healthAttribute.Min) return;
|
||||
|
||||
|
||||
Events.Raise(new EventData
|
||||
{
|
||||
EventTags = Tag.RequestTag(TagsManager, "events.combat.death").GetSingleTagContainer()!
|
||||
@@ -213,13 +212,11 @@ public partial class Enemy : CharacterBody3D,
|
||||
// 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);
|
||||
}
|
||||
if (child is not WeaponSystem system) continue;
|
||||
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())
|
||||
@@ -243,19 +240,4 @@ public partial class Enemy : CharacterBody3D,
|
||||
{
|
||||
return TargetComponent.GlobalPosition;
|
||||
}
|
||||
|
||||
// Stun management
|
||||
public bool IsStunned { get; set; }
|
||||
|
||||
[Export(PropertyHint.Range, "0.1, 2, 0.1, or_greater")]
|
||||
public float StunDuration { get; set; } = 1f;
|
||||
public void Stun()
|
||||
{
|
||||
IsStunned = true;
|
||||
GetTree().CreateTimer(StunDuration).Timeout += Unstun;
|
||||
}
|
||||
public void Unstun()
|
||||
{
|
||||
IsStunned = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user