From c2d3b6c05ad5c8dfacb6d47fdceed144409ef16e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 15:53:49 +0900 Subject: [PATCH] Remove late initialization of head + tail, keep them updated with start time and end time. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 29 +++++++++++++++++---- osu.Game/Rulesets/Objects/HitObject.cs | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index db317ddf7b..5069b4f623 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -13,20 +13,39 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class HoldNote : ManiaHitObject, IHasEndTime { - public double Duration { get; set; } public double EndTime => StartTime + Duration; - private Note head; + 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; + } + } + /// /// The head note of the hold. /// - public Note Head => head ?? (head = new Note { StartTime = StartTime }); + public Note Head = new Note(); - private Note tail; /// /// The tail note of the hold. /// - public Note Tail => tail ?? (tail = new TailNote { StartTime = EndTime }); + public Note Tail = new TailNote(); /// /// The time between ticks of this hold. diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index 5592681cab..b282965db8 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -19,7 +19,7 @@ public class HitObject /// /// The time at which the HitObject starts. /// - public double StartTime; + public virtual double StartTime { get; set; } /// /// The samples to be played when this hit object is hit.