1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 23:47:32 +08:00
osu-lazer/osu.Game.Modes.Taiko/Objects/DrumRoll.cs

104 lines
3.6 KiB
C#
Raw Normal View History

2017-03-17 12:56:14 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps.Samples;
using osu.Game.Modes.Objects.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
namespace osu.Game.Modes.Taiko.Objects
{
public class DrumRoll : TaikoHitObject, IHasDistance
{
public double EndTime => StartTime + Distance / Velocity;
public double Duration => EndTime - StartTime;
/// <summary>
/// Raw length of the drum roll in positional length units.
/// </summary>
public double Distance { get; set; }
/// <summary>
/// Velocity of the drum roll in positional length units per millisecond.
/// </summary>
2017-03-22 00:33:22 +08:00
public double Velocity { get; protected set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// The distance between ticks of this drumroll.
/// <para>Half of this value is the hit window of the ticks.</para>
/// </summary>
2017-03-22 00:33:22 +08:00
public double TickTimeDistance { get; protected set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Number of drum roll ticks required for a "Good" hit.
/// </summary>
2017-03-22 00:33:22 +08:00
public double RequiredGoodHits { get; protected set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Number of drum roll ticks required for a "Great" hit.
/// </summary>
2017-03-22 00:33:22 +08:00
public double RequiredGreatHits { get; protected set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Total number of drum roll ticks.
/// </summary>
2017-03-22 00:33:22 +08:00
public int TotalTicks => Ticks.Count();
2017-03-17 12:56:14 +08:00
/// <summary>
/// Initializes the drum roll ticks if not initialized and returns them.
/// </summary>
2017-03-22 00:33:22 +08:00
public IEnumerable<DrumRollTick> Ticks => ticks ?? (ticks = createTicks());
2017-03-17 12:56:14 +08:00
private List<DrumRollTick> ticks;
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
base.ApplyDefaults(timing, difficulty);
2017-03-17 14:45:54 +08:00
Velocity = timing.SliderVelocityAt(StartTime) * difficulty.SliderMultiplier / 1000;
2017-03-17 12:56:14 +08:00
TickTimeDistance = timing.BeatLengthAt(StartTime);
2017-03-23 09:56:30 +08:00
//TODO: move this to legacy conversion code to allow for direct division without special case.
2017-03-17 12:56:14 +08:00
if (difficulty.SliderTickRate == 3)
TickTimeDistance /= 3;
else
TickTimeDistance /= 4;
RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
}
2017-03-22 00:33:22 +08:00
private List<DrumRollTick> createTicks()
2017-03-17 12:56:14 +08:00
{
2017-03-22 00:33:22 +08:00
var ret = new List<DrumRollTick>();
2017-03-17 12:56:14 +08:00
if (TickTimeDistance == 0)
2017-03-22 00:33:22 +08:00
return ret;
2017-03-17 12:56:14 +08:00
bool first = true;
for (double t = StartTime; t < EndTime + (int)TickTimeDistance; t += TickTimeDistance)
{
2017-03-22 00:33:22 +08:00
ret.Add(new DrumRollTick
2017-03-17 12:56:14 +08:00
{
FirstTick = first,
PreEmpt = PreEmpt,
TickTimeDistance = TickTimeDistance,
StartTime = t,
Sample = new HitSampleInfo
{
Type = SampleType.None,
Set = SampleSet.Soft
}
});
first = false;
}
2017-03-22 00:33:22 +08:00
return ret;
2017-03-17 12:56:14 +08:00
}
}
}