2019-08-20 04:54:07 +08: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;
|
2022-02-02 15:15:06 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-08-20 04:54:07 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-02-02 15:15:06 +08:00
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
|
using osu.Game.Configuration;
|
2019-08-20 04:54:07 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2022-02-02 15:15:06 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-08-20 04:54:07 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2019-08-20 23:23:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2022-02-02 15:15:06 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2019-08-22 03:37:56 +08:00
|
|
|
|
using osuTK;
|
2019-08-20 04:54:07 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2022-01-05 20:05:22 +08:00
|
|
|
|
internal class OsuModAimAssist : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
2019-08-20 04:54:07 +08:00
|
|
|
|
{
|
2019-08-20 22:33:56 +08:00
|
|
|
|
public override string Name => "Aim Assist";
|
2019-08-20 04:54:07 +08:00
|
|
|
|
public override string Acronym => "AA";
|
2022-01-04 21:29:44 +08:00
|
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.MousePointer;
|
2019-08-20 04:54:07 +08:00
|
|
|
|
public override ModType Type => ModType.Fun;
|
2022-02-02 15:26:10 +08:00
|
|
|
|
public override string Description => "No need to chase the circle – the circle chases you!";
|
2019-08-20 04:54:07 +08:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
2019-08-22 03:37:56 +08:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModWiggle), typeof(OsuModTransform), typeof(ModAutoplay) };
|
2019-08-20 04:54:07 +08:00
|
|
|
|
|
2022-02-02 15:15:06 +08:00
|
|
|
|
private IFrameStableClock gameplayClock;
|
|
|
|
|
|
2022-02-02 15:26:10 +08:00
|
|
|
|
[SettingSource("Assist strength", "How much this mod will assist you.", 0)]
|
2022-02-02 15:15:06 +08:00
|
|
|
|
public BindableFloat AssistStrength { get; } = new BindableFloat(0.5f)
|
2022-01-06 21:47:58 +08:00
|
|
|
|
{
|
|
|
|
|
Precision = 0.05f,
|
2022-02-02 15:26:10 +08:00
|
|
|
|
MinValue = 0.05f,
|
2022-01-06 21:47:58 +08:00
|
|
|
|
MaxValue = 1.0f,
|
|
|
|
|
};
|
2022-01-05 20:05:22 +08:00
|
|
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
|
|
|
|
{
|
2022-02-02 15:15:06 +08:00
|
|
|
|
gameplayClock = drawableRuleset.FrameStableClock;
|
|
|
|
|
|
2022-02-02 15:26:10 +08:00
|
|
|
|
// Hide judgment displays and follow points as they won't make any sense.
|
|
|
|
|
// Judgements can potentially be turned on in a future where they display at a position relative to their drawable counterpart.
|
2022-01-06 17:38:30 +08:00
|
|
|
|
drawableRuleset.Playfield.DisplayJudgements.Value = false;
|
|
|
|
|
(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
|
2022-01-05 20:05:22 +08:00
|
|
|
|
}
|
2019-08-20 04:54:07 +08:00
|
|
|
|
|
|
|
|
|
public void Update(Playfield playfield)
|
|
|
|
|
{
|
2022-02-02 14:10:56 +08:00
|
|
|
|
var cursorPos = playfield.Cursor.ActiveCursor.DrawPosition;
|
2022-01-06 23:31:30 +08:00
|
|
|
|
|
2022-02-02 15:26:10 +08:00
|
|
|
|
foreach (var drawable in playfield.HitObjectContainer.AliveObjects)
|
2019-08-20 04:54:07 +08:00
|
|
|
|
{
|
2022-02-02 14:10:56 +08:00
|
|
|
|
switch (drawable)
|
2019-08-20 04:54:07 +08:00
|
|
|
|
{
|
2022-02-02 14:10:56 +08:00
|
|
|
|
case DrawableHitCircle circle:
|
2022-02-02 15:15:06 +08:00
|
|
|
|
easeTo(circle, cursorPos);
|
2022-02-02 14:10:56 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DrawableSlider slider:
|
|
|
|
|
|
2022-02-02 14:36:09 +08:00
|
|
|
|
if (!slider.HeadCircle.Result.HasResult)
|
2022-02-02 15:15:06 +08:00
|
|
|
|
easeTo(slider, cursorPos);
|
2022-02-02 14:10:56 +08:00
|
|
|
|
else
|
2022-02-02 15:15:06 +08:00
|
|
|
|
easeTo(slider, cursorPos - slider.Ball.DrawPosition);
|
2019-08-20 04:54:07 +08:00
|
|
|
|
|
2022-02-02 14:10:56 +08:00
|
|
|
|
break;
|
2019-08-22 03:37:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-02 15:15:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void easeTo(DrawableHitObject hitObject, Vector2 destination)
|
|
|
|
|
{
|
2022-02-02 15:26:10 +08:00
|
|
|
|
double dampLength = Interpolation.Lerp(3000, 40, AssistStrength.Value);
|
2022-02-02 15:15:06 +08:00
|
|
|
|
|
|
|
|
|
float x = (float)Interpolation.DampContinuously(hitObject.X, destination.X, dampLength, gameplayClock.ElapsedFrameTime);
|
|
|
|
|
float y = (float)Interpolation.DampContinuously(hitObject.Y, destination.Y, dampLength, gameplayClock.ElapsedFrameTime);
|
2022-01-06 23:04:38 +08:00
|
|
|
|
|
2022-02-02 15:15:06 +08:00
|
|
|
|
hitObject.Position = new Vector2(x, y);
|
2019-08-20 04:54:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|