1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 00:02:54 +08:00

Implement OsuModSpunOut

This commit is contained in:
mcendu 2020-02-08 08:59:35 +08:00
parent 9f79713fb3
commit 25a930c438
3 changed files with 31 additions and 9 deletions

View File

@ -2,13 +2,17 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModSpunOut : Mod
public class OsuModSpunOut : Mod, IApplicableToDrawableHitObjects
{
public override string Name => "Spun Out";
public override string Acronym => "SO";
@ -18,5 +22,16 @@ namespace osu.Game.Rulesets.Osu.Mods
public override double ScoreMultiplier => 0.9;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot) };
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var hitObject in drawables)
{
if (hitObject is DrawableSpinner spinner)
{
spinner.Disc.AutoSpin = true;
}
}
}
}
}

View File

@ -177,7 +177,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void Update()
{
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;
if (!SpmCounter.IsPresent && Disc.Tracking)
if (!SpmCounter.IsPresent && (Disc.Tracking || Disc.AutoSpin))
SpmCounter.FadeIn(HitObject.TimeFadeIn);
base.Update();

View File

@ -73,6 +73,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
}
}
public bool AutoSpin { get; set; } = false;
protected override bool OnMouseMove(MouseMoveEvent e)
{
mousePosition = Parent.ToLocalSpace(e.ScreenSpaceMousePosition);
@ -94,16 +96,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
base.Update();
var thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
bool valid = spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current;
var delta = thisAngle - lastAngle;
if (valid && AutoSpin)
Rotate(6f);
else
{
var thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
bool validAndTracking = tracking && spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current;
var delta = thisAngle - lastAngle;
if (validAndTracking)
Rotate(delta);
if (valid && tracking)
Rotate(delta);
lastAngle = thisAngle;
lastAngle = thisAngle;
}
if (Complete && updateCompleteTick())
{
@ -114,7 +121,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
}
this.RotateTo(currentRotation / 2, validAndTracking ? 500 : 1500, Easing.OutExpo);
this.RotateTo(currentRotation / 2, 500, Easing.OutExpo);
}
public void Rotate(float angle)