2022-05-26 04:08:00 +00:00
|
|
|
// 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 System;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Configuration;
|
2022-06-07 13:36:44 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Utils;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2022-05-26 04:08:00 +00:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
|
|
|
internal class OsuModRepel : OsuEaseHitObjectPositionsMod
|
|
|
|
{
|
|
|
|
public override string Name => "Repel";
|
|
|
|
public override string Acronym => "RP";
|
|
|
|
public override string Description => "Run away!";
|
|
|
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModMagnetised)).ToArray();
|
|
|
|
|
|
|
|
[SettingSource("Repulsion strength", "How strong the repulsion is.", 0)]
|
2022-06-09 22:26:18 +00:00
|
|
|
public override BindableFloat EasingStrength { get; } = new BindableFloat(0.6f)
|
2022-05-26 04:08:00 +00:00
|
|
|
{
|
|
|
|
Precision = 0.05f,
|
|
|
|
MinValue = 0.05f,
|
|
|
|
MaxValue = 1.0f,
|
|
|
|
};
|
|
|
|
|
2022-06-09 22:26:18 +00:00
|
|
|
protected override float EasingStrengthMultiplier => 0.8f;
|
2022-06-08 05:00:47 +00:00
|
|
|
|
2022-06-07 13:36:44 +00:00
|
|
|
protected override Vector2 DestinationVector
|
2022-05-26 04:08:00 +00:00
|
|
|
{
|
2022-06-07 13:36:44 +00:00
|
|
|
get
|
|
|
|
{
|
|
|
|
float x = Math.Clamp(2 * WorkingHitObject.X - CursorPosition.X, 0, OsuPlayfield.BASE_SIZE.X);
|
|
|
|
float y = Math.Clamp(2 * WorkingHitObject.Y - CursorPosition.Y, 0, OsuPlayfield.BASE_SIZE.Y);
|
|
|
|
|
|
|
|
if (WorkingHitObject.HitObject is Slider slider)
|
|
|
|
{
|
2022-06-09 22:07:37 +00:00
|
|
|
var possibleMovementBounds = OsuHitObjectGenerationUtils.CalculatePossibleMovementBounds(slider);
|
2022-06-07 13:36:44 +00:00
|
|
|
|
|
|
|
x = possibleMovementBounds.Width < 0
|
|
|
|
? x
|
|
|
|
: Math.Clamp(x, possibleMovementBounds.Left, possibleMovementBounds.Right);
|
|
|
|
|
|
|
|
y = possibleMovementBounds.Height < 0
|
|
|
|
? y
|
|
|
|
: Math.Clamp(y, possibleMovementBounds.Top, possibleMovementBounds.Bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Vector2(x, y);
|
|
|
|
}
|
2022-05-26 04:08:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|