1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuModAimAssist.cs

100 lines
3.9 KiB
C#
Raw Normal View History

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;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.UI;
2019-08-20 23:23:50 +08:00
using osu.Game.Rulesets.Osu.UI;
2019-08-20 04:54:07 +08:00
namespace osu.Game.Rulesets.Osu.Mods
{
internal class OsuModAimAssist : Mod, IApplicableToDrawableHitObjects, IUpdatableByPlayfield
{
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";
public override IconUsage Icon => FontAwesome.Solid.MousePointer;
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;
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModAutoplay), typeof(OsuModWiggle), typeof(OsuModTransform) };
2019-08-21 05:18:57 +08:00
private readonly List<DrawableOsuHitObject> movingObjects = new List<DrawableOsuHitObject>();
2019-08-20 04:54:07 +08:00
public void Update(Playfield playfield)
{
2019-08-21 05:18:57 +08:00
var cursorPos = playfield.Cursor.ActiveCursor.DrawPosition;
2019-08-20 22:33:56 +08:00
2019-08-21 05:18:57 +08:00
// Avoid relocating judgment displays and hide follow points
2019-08-20 04:54:07 +08:00
playfield.DisplayJudgements.Value = false;
2019-08-20 23:23:50 +08:00
(playfield as OsuPlayfield)?.ConnectionLayer.Hide();
2019-08-20 04:54:07 +08:00
2019-08-21 05:18:57 +08:00
// First move objects to new destination, then remove them from movingObjects list if they're too old
movingObjects.RemoveAll(d =>
2019-08-20 04:54:07 +08:00
{
2019-08-20 22:33:56 +08:00
var h = d.HitObject;
2019-08-21 05:18:57 +08:00
var currentTime = playfield.Clock.CurrentTime;
var endTime = (h as IHasEndTime)?.EndTime ?? h.StartTime;
d.ClearTransforms();
2019-08-20 04:54:07 +08:00
2019-08-20 22:33:56 +08:00
switch (d)
2019-08-20 04:54:07 +08:00
{
2019-08-20 22:33:56 +08:00
case DrawableHitCircle circle:
2019-08-21 05:18:57 +08:00
// 10ms earlier on the note to reduce chance of missing when clicking early / cursor moves fast
circle.MoveTo(cursorPos, Math.Max(0, endTime - currentTime - 10));
return currentTime > endTime;
2019-08-20 05:51:47 +08:00
2019-08-20 22:33:56 +08:00
case DrawableSlider slider:
2019-08-20 05:51:47 +08:00
2019-08-20 22:33:56 +08:00
// Move slider to cursor
if (currentTime < h.StartTime)
2019-08-21 05:18:57 +08:00
{
slider.MoveTo(cursorPos, Math.Max(0, h.StartTime - currentTime - 10));
return false;
}
2019-08-20 22:33:56 +08:00
// Move slider so that sliderball stays on the cursor
else
2019-08-21 05:18:57 +08:00
{
slider.MoveTo(cursorPos - slider.Ball.DrawPosition);
return currentTime > endTime;
}
2019-08-20 04:54:07 +08:00
2019-08-20 22:33:56 +08:00
case DrawableSpinner _:
// TODO
return true;
2019-08-20 05:51:47 +08:00
2019-08-20 22:33:56 +08:00
default:
return true;
}
});
2019-08-20 04:54:07 +08:00
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var drawable in drawables)
drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState;
}
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
{
2019-08-21 05:18:57 +08:00
if (drawable is DrawableOsuHitObject hitobject)
movingObjects.Add(hitobject);
2019-08-20 04:54:07 +08:00
}
}
/*
* TODOs
2019-08-21 05:18:57 +08:00
* - fix sliders reappearing at original position after their EndTime (see https://puu.sh/E7zT4/111cf9cdc8.gif)
* - relocate / hide slider headcircle's explosion, flash, ...
2019-08-20 22:33:56 +08:00
* - automate spinners
2019-08-20 04:54:07 +08:00
* - combine with OsuModRelax (?)
*
*/
}