Remove late initialization of head + tail, keep them updated with start time and end time.

This commit is contained in:
smoogipooo
2017-05-26 15:53:49 +09:00
parent 40e63a0870
commit c2d3b6c05a
2 changed files with 25 additions and 6 deletions

View File

@ -13,20 +13,39 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
public class HoldNote : ManiaHitObject, IHasEndTime public class HoldNote : ManiaHitObject, IHasEndTime
{ {
public double Duration { get; set; }
public double EndTime => StartTime + Duration; 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;
}
}
/// <summary> /// <summary>
/// The head note of the hold. /// The head note of the hold.
/// </summary> /// </summary>
public Note Head => head ?? (head = new Note { StartTime = StartTime }); public Note Head = new Note();
private Note tail;
/// <summary> /// <summary>
/// The tail note of the hold. /// The tail note of the hold.
/// </summary> /// </summary>
public Note Tail => tail ?? (tail = new TailNote { StartTime = EndTime }); public Note Tail = new TailNote();
/// <summary> /// <summary>
/// The time between ticks of this hold. /// The time between ticks of this hold.

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Objects
/// <summary> /// <summary>
/// The time at which the HitObject starts. /// The time at which the HitObject starts.
/// </summary> /// </summary>
public double StartTime; public virtual double StartTime { get; set; }
/// <summary> /// <summary>
/// The samples to be played when this hit object is hit. /// The samples to be played when this hit object is hit.