1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

fix codefactor warnings and derive ModWindUp and ModWindDown to ModTimeRamp

This commit is contained in:
LeNitrous 2019-01-26 20:15:19 +08:00
parent 0f8c5bcbd7
commit 03e57d0423
13 changed files with 55 additions and 55 deletions

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Catch.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Catch.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Mania.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Mania.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Objects;

View File

@ -1,7 +1,6 @@
// 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.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Objects;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Zoooooooooom...";
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModHalfTime), typeof(ModWindUp) };
public override Type[] IncompatibleMods => new[] { typeof(ModHalfTime), typeof(ModTimeRamp) };
public virtual void ApplyToClock(IAdjustableClock clock)
{

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "Less zoom...";
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime), typeof(ModWindUp) };
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime), typeof(ModTimeRamp) };
public virtual void ApplyToClock(IAdjustableClock clock)
{

View File

@ -0,0 +1,46 @@
// 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.Audio;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModTimeRamp : Mod
{
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime), typeof(ModHalfTime) };
public abstract double AppendRate { get; }
}
public abstract class ModTimeRamp<T> : ModTimeRamp, IUpdatableByPlayfield, IApplicableToClock, IApplicableToBeatmap<T>
where T : HitObject
{
private double lastObjectEndTime;
private IAdjustableClock clock;
private IHasPitchAdjust pitchAdjust;
public virtual void ApplyToClock(IAdjustableClock clk)
{
clock = clk;
pitchAdjust = clk as IHasPitchAdjust;
}
public virtual void ApplyToBeatmap(Beatmap<T> beatmap)
{
HitObject lastObject = beatmap.HitObjects[beatmap.HitObjects.Count - 1];
lastObjectEndTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
}
public virtual void Update(Playfield playfield)
{
double newRate = 1 + (AppendRate * (clock.CurrentTime / lastObjectEndTime));
clock.Rate = newRate;
pitchAdjust.PitchAdjust = newRate;
}
}
}

View File

@ -6,13 +6,14 @@ using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Mods
{
public class ModWindDown<T> : ModWindUp<T>
public class ModWindDown<T> : ModTimeRamp<T>
where T : HitObject
{
public override string Name => "Wind Down";
public override string Acronym => "WD";
public override string Description => "Slow down.";
public override string Description => "Cool down.";
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_down;
public override double ScoreMultiplier => 1.0;
public override double AppendRate => -0.25;
}
}

View File

@ -1,58 +1,19 @@
// 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.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Timing;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModWindUp : Mod
public class ModWindUp<T> : ModTimeRamp<T>
where T : HitObject
{
public override string Name => "Wind Up";
public override string Acronym => "WU";
public override ModType Type => ModType.Fun;
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_up;
public override string Description => "Crank it up!";
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime), typeof(ModHalfTime) };
public abstract double AppendRate { get; }
}
public abstract class ModWindUp<T> : ModWindUp, IUpdatableByPlayfield, IApplicableToClock, IApplicableToBeatmap<T>
where T : HitObject
{
private double LastObjectEndTime;
private IAdjustableClock Clock;
private IHasPitchAdjust ClockAdjust;
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_up;
public override double ScoreMultiplier => 1.0;
public override double AppendRate => 0.5;
public virtual void ApplyToClock(IAdjustableClock clock)
{
Clock = clock;
ClockAdjust = clock as IHasPitchAdjust;
}
public virtual void ApplyToBeatmap(Beatmap<T> beatmap)
{
HitObject LastObject = beatmap.HitObjects[beatmap.HitObjects.Count - 1];
LastObjectEndTime = (LastObject as IHasEndTime)?.EndTime ?? LastObject?.StartTime ?? 0;
}
public virtual void Update(Playfield playfield)
{
double newRate = 1 + (AppendRate * (Clock.CurrentTime / LastObjectEndTime));
Clock.Rate = newRate;
ClockAdjust.PitchAdjust = newRate;
}
}
}