basic tests for a wider variety of files
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Test (push) Failing after 7m29s
Create tag and build when new code gets to main / Export (push) Successful in 8m18s

This commit is contained in:
2026-02-20 16:58:17 +01:00
parent 4474ba22fa
commit 9207295a99
28 changed files with 545 additions and 140 deletions

View File

@@ -16,36 +16,37 @@ public partial class Enemy : CharacterBody3D,
IStunnable
{
// Signals and events
public event Action<IDamageable, DamageRecord> DamageTaken;
public event Action<IHealthable, HealthChangedRecord> HealthChanged;
public event Action<IHealthable> HealthDepleted;
public event Action<IDamageable, DamageRecord> DamageTaken = null!;
public event Action<IHealthable, HealthChangedRecord> HealthChanged = null!;
public event Action<IHealthable> HealthDepleted = null!;
// Public export components
[Export]
public Node3D Target { get; set; }
public Node3D Target { get; set; } = null!;
[Export]
public float EnemyHeight { get; set; } = 1f;
[ExportGroup("Health")]
[Export]
public RHealth RHealth { get; set; }
public RHealth RHealth { get; set; } = null!;
[Export]
public RDeathEffect[] DeathEffects { get; set; }
public IHealthable CHealth { get; set; }
public RDeathEffect[] DeathEffects { get; set; } = null!;
public IHealthable CHealth { get; set; } = null!;
[ExportGroup("Damage")]
[Export]
public RDamage RDamage { get; set; }
public IDamageable CDamageable { get; set; }
public RDamage RDamage { get; set; } = null!;
public IDamageable CDamageable { get; set; } = null!;
[Export]
public RKnockback RKnockback { get; set; }
public IKnockbackable CKnockback { get; set; }
public RKnockback RKnockback { get; set; } = null!;
public IKnockbackable CKnockback { get; set; } = null!;
[ExportGroup("Movement")]
[Export]
public RMovement RMovement { get; set; }
public IMoveable CMovement { get; set; }
public RMovement RMovement { get; set; } = null!;
public IMoveable CMovement { get; set; } = null!;
// Public stuff
public float CurrentHealth
@@ -55,9 +56,9 @@ public partial class Enemy : CharacterBody3D,
}
// Private stuff
private Area3D _damageBox;
private Node3D _target;
private Healthbar _healthbar;
private Area3D _damageBox = null!;
internal Node3D _target = null!;
private Healthbar _healthbar = null!;
public override void _Ready()
{
@@ -70,34 +71,28 @@ public partial class Enemy : CharacterBody3D,
_damageBox = GetNode<Area3D>("DamageBox");
_target = GetNode<Node3D>("CTarget");
CDamageable = GetNode<Node>("CDamageable") as IDamageable;
CMovement = GetNode<Node>("CMovement") as IMoveable;
CHealth = GetNode<Node>("CHealth") as IHealthable;
CKnockback = GetNode<Node>("CKnockback") as IKnockbackable;
if (CDamageable is null) GD.PrintErr("This node needs a 'CDamage' child of type IDamageable!");
if (CMovement is null) GD.PrintErr("This node needs a 'CMovement' child of type IMoveable!");
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!");
CDamageable = (GetNode<Node>("CDamageable") as IDamageable)!;
CMovement = (GetNode<Node>("CMovement") as IMoveable)!;
CHealth = (GetNode<Node>("CHealth") as IHealthable)!;
CKnockback = (GetNode<Node>("CKnockback") as IKnockbackable)!;
_healthbar = GetNode<CHealthbar>("CHealthBar").Healthbar;
if (RMovement != null) CMovement!.RMovement = RMovement;
if (RHealth != null)
{
CHealth!.RHealth = RHealth;
CHealth.CurrentHealth = RHealth.StartingHealth;
}
if (RKnockback != null) CKnockback!.RKnockback = RKnockback;
_healthbar.Initialize(CHealth!.CurrentHealth);
CMovement.RMovement = RMovement;
CHealth.RHealth = RHealth;
CHealth.CurrentHealth = RHealth.StartingHealth;
CKnockback.RKnockback = RKnockback;
_healthbar.Initialize(CHealth.CurrentHealth);
}
public void SetupSignals()
{
// Anonymous function call to erase return values of ReduceHealth
CDamageable.DamageTaken += (source, record) => ReduceHealth(source, record);
CDamageable.DamageTaken += (source, record) => RegisterKnockback(new KnockbackRecord(record));
CDamageable.DamageTaken += (_, record) => RegisterKnockback(new KnockbackRecord(record));
CHealth.HealthDepleted += Kill;
HealthChanged += (source, record) => _healthbar.SetHealth(record.CurrentHealth);
HealthChanged += (_, record) => _healthbar.SetHealth(record.CurrentHealth);
}
public override void _PhysicsProcess(double delta)
@@ -187,24 +182,21 @@ public partial class Enemy : CharacterBody3D,
public void RegisterKnockback(KnockbackRecord knockbackRecord)
{
if (CKnockback is null) return;
CKnockback.RegisterKnockback(knockbackRecord);
}
public Vector3 ComputeKnockback()
{
if (CKnockback is null) return Vector3.Zero;
return CKnockback.ComputeKnockback();
}
public Vector3 GetTargetGlobalPosition()
{
if (_target is null) return GlobalPosition;
return _target.GlobalPosition;
return _target == null ? GlobalPosition : _target.GlobalPosition;
}
// Stun management
public bool IsStunned { get; set; } = false;
public bool IsStunned { get; set; }
[Export(PropertyHint.Range, "0.1, 2, 0.1, or_greater")]
public float StunDuration { get; set; } = 1f;