Files
MovementTests/tests/components/KnockbackComponentUnitTest.cs
Minimata 96b4fa7197
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 23s
Create tag and build when new code gets to main / Export (push) Successful in 7m9s
Create tag and build when new code gets to main / Test (push) Failing after 5m6s
trying to fix CI
2026-02-22 16:06:04 +01:00

33 lines
1.0 KiB
C#

using Godot;
using GdUnit4;
using static GdUnit4.Assertions;
using Movementtests.interfaces;
using Movementtests.systems.damage;
namespace Movementtests.tests;
[TestSuite, RequireGodotRuntime]
public class KnockbackComponentUnitTest
{
[TestCase]
public void RegisterAndComputeKnockback()
{
var cKnock = new CKnockback();
cKnock.RKnockback = new RKnockback(2.0f);
cKnock.GlobalPosition = Vector3.Zero;
var damage = new DamageRecord(new Vector3(10, 0, 0), new RDamage(0, EDamageTypes.Normal));
var record = new KnockbackRecord(damage, 1.5f);
cKnock.RegisterKnockback(record);
var force = cKnock.ComputeKnockback();
// Direction from source(10,0,0) to target(0,0,0) is (-1,0,0), scaled by modifier(2) and multiplier(1.5) => (-3,0,0)
AssertVector(force).IsEqual(new Vector3(-3, 0, 0));
// Second call returns zero since internal state resets
var second = cKnock.ComputeKnockback();
AssertVector(second).IsEqual(Vector3.Zero);
}
}