2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2020-04-21 16:33:19 +09:00
|
|
|
using System.Collections.Generic;
|
2020-05-15 18:07:41 +09:00
|
|
|
using System.Threading;
|
2020-04-21 16:33:19 +09:00
|
|
|
using osu.Game.Audio;
|
2017-07-26 13:22:46 +09:00
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 13:55:18 +09:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-08-02 16:44:01 +09:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
2017-05-03 12:53:45 +09:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2019-09-06 15:24:00 +09:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-04-18 16:05:58 +09:00
|
|
|
namespace osu.Game.Rulesets.Mania.Objects
|
2016-09-02 18:44:02 +09:00
|
|
|
{
|
2017-05-09 20:55:20 +09:00
|
|
|
/// <summary>
|
|
|
|
/// Represents a hit object which requires pressing, holding, and releasing a key.
|
|
|
|
/// </summary>
|
2020-05-27 12:38:39 +09:00
|
|
|
public class HoldNote : ManiaHitObject, IHasDuration
|
2016-09-02 18:44:02 +09:00
|
|
|
{
|
2020-02-05 17:12:26 +09:00
|
|
|
public double EndTime
|
|
|
|
{
|
|
|
|
get => StartTime + Duration;
|
|
|
|
set => Duration = value - StartTime;
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-05-26 15:53:49 +09:00
|
|
|
private double duration;
|
2019-02-28 13:31:40 +09:00
|
|
|
|
2017-05-26 15:53:49 +09:00
|
|
|
public double Duration
|
|
|
|
{
|
2019-02-28 13:58:19 +09:00
|
|
|
get => duration;
|
2017-05-26 15:53:49 +09:00
|
|
|
set
|
|
|
|
{
|
|
|
|
duration = value;
|
2020-04-21 16:33:19 +09:00
|
|
|
|
|
|
|
if (Tail != null)
|
|
|
|
Tail.StartTime = EndTime;
|
2017-05-26 15:53:49 +09:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-05-26 15:53:49 +09:00
|
|
|
public override double StartTime
|
|
|
|
{
|
2019-02-28 13:58:19 +09:00
|
|
|
get => base.StartTime;
|
2017-05-26 15:53:49 +09:00
|
|
|
set
|
|
|
|
{
|
|
|
|
base.StartTime = value;
|
2020-04-21 16:33:19 +09:00
|
|
|
|
|
|
|
if (Head != null)
|
|
|
|
Head.StartTime = value;
|
|
|
|
|
|
|
|
if (Tail != null)
|
|
|
|
Tail.StartTime = EndTime;
|
2017-05-26 15:53:49 +09:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-09-11 13:44:39 +09:00
|
|
|
public override int Column
|
|
|
|
{
|
2019-02-28 13:58:19 +09:00
|
|
|
get => base.Column;
|
2017-09-11 13:44:39 +09:00
|
|
|
set
|
|
|
|
{
|
|
|
|
base.Column = value;
|
2020-04-21 16:33:19 +09:00
|
|
|
|
|
|
|
if (Head != null)
|
|
|
|
Head.Column = value;
|
|
|
|
|
|
|
|
if (Tail != null)
|
|
|
|
Tail.Column = value;
|
2017-09-11 13:44:39 +09:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2021-10-23 01:59:07 -07:00
|
|
|
public IList<IList<HitSampleInfo>> NodeSamples { get; set; }
|
2020-04-21 16:33:19 +09:00
|
|
|
|
2017-05-24 21:57:38 +09:00
|
|
|
/// <summary>
|
|
|
|
/// The head note of the hold.
|
|
|
|
/// </summary>
|
2021-05-12 16:35:05 +09:00
|
|
|
public HeadNote Head { get; private set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-05-24 21:57:38 +09:00
|
|
|
/// <summary>
|
|
|
|
/// The tail note of the hold.
|
|
|
|
/// </summary>
|
2020-04-21 16:33:19 +09:00
|
|
|
public TailNote Tail { get; private set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2023-01-19 20:53:35 +09:00
|
|
|
public override double MaximumJudgementOffset => Tail.MaximumJudgementOffset;
|
|
|
|
|
2017-05-09 20:55:20 +09:00
|
|
|
/// <summary>
|
2017-05-24 21:57:38 +09:00
|
|
|
/// The time between ticks of this hold.
|
2017-05-09 20:55:20 +09:00
|
|
|
/// </summary>
|
2017-05-24 20:45:01 +09:00
|
|
|
private double tickSpacing = 50;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2021-10-01 14:56:42 +09:00
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
2017-05-24 21:24:33 +09:00
|
|
|
{
|
2017-12-22 21:42:54 +09:00
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-05-24 21:24:33 +09:00
|
|
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
|
|
|
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2020-05-15 18:07:41 +09:00
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
2017-05-03 12:53:45 +09:00
|
|
|
{
|
2020-05-15 18:07:41 +09:00
|
|
|
base.CreateNestedHitObjects(cancellationToken);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2020-05-15 18:17:39 +09:00
|
|
|
createTicks(cancellationToken);
|
2018-08-16 10:45:06 +09:00
|
|
|
|
2021-05-12 16:35:05 +09:00
|
|
|
AddNested(Head = new HeadNote
|
2020-04-21 16:33:19 +09:00
|
|
|
{
|
|
|
|
StartTime = StartTime,
|
|
|
|
Column = Column,
|
2020-08-18 01:40:55 +09:00
|
|
|
Samples = GetNodeSamples(0),
|
2020-04-21 16:33:19 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
AddNested(Tail = new TailNote
|
|
|
|
{
|
|
|
|
StartTime = EndTime,
|
|
|
|
Column = Column,
|
2020-08-18 01:40:55 +09:00
|
|
|
Samples = GetNodeSamples((NodeSamples?.Count - 1) ?? 1),
|
2020-04-21 16:33:19 +09:00
|
|
|
});
|
2017-12-22 21:42:54 +09:00
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2020-05-15 18:17:39 +09:00
|
|
|
private void createTicks(CancellationToken cancellationToken)
|
2017-12-22 21:42:54 +09:00
|
|
|
{
|
2017-05-24 20:45:01 +09:00
|
|
|
if (tickSpacing == 0)
|
2017-12-22 21:42:54 +09:00
|
|
|
return;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2017-05-26 16:28:39 +09:00
|
|
|
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
2017-05-24 20:45:01 +09:00
|
|
|
{
|
2020-05-15 18:17:39 +09:00
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
2017-12-22 21:42:54 +09:00
|
|
|
AddNested(new HoldNoteTick
|
2017-05-24 20:45:01 +09:00
|
|
|
{
|
2017-09-11 14:35:18 +09:00
|
|
|
StartTime = t,
|
|
|
|
Column = Column
|
2017-12-22 21:42:54 +09:00
|
|
|
});
|
2017-05-24 20:45:01 +09:00
|
|
|
}
|
2017-05-03 12:53:45 +09:00
|
|
|
}
|
2018-08-02 16:44:01 +09:00
|
|
|
|
2020-02-23 13:01:30 +09:00
|
|
|
public override Judgement CreateJudgement() => new IgnoreJudgement();
|
2019-09-02 16:10:30 +09:00
|
|
|
|
2019-10-09 19:08:31 +09:00
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2020-04-21 16:33:19 +09:00
|
|
|
|
2020-08-18 01:40:55 +09:00
|
|
|
public IList<HitSampleInfo> GetNodeSamples(int nodeIndex) =>
|
2020-04-21 16:33:19 +09:00
|
|
|
nodeIndex < NodeSamples?.Count ? NodeSamples[nodeIndex] : Samples;
|
2016-09-02 18:44:02 +09:00
|
|
|
}
|
|
|
|
}
|