osu/osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs

55 lines
1.9 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
using System;
2020-02-08 00:59:35 +00:00
using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
2018-04-13 09:19:50 +00:00
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
2020-02-08 00:59:35 +00:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
2020-02-08 01:51:32 +00:00
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using osu.Game.Rulesets.UI;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Osu.Mods
{
2020-02-08 01:51:32 +00:00
public class OsuModSpunOut : Mod, IApplicableToDrawableHitObjects, IUpdatableByPlayfield
2018-04-13 09:19:50 +00:00
{
public override string Name => "Spun Out";
public override string Acronym => "SO";
2020-01-14 13:22:00 +00:00
public override IconUsage? Icon => OsuIcon.ModSpunout;
2020-02-09 05:33:43 +00:00
public override ModType Type => ModType.Automation;
2018-04-13 09:19:50 +00:00
public override string Description => @"Spinners will be automatically completed.";
public override double ScoreMultiplier => 0.9;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot) };
2020-02-08 00:59:35 +00:00
2020-02-08 01:51:32 +00:00
private double lastFrameTime;
2020-02-08 03:16:48 +00:00
private float frameDelay;
2020-02-08 01:51:32 +00:00
2020-02-08 00:59:35 +00:00
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var hitObject in drawables)
{
if (hitObject is DrawableSpinner spinner)
{
spinner.Disc.Enabled = false;
2020-02-08 01:51:32 +00:00
spinner.Disc.OnUpdate += d =>
{
2020-02-09 05:35:36 +00:00
var s = d as SpinnerDisc;
if (s.Valid)
s.Rotate(180 / MathF.PI * frameDelay / 40);
2020-02-08 01:51:32 +00:00
};
2020-02-08 00:59:35 +00:00
}
}
}
2020-02-08 01:51:32 +00:00
public void Update(Playfield playfield)
{
2020-02-08 03:16:48 +00:00
frameDelay = (float)(playfield.Time.Current - lastFrameTime);
2020-02-08 01:51:32 +00:00
lastFrameTime = playfield.Time.Current;
}
2018-04-13 09:19:50 +00:00
}
}