1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 12:27:26 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuModAimAssist.cs

143 lines
5.5 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;
2019-08-20 04:54:07 +08:00
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-22 03:37:56 +08:00
using osuTK;
using System.Linq;
2019-08-20 04:54:07 +08:00
namespace osu.Game.Rulesets.Osu.Mods
{
internal class OsuModAimAssist : Mod, IUpdatableByPlayfield
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";
public override IconUsage? Icon => FontAwesome.Solid.MousePointer;
2019-08-20 04:54:07 +08: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-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
public const float SPIN_RADIUS = 50; // same as OsuAutoGeneratorBase.SPIN_RADIUS
2019-08-22 03:37:56 +08:00
private DrawableSpinner activeSpinner;
private float spinnerAngle; // in radians
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;
double currentTime = playfield.Clock.CurrentTime;
2019-08-20 22:33:56 +08:00
// Judgment displays would all be cramped onto the cursor
2019-08-20 04:54:07 +08:00
playfield.DisplayJudgements.Value = false;
// FIXME: Hide follow points
//(playfield as OsuPlayfield)?.ConnectionLayer.Hide();
2019-08-20 04:54:07 +08:00
2019-08-22 03:37:56 +08:00
// If object too old, remove from movingObjects list, otherwise move to new destination
foreach (var drawable in playfield.HitObjectContainer.AliveObjects.OfType<DrawableOsuHitObject>())
2019-08-20 04:54:07 +08:00
{
var h = drawable.HitObject;
double endTime = h.GetEndTime();
2019-08-22 03:37:56 +08:00
switch (drawable)
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));
break;
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));
}
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
{
// FIXME: Hide flashes
//slider.HeadCircle.Hide();
2019-08-21 05:18:57 +08:00
slider.MoveTo(cursorPos - slider.Ball.DrawPosition);
}
2019-08-20 04:54:07 +08:00
break;
2019-08-22 03:37:56 +08:00
case DrawableSpinner spinner:
// Move spinner to cursor
if (currentTime < h.StartTime)
{
spinner.MoveTo(cursorPos, Math.Max(0, h.StartTime - currentTime - 10));
}
else
{
// TODO:
// - get current angle to cursor
// - move clockwise(?)
// - call spinner.RotationTracker.AddRotation
// TODO: Remove
//spinnerAngle = 0;
//activeSpinner = spinner;
2019-08-22 03:37:56 +08:00
}
2019-08-20 05:51:47 +08:00
break;
2019-08-20 22:33:56 +08:00
default:
continue;
2019-08-20 22:33:56 +08:00
}
}
2019-08-22 03:37:56 +08:00
// Move active spinner around the cursor
2019-08-22 03:37:56 +08:00
if (activeSpinner != null)
{
double spinnerEndTime = activeSpinner.HitObject.GetEndTime();
if (currentTime > spinnerEndTime)
2019-08-22 03:37:56 +08:00
{
activeSpinner = null;
spinnerAngle = 0;
}
else
{
const float additional_degrees = 4;
float added_degrees = additional_degrees * (float)Math.PI / 180;
spinnerAngle += added_degrees;
//int spinsRequired = activeSpinner.HitObject.SpinsRequired;
//float spunDegrees = activeSpinner.Result.RateAdjustedRotation;
//double timeLeft = spinnerEndTime - currentTime;
2019-08-22 03:37:56 +08:00
// Visual progress
activeSpinner.MoveTo(new Vector2((float)(SPIN_RADIUS * Math.Cos(spinnerAngle) + cursorPos.X), (float)(SPIN_RADIUS * Math.Sin(spinnerAngle) + cursorPos.Y)));
2019-08-22 03:37:56 +08:00
// Logical progress
activeSpinner.RotationTracker.AddRotation(added_degrees);
Console.WriteLine($"added_degrees={added_degrees}");
//activeSpinner.Disc.RotationAbsolute += additional_degrees;
2019-08-22 03:37:56 +08:00
}
}
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)
2019-08-22 03:37:56 +08:00
* - find nicer way to handle slider headcircle explosion, flash, ...
* - add Aim Assist as incompatible mod for Autoplay (?)
2019-08-20 04:54:07 +08:00
*
*/
}