2019-08-19 20:54:07 +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 osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
2019-08-20 15:23:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2019-08-21 19:37:56 +00:00
|
|
|
|
using osuTK;
|
2022-01-04 13:29:44 +00:00
|
|
|
|
using System.Linq;
|
2022-01-05 12:05:22 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-08-19 20:54:07 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2022-01-05 12:05:22 +00:00
|
|
|
|
internal class OsuModAimAssist : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
2019-08-19 20:54:07 +00:00
|
|
|
|
{
|
2019-08-20 14:33:56 +00:00
|
|
|
|
public override string Name => "Aim Assist";
|
2019-08-19 20:54:07 +00:00
|
|
|
|
public override string Acronym => "AA";
|
2022-01-04 13:29:44 +00:00
|
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.MousePointer;
|
2019-08-19 20:54:07 +00:00
|
|
|
|
public override ModType Type => ModType.Fun;
|
|
|
|
|
public override string Description => "No need to chase the circle, the circle chases you";
|
|
|
|
|
public override double ScoreMultiplier => 1;
|
2019-08-21 19:37:56 +00:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModWiggle), typeof(OsuModTransform), typeof(ModAutoplay) };
|
2019-08-19 20:54:07 +00:00
|
|
|
|
|
2022-01-04 21:17:50 +00:00
|
|
|
|
private const float spin_radius = 30;
|
2022-01-05 12:05:22 +00:00
|
|
|
|
|
2022-01-04 21:17:50 +00:00
|
|
|
|
private Vector2? prevCursorPos;
|
2022-01-05 12:05:22 +00:00
|
|
|
|
private OsuInputManager inputManager;
|
|
|
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
|
|
|
|
{
|
|
|
|
|
// Grab the input manager for future use
|
|
|
|
|
inputManager = (OsuInputManager)drawableRuleset.KeyBindingInputManager;
|
2022-01-06 09:38:30 +00:00
|
|
|
|
|
|
|
|
|
// Hide judgment displays and follow points
|
|
|
|
|
drawableRuleset.Playfield.DisplayJudgements.Value = false;
|
|
|
|
|
(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
|
2022-01-05 12:05:22 +00:00
|
|
|
|
}
|
2019-08-19 20:54:07 +00:00
|
|
|
|
|
|
|
|
|
public void Update(Playfield playfield)
|
|
|
|
|
{
|
2019-08-20 21:18:57 +00:00
|
|
|
|
var cursorPos = playfield.Cursor.ActiveCursor.DrawPosition;
|
2022-01-04 13:29:44 +00:00
|
|
|
|
double currentTime = playfield.Clock.CurrentTime;
|
2019-08-20 14:33:56 +00:00
|
|
|
|
|
2022-01-04 21:17:50 +00:00
|
|
|
|
// Move all currently alive object to new destination
|
2022-01-04 13:29:44 +00:00
|
|
|
|
foreach (var drawable in playfield.HitObjectContainer.AliveObjects.OfType<DrawableOsuHitObject>())
|
2019-08-19 20:54:07 +00:00
|
|
|
|
{
|
2022-01-04 13:29:44 +00:00
|
|
|
|
var h = drawable.HitObject;
|
2019-08-21 19:37:56 +00:00
|
|
|
|
|
2022-01-04 13:29:44 +00:00
|
|
|
|
switch (drawable)
|
2019-08-19 20:54:07 +00:00
|
|
|
|
{
|
2019-08-20 14:33:56 +00:00
|
|
|
|
case DrawableHitCircle circle:
|
2019-08-20 21:18:57 +00:00
|
|
|
|
|
|
|
|
|
// 10ms earlier on the note to reduce chance of missing when clicking early / cursor moves fast
|
2022-01-05 12:05:22 +00:00
|
|
|
|
circle.MoveTo(cursorPos, Math.Max(0, h.StartTime - currentTime - 10));
|
|
|
|
|
// FIXME: some circles cause flash at original(?) position when clicked too early
|
2022-01-04 13:29:44 +00:00
|
|
|
|
|
|
|
|
|
break;
|
2019-08-19 21:51:47 +00:00
|
|
|
|
|
2019-08-20 14:33:56 +00:00
|
|
|
|
case DrawableSlider slider:
|
2019-08-19 21:51:47 +00:00
|
|
|
|
|
2019-08-20 14:33:56 +00:00
|
|
|
|
// Move slider to cursor
|
|
|
|
|
if (currentTime < h.StartTime)
|
2019-08-20 21:18:57 +00:00
|
|
|
|
{
|
|
|
|
|
slider.MoveTo(cursorPos, Math.Max(0, h.StartTime - currentTime - 10));
|
|
|
|
|
}
|
2019-08-20 14:33:56 +00:00
|
|
|
|
// Move slider so that sliderball stays on the cursor
|
|
|
|
|
else
|
2019-08-20 21:18:57 +00:00
|
|
|
|
{
|
2022-01-05 12:05:22 +00:00
|
|
|
|
slider.HeadCircle.Hide(); // hide flash, triangles, ... so they don't move with slider
|
2019-08-20 21:18:57 +00:00
|
|
|
|
slider.MoveTo(cursorPos - slider.Ball.DrawPosition);
|
2022-01-05 12:05:22 +00:00
|
|
|
|
// FIXME: some sliders re-appearing at their original position for a single frame when they're done
|
2019-08-20 21:18:57 +00:00
|
|
|
|
}
|
2019-08-19 20:54:07 +00:00
|
|
|
|
|
2022-01-04 13:29:44 +00:00
|
|
|
|
break;
|
2019-08-21 19:37:56 +00:00
|
|
|
|
|
|
|
|
|
case DrawableSpinner spinner:
|
|
|
|
|
|
2022-01-05 12:05:22 +00:00
|
|
|
|
// Move spinner _next_ to cursor
|
2019-08-21 19:37:56 +00:00
|
|
|
|
if (currentTime < h.StartTime)
|
|
|
|
|
{
|
2022-01-04 21:17:50 +00:00
|
|
|
|
spinner.MoveTo(cursorPos + new Vector2(0, -spin_radius), Math.Max(0, h.StartTime - currentTime - 10));
|
2019-08-21 19:37:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-04 21:17:50 +00:00
|
|
|
|
// Move spinner visually
|
|
|
|
|
Vector2 delta = spin_radius * (spinner.Position - prevCursorPos ?? cursorPos).Normalized();
|
|
|
|
|
const float angle = 3 * MathF.PI / 180; // radians per update, arbitrary value
|
2019-08-19 21:51:47 +00:00
|
|
|
|
|
2022-01-04 21:17:50 +00:00
|
|
|
|
// Rotation matrix
|
|
|
|
|
var targetPos = new Vector2(
|
|
|
|
|
delta.X * MathF.Cos(angle) - delta.Y * MathF.Sin(angle) + cursorPos.X,
|
|
|
|
|
delta.X * MathF.Sin(angle) + delta.Y * MathF.Cos(angle) + cursorPos.Y
|
|
|
|
|
);
|
2022-01-04 13:29:44 +00:00
|
|
|
|
|
2022-01-04 21:17:50 +00:00
|
|
|
|
spinner.MoveTo(targetPos);
|
2022-01-04 13:29:44 +00:00
|
|
|
|
|
2022-01-05 12:05:22 +00:00
|
|
|
|
// Move spinner logically
|
|
|
|
|
if (inputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false)
|
|
|
|
|
{
|
|
|
|
|
// Arbitrary value, might lead to some inconsistencies depending on clock rate, replay, ...
|
|
|
|
|
spinner.RotationTracker.AddRotation(2 * MathF.PI);
|
|
|
|
|
}
|
2022-01-04 21:17:50 +00:00
|
|
|
|
}
|
2019-08-21 19:37:56 +00:00
|
|
|
|
|
2022-01-04 21:17:50 +00:00
|
|
|
|
break;
|
2019-08-21 19:37:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-04 21:17:50 +00:00
|
|
|
|
|
|
|
|
|
prevCursorPos = cursorPos;
|
2019-08-19 20:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|