fish-station/Content.IntegrationTests/Tests/Movement/SlippingTest.cs

46 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#nullable enable
using Content.IntegrationTests.Tests.Helpers;
using Content.Shared.Movement.Components;
using Content.Shared.Slippery;
using Content.Shared.Stunnable;
using Robust.Shared.Input;
using Robust.Shared.Maths;
namespace Content.IntegrationTests.Tests.Movement;
public sealed class SlippingTest : MovementTest
{
public sealed class SlipTestSystem : TestListenerSystem<SlipEvent>;
[Test]
public async Task BananaSlipTest()
{
await SpawnTarget("TrashBananaPeel");
var modifier = Comp<MovementSpeedModifierComponent>(Player).SprintSpeedModifier;
// Sunrise-Start
// Ввиду бхоп системы, скорость не ровно 1, а может быть чуть больше.
// Assert.That(modifier, Is.EqualTo(1), "Player is not moving at full speed.");
Assert.That(Math.Abs(modifier - 1), Is.LessThan(0.1f));
// Sunrise-End
// Player is to the left of the banana peel.
Assert.That(Delta(), Is.GreaterThan(0.5f));
// Walking over the banana slowly does not trigger a slip.
await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Down);
await AssertFiresEvent<SlipEvent>(async () => await Move(DirectionFlag.East, 1f), count: 0);
Assert.That(Delta(), Is.LessThan(0.5f));
AssertComp<KnockedDownComponent>(false, Player);
// Moving at normal speeds does trigger a slip.
await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Up);
await AssertFiresEvent<SlipEvent>(async () => await Move(DirectionFlag.West, 1f));
// And the person that slipped was the player
AssertEvent<SlipEvent>(predicate: @event => @event.Slipped == SPlayer);
AssertComp<KnockedDownComponent>(true, Player);
}
}