1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 06:37:50 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Objects/HoldNote.cs

119 lines
3.5 KiB
C#
Raw Normal View History

2017-05-29 14:35:50 +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
2016-09-02 17:44:02 +08:00
2017-07-26 12:22:46 +08:00
using osu.Game.Beatmaps;
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>
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;
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 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>
private double tickSpacing = 50;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
2017-05-24 20:24:33 +08:00
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
2017-05-24 20:24:33 +08:00
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
Head.ApplyDefaults(controlPointInfo, difficulty);
Tail.ApplyDefaults(controlPointInfo, difficulty);
2017-05-24 20:24:33 +08:00
}
protected override void CreateNestedHitObjects()
2017-05-03 11:53:45 +08:00
{
base.CreateNestedHitObjects();
createTicks();
}
private void createTicks()
{
if (tickSpacing == 0)
return;
2017-05-26 15:28:39 +08:00
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
{
AddNested(new HoldNoteTick
{
StartTime = t,
Column = Column
});
}
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;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
2017-05-24 20:57:38 +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
}
}