1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00
osu-lazer/osu.Game/Rulesets/Mods/ModWindUp.cs

55 lines
1.9 KiB
C#
Raw Normal View History

2019-01-26 12:15:45 +08:00
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;
2019-01-26 12:15:45 +08:00
namespace osu.Game.Rulesets.Mods
{
public abstract class ModWindUp : Mod
{
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>
2019-01-26 12:15:45 +08:00
where T : HitObject
{
private double LastObjectEndTime;
2019-01-26 12:15:45 +08:00
private IAdjustableClock Clock;
private IHasPitchAdjust ClockAdjust;
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)
2019-01-26 12:15:45 +08:00
{
HitObject LastObject = beatmap.HitObjects[beatmap.HitObjects.Count - 1];
LastObjectEndTime = (LastObject as IHasEndTime)?.EndTime ?? LastObject?.StartTime ?? 0;
2019-01-26 12:15:45 +08:00
}
public virtual void Update(Playfield playfield)
{
double newRate = 1 + (AppendRate * (Clock.CurrentTime / LastObjectEndTime));
2019-01-26 12:15:45 +08:00
Clock.Rate = newRate;
ClockAdjust.PitchAdjust = newRate;
}
}
}