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;
|
2022-10-13 05:17:02 +08:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2019-08-20 04:54:07 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-08-11 04:09:11 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2022-08-25 08:59:32 +08:00
|
|
|
|
using osu.Framework.Timing;
|
2022-06-10 06:52:10 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2022-02-02 15:15:06 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2022-06-10 06:52:10 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
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-06-10 06:52:10 +08:00
|
|
|
|
internal class OsuModMagnetised : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
2019-08-20 04:54:07 +08:00
|
|
|
|
{
|
2022-04-01 11:15:26 +08:00
|
|
|
|
public override string Name => "Magnetised";
|
|
|
|
|
public override string Acronym => "MG";
|
|
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.Magnet;
|
2022-06-10 06:52:10 +08:00
|
|
|
|
public override ModType Type => ModType.Fun;
|
2022-08-11 04:09:11 +08:00
|
|
|
|
public override LocalisableString Description => "No need to chase the circles – your cursor is a magnet!";
|
2022-08-12 14:25:35 +08:00
|
|
|
|
public override double ScoreMultiplier => 0.5;
|
2023-12-03 10:39:44 +08:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModWiggle), typeof(OsuModTransform), typeof(ModAutoplay), typeof(OsuModRelax), typeof(OsuModRepel), typeof(OsuModBubbles), typeof(OsuModDepth) };
|
2019-08-20 04:54:07 +08:00
|
|
|
|
|
2022-04-01 11:15:26 +08:00
|
|
|
|
[SettingSource("Attraction strength", "How strong the pull is.", 0)]
|
2022-06-10 06:52:10 +08:00
|
|
|
|
public BindableFloat AttractionStrength { 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-06-10 06:52:10 +08:00
|
|
|
|
|
2024-04-23 02:25:43 +08:00
|
|
|
|
// Bindable Setting for Show Judgements
|
|
|
|
|
[SettingSource("Show Judgements", "Whether to show judgements or not.")]
|
|
|
|
|
public BindableBool ShowJudgements { get; } = new BindableBool(true);
|
|
|
|
|
|
2022-06-10 06:52:10 +08:00
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
|
|
|
|
{
|
|
|
|
|
// 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.
|
2024-04-23 02:25:43 +08:00
|
|
|
|
drawableRuleset.Playfield.DisplayJudgements.Value = ShowJudgements.Value;
|
|
|
|
|
//(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
|
2022-06-10 06:52:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(Playfield playfield)
|
|
|
|
|
{
|
2022-10-13 05:17:02 +08:00
|
|
|
|
var cursorPos = playfield.Cursor.AsNonNull().ActiveCursor.DrawPosition;
|
2022-06-10 06:52:10 +08:00
|
|
|
|
|
2024-02-04 00:54:04 +08:00
|
|
|
|
foreach (var entry in playfield.HitObjectContainer.AliveEntries)
|
2022-06-10 06:52:10 +08:00
|
|
|
|
{
|
2024-02-04 00:54:04 +08:00
|
|
|
|
var drawable = entry.Value;
|
|
|
|
|
|
2022-06-10 06:52:10 +08:00
|
|
|
|
switch (drawable)
|
|
|
|
|
{
|
|
|
|
|
case DrawableHitCircle circle:
|
2022-08-25 08:59:32 +08:00
|
|
|
|
easeTo(playfield.Clock, circle, cursorPos);
|
2022-06-10 06:52:10 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DrawableSlider slider:
|
|
|
|
|
|
|
|
|
|
if (!slider.HeadCircle.Result.HasResult)
|
2022-08-25 08:59:32 +08:00
|
|
|
|
easeTo(playfield.Clock, slider, cursorPos);
|
2022-06-10 06:52:10 +08:00
|
|
|
|
else
|
2022-08-25 08:59:32 +08:00
|
|
|
|
easeTo(playfield.Clock, slider, cursorPos - slider.Ball.DrawPosition);
|
2022-06-10 06:52:10 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-25 08:59:32 +08:00
|
|
|
|
private void easeTo(IFrameBasedClock clock, DrawableHitObject hitObject, Vector2 destination)
|
2022-06-10 06:52:10 +08:00
|
|
|
|
{
|
|
|
|
|
double dampLength = Interpolation.Lerp(3000, 40, AttractionStrength.Value);
|
|
|
|
|
|
2022-08-25 08:59:32 +08:00
|
|
|
|
float x = (float)Interpolation.DampContinuously(hitObject.X, destination.X, dampLength, clock.ElapsedFrameTime);
|
|
|
|
|
float y = (float)Interpolation.DampContinuously(hitObject.Y, destination.Y, dampLength, clock.ElapsedFrameTime);
|
2022-06-10 06:52:10 +08:00
|
|
|
|
|
|
|
|
|
hitObject.Position = new Vector2(x, y);
|
|
|
|
|
}
|
2019-08-20 04:54:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|