better healthbars and one for the player as well
This commit is contained in:
@@ -57,7 +57,7 @@ public partial class Enemy : CharacterBody3D,
|
||||
// Private stuff
|
||||
private Area3D _damageBox;
|
||||
private Node3D _target;
|
||||
private CHealthbar _healthbar;
|
||||
private Healthbar _healthbar;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -79,7 +79,7 @@ public partial class Enemy : CharacterBody3D,
|
||||
if (CHealth is null) GD.PrintErr("This node needs a 'CHealth' child of type IHealthable!");
|
||||
if (CKnockback is null) GD.PrintErr("This node needs a 'CKnockback' child of type IKnockbackable!");
|
||||
|
||||
_healthbar = GetNode<CHealthbar>("CHealthBar");
|
||||
_healthbar = GetNode<CHealthbar>("CHealthBar").Healthbar;
|
||||
|
||||
if (RMovement != null) CMovement!.RMovement = RMovement;
|
||||
if (RHealth != null)
|
||||
@@ -88,6 +88,7 @@ public partial class Enemy : CharacterBody3D,
|
||||
CHealth.CurrentHealth = RHealth.StartingHealth;
|
||||
}
|
||||
if (RKnockback != null) CKnockback!.RKnockback = RKnockback;
|
||||
_healthbar.Initialize(CHealth!.CurrentHealth);
|
||||
}
|
||||
|
||||
public void SetupSignals()
|
||||
@@ -96,7 +97,7 @@ public partial class Enemy : CharacterBody3D,
|
||||
CDamageable.DamageTaken += (source, record) => ReduceHealth(source, record);
|
||||
CDamageable.DamageTaken += (source, record) => RegisterKnockback(new KnockbackRecord(record));
|
||||
CHealth.HealthDepleted += Kill;
|
||||
HealthChanged += (source, record) => _healthbar.OnHealthChanged(record);
|
||||
HealthChanged += (source, record) => _healthbar.SetHealth(record.CurrentHealth);
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
|
||||
Reference in New Issue
Block a user