mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 09:22:34 +08:00
add test, fix formatting, expose easing function
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
{
|
||||
public class TestSceneOsuModRepel : OsuModTestScene
|
||||
{
|
||||
[TestCase(0.1f)]
|
||||
[TestCase(0.5f)]
|
||||
[TestCase(1)]
|
||||
public void TestRepel(float strength)
|
||||
{
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new OsuModRepel
|
||||
{
|
||||
RepulsionStrength = { Value = strength },
|
||||
},
|
||||
PassCondition = () => true,
|
||||
Autoplay = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
protected BindableFloat EasementStrength = new BindableFloat(0.5f);
|
||||
protected Vector2 CursorPosition;
|
||||
protected DrawableHitObject WorkingHitObject;
|
||||
protected abstract Vector2 DestinationVector { get; }
|
||||
|
||||
protected virtual Vector2 DestinationVector => WorkingHitObject.Position;
|
||||
|
||||
private IFrameStableClock gameplayClock;
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||
@@ -47,22 +47,22 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
switch (drawable)
|
||||
{
|
||||
case DrawableHitCircle circle:
|
||||
easeHitObjectPositionToVector(circle, DestinationVector);
|
||||
EaseHitObjectPositionToVector(circle, DestinationVector);
|
||||
break;
|
||||
|
||||
case DrawableSlider slider:
|
||||
|
||||
if (!slider.HeadCircle.Result.HasResult)
|
||||
easeHitObjectPositionToVector(slider, DestinationVector);
|
||||
EaseHitObjectPositionToVector(slider, DestinationVector);
|
||||
else
|
||||
easeHitObjectPositionToVector(slider, DestinationVector - slider.Ball.DrawPosition);
|
||||
EaseHitObjectPositionToVector(slider, DestinationVector - slider.Ball.DrawPosition);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void easeHitObjectPositionToVector(DrawableHitObject hitObject, Vector2 destination)
|
||||
protected void EaseHitObjectPositionToVector(DrawableHitObject hitObject, Vector2 destination)
|
||||
{
|
||||
double dampLength = Interpolation.Lerp(3000, 40, EasementStrength.Value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user