2019-01-24 16:43:03 +08:00
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-08-02 15:44:01 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Mania.Judgements;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2019-09-06 14:24:00 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Objects
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a hit object which requires pressing, holding, and releasing a key.
|
|
|
|
/// </summary>
|
|
|
|
public class HoldNote : ManiaHitObject, IHasEndTime
|
|
|
|
{
|
|
|
|
public double EndTime => StartTime + Duration;
|
|
|
|
|
|
|
|
private double duration;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
public double Duration
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => duration;
|
2018-04-13 17:19:50 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
duration = value;
|
|
|
|
Tail.StartTime = EndTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override double StartTime
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => base.StartTime;
|
2018-04-13 17:19:50 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
base.StartTime = value;
|
|
|
|
Head.StartTime = value;
|
|
|
|
Tail.StartTime = EndTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int Column
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => base.Column;
|
2018-04-13 17:19:50 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
base.Column = value;
|
|
|
|
Head.Column = value;
|
|
|
|
Tail.Column = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The head note of the hold.
|
|
|
|
/// </summary>
|
|
|
|
public readonly Note Head = new Note();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The tail note of the hold.
|
|
|
|
/// </summary>
|
2018-08-02 15:44:01 +08:00
|
|
|
public readonly TailNote Tail = new TailNote();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The time between ticks of this hold.
|
|
|
|
/// </summary>
|
|
|
|
private double tickSpacing = 50;
|
|
|
|
|
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
|
|
|
{
|
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
|
|
|
|
|
|
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
|
|
|
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void CreateNestedHitObjects()
|
|
|
|
{
|
|
|
|
base.CreateNestedHitObjects();
|
|
|
|
|
|
|
|
createTicks();
|
2018-08-16 09:45:06 +08:00
|
|
|
|
|
|
|
AddNested(Head);
|
|
|
|
AddNested(Tail);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void createTicks()
|
|
|
|
{
|
|
|
|
if (tickSpacing == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
|
|
|
{
|
|
|
|
AddNested(new HoldNoteTick
|
|
|
|
{
|
|
|
|
StartTime = t,
|
|
|
|
Column = Column
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-08-02 15:44:01 +08:00
|
|
|
|
2018-08-06 10:50:18 +08:00
|
|
|
public override Judgement CreateJudgement() => new HoldNoteJudgement();
|
2019-09-02 15:10:30 +08:00
|
|
|
|
2019-10-09 18:08:31 +08:00
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|