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
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-04-21 15:33:19 +08:00
|
|
|
using System.Collections.Generic;
|
2020-05-15 17:07:41 +08:00
|
|
|
using System.Threading;
|
2020-04-21 15:33:19 +08:00
|
|
|
using osu.Game.Audio;
|
2018-08-02 15:44:01 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
2017-05-03 11:53:45 +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
|
|
|
|
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>
|
2020-05-27 11:38:39 +08:00
|
|
|
public class HoldNote : ManiaHitObject, IHasDuration
|
2016-09-02 17:44:02 +08:00
|
|
|
{
|
2020-02-05 16:12:26 +08:00
|
|
|
public double EndTime
|
|
|
|
{
|
|
|
|
get => StartTime + Duration;
|
|
|
|
set => Duration = value - StartTime;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-05-26 14:53:49 +08:00
|
|
|
private double duration;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2017-05-26 14:53:49 +08:00
|
|
|
public double Duration
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => duration;
|
2017-05-26 14:53:49 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
duration = value;
|
2020-04-21 15:33:19 +08:00
|
|
|
|
|
|
|
if (Tail != null)
|
|
|
|
Tail.StartTime = EndTime;
|
2017-05-26 14:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-05-26 14:53:49 +08:00
|
|
|
public override double StartTime
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => base.StartTime;
|
2017-05-26 14:53:49 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
base.StartTime = value;
|
2020-04-21 15:33:19 +08:00
|
|
|
|
|
|
|
if (Head != null)
|
|
|
|
Head.StartTime = value;
|
|
|
|
|
|
|
|
if (Tail != null)
|
|
|
|
Tail.StartTime = EndTime;
|
2017-05-26 14:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-11 12:44:39 +08:00
|
|
|
public override int Column
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => base.Column;
|
2017-09-11 12:44:39 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
base.Column = value;
|
2020-04-21 15:33:19 +08:00
|
|
|
|
|
|
|
if (Head != null)
|
|
|
|
Head.Column = value;
|
|
|
|
|
|
|
|
if (Tail != null)
|
|
|
|
Tail.Column = value;
|
2017-09-11 12:44:39 +08:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-10-23 16:59:07 +08:00
|
|
|
public IList<IList<HitSampleInfo>> NodeSamples { get; set; }
|
2020-04-21 15:33:19 +08:00
|
|
|
|
2017-05-24 20:57:38 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The head note of the hold.
|
|
|
|
/// </summary>
|
2024-07-01 19:34:33 +08:00
|
|
|
public HeadNote Head { get; protected set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-05-24 20:57:38 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The tail note of the hold.
|
|
|
|
/// </summary>
|
2024-07-01 19:34:33 +08:00
|
|
|
public TailNote Tail { get; protected set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2023-10-09 08:47:00 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The body of the hold.
|
|
|
|
/// This is an invisible and silent object that tracks the holding state of the <see cref="HoldNote"/>.
|
|
|
|
/// </summary>
|
2024-07-01 19:34:33 +08:00
|
|
|
public HoldNoteBody Body { get; protected set; }
|
2023-10-09 08:47:00 +08:00
|
|
|
|
2023-01-19 19:53:35 +08:00
|
|
|
public override double MaximumJudgementOffset => Tail.MaximumJudgementOffset;
|
|
|
|
|
2020-05-15 17:07:41 +08:00
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
2017-05-03 11:53:45 +08:00
|
|
|
{
|
2020-05-15 17:07:41 +08:00
|
|
|
base.CreateNestedHitObjects(cancellationToken);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-05-12 15:35:05 +08:00
|
|
|
AddNested(Head = new HeadNote
|
2020-04-21 15:33:19 +08:00
|
|
|
{
|
|
|
|
StartTime = StartTime,
|
|
|
|
Column = Column,
|
2020-08-18 00:40:55 +08:00
|
|
|
Samples = GetNodeSamples(0),
|
2020-04-21 15:33:19 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddNested(Tail = new TailNote
|
|
|
|
{
|
|
|
|
StartTime = EndTime,
|
|
|
|
Column = Column,
|
2020-08-18 00:40:55 +08:00
|
|
|
Samples = GetNodeSamples((NodeSamples?.Count - 1) ?? 1),
|
2020-04-21 15:33:19 +08:00
|
|
|
});
|
2023-10-09 08:47:00 +08:00
|
|
|
|
|
|
|
AddNested(Body = new HoldNoteBody
|
|
|
|
{
|
|
|
|
StartTime = StartTime,
|
|
|
|
Column = Column
|
|
|
|
});
|
2017-12-22 20:42:54 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-02-23 12:01:30 +08:00
|
|
|
public override Judgement CreateJudgement() => new IgnoreJudgement();
|
2019-09-02 15:10:30 +08:00
|
|
|
|
2019-10-09 18:08:31 +08:00
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2020-04-21 15:33:19 +08:00
|
|
|
|
2020-08-18 00:40:55 +08:00
|
|
|
public IList<HitSampleInfo> GetNodeSamples(int nodeIndex) =>
|
2020-04-21 15:33:19 +08:00
|
|
|
nodeIndex < NodeSamples?.Count ? NodeSamples[nodeIndex] : Samples;
|
2016-09-02 17:44:02 +08:00
|
|
|
}
|
|
|
|
}
|