2018-01-05 19:21:19 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-02 17:44:02 +08:00
|
|
|
|
2017-07-26 12:22:46 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 12:55:18 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-05-03 11:53:45 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
namespace osu.Game.Rulesets.Mania.Objects
|
2016-09-02 17:44:02 +08:00
|
|
|
{
|
2017-05-09 19:55:20 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Represents a hit object which requires pressing, holding, and releasing a key.
|
|
|
|
/// </summary>
|
2017-05-24 19:45:01 +08:00
|
|
|
public class HoldNote : ManiaHitObject, IHasEndTime
|
2016-09-02 17:44:02 +08:00
|
|
|
{
|
2017-05-03 11:53:45 +08:00
|
|
|
public double EndTime => StartTime + Duration;
|
|
|
|
|
2017-05-26 14:53:49 +08:00
|
|
|
private double duration;
|
|
|
|
public double Duration
|
|
|
|
{
|
|
|
|
get { return duration; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
duration = value;
|
|
|
|
Tail.StartTime = EndTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override double StartTime
|
|
|
|
{
|
|
|
|
get { return base.StartTime; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
base.StartTime = value;
|
|
|
|
Head.StartTime = value;
|
|
|
|
Tail.StartTime = EndTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-11 12:44:39 +08:00
|
|
|
public override int Column
|
|
|
|
{
|
|
|
|
get { return base.Column; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
base.Column = value;
|
|
|
|
Head.Column = value;
|
|
|
|
Tail.Column = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-24 20:57:38 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The head note of the hold.
|
|
|
|
/// </summary>
|
2017-05-26 15:28:39 +08:00
|
|
|
public readonly Note Head = new Note();
|
2017-05-24 19:45:01 +08:00
|
|
|
|
2017-05-24 20:57:38 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The tail note of the hold.
|
|
|
|
/// </summary>
|
2017-05-26 15:28:39 +08:00
|
|
|
public readonly Note Tail = new TailNote();
|
2017-05-18 17:19:29 +08:00
|
|
|
|
2017-05-09 19:55:20 +08:00
|
|
|
/// <summary>
|
2017-05-24 20:57:38 +08:00
|
|
|
/// The time between ticks of this hold.
|
2017-05-09 19:55:20 +08:00
|
|
|
/// </summary>
|
2017-05-24 19:45:01 +08:00
|
|
|
private double tickSpacing = 50;
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
2017-05-24 20:24:33 +08:00
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2017-12-21 15:02:33 +08:00
|
|
|
|
2017-05-24 20:24:33 +08:00
|
|
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
|
|
|
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
2017-05-29 15:18:01 +08:00
|
|
|
|
|
|
|
Head.ApplyDefaults(controlPointInfo, difficulty);
|
|
|
|
Tail.ApplyDefaults(controlPointInfo, difficulty);
|
2017-05-24 20:24:33 +08:00
|
|
|
}
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
protected override void CreateNestedHitObjects()
|
2017-05-03 11:53:45 +08:00
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
base.CreateNestedHitObjects();
|
2017-05-24 19:45:01 +08:00
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
createTicks();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createTicks()
|
|
|
|
{
|
2017-05-24 19:45:01 +08:00
|
|
|
if (tickSpacing == 0)
|
2017-12-22 20:42:54 +08:00
|
|
|
return;
|
2017-05-24 19:45:01 +08:00
|
|
|
|
2017-05-26 15:28:39 +08:00
|
|
|
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
2017-05-24 19:45:01 +08:00
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
AddNested(new HoldNoteTick
|
2017-05-24 19:45:01 +08:00
|
|
|
{
|
2017-09-11 13:35:18 +08:00
|
|
|
StartTime = t,
|
|
|
|
Column = Column
|
2017-12-22 20:42:54 +08:00
|
|
|
});
|
2017-05-24 19:45:01 +08:00
|
|
|
}
|
2017-05-03 11:53:45 +08:00
|
|
|
|
|
|
|
}
|
2017-05-24 20:57:38 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The tail of the hold note.
|
|
|
|
/// </summary>
|
|
|
|
private class TailNote : Note
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Lenience of release hit windows. This is to make cases where the hold note release
|
|
|
|
/// is timed alongside presses of other hit objects less awkward.
|
|
|
|
/// </summary>
|
|
|
|
private const double release_window_lenience = 1.5;
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
2017-05-24 20:57:38 +08:00
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2017-05-24 20:57:38 +08:00
|
|
|
|
|
|
|
HitWindows *= release_window_lenience;
|
|
|
|
}
|
|
|
|
}
|
2016-09-02 17:44:02 +08:00
|
|
|
}
|
|
|
|
}
|