Move sett from EndTime to Duration

This commit is contained in:
Dean Herbert 2020-05-27 12:37:44 +09:00
parent ad10a7f0b2
commit b8e0a6f127
17 changed files with 50 additions and 50 deletions

View File

@ -115,15 +115,15 @@ protected override void CreateNestedHitObjects(CancellationToken cancellationTok
}
}
public double EndTime
public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH;
public double Duration
{
get => StartTime + this.SpanCount() * Path.Distance / Velocity;
get => this.SpanCount() * Path.Distance / Velocity;
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
}
public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH;
public double Duration => EndTime - StartTime;
public double EndTime => StartTime + Duration;
private readonly SliderPath path = new SliderPath();

View File

@ -19,14 +19,14 @@ namespace osu.Game.Rulesets.Osu.Objects
{
public class Slider : OsuHitObject, IHasCurve
{
public double EndTime
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
public double Duration
{
get => StartTime + this.SpanCount() * Path.Distance / Velocity;
get => EndTime - StartTime;
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
}
public double Duration => EndTime - StartTime;
private readonly Cached<Vector2> endPositionCache = new Cached<Vector2>();
public override Vector2 EndPosition => endPositionCache.IsValid ? endPositionCache.Value : endPositionCache.Value = Position + this.CurvePositionAt(1);

View File

@ -237,7 +237,7 @@ protected override void UpdateStateTransforms(ArmedState state)
case ArmedState.Miss:
case ArmedState.Hit:
using (BeginAbsoluteSequence(Time.Current, true))
using (BeginDelayedSequence(HitObject.Duration, true))
{
this.FadeOut(transition_duration, Easing.Out);
bodyContainer.ScaleTo(1.4f, transition_duration);

View File

@ -281,7 +281,7 @@ protected override IEnumerable<TestHitObject> ConvertHitObject(HitObject origina
yield return new TestHitObject
{
StartTime = original.StartTime,
EndTime = (original as IHasEndTime)?.EndTime ?? (original.StartTime + 100)
Duration = (original as IHasEndTime)?.Duration ?? 100
};
}
}
@ -292,9 +292,9 @@ protected override IEnumerable<TestHitObject> ConvertHitObject(HitObject origina
private class TestHitObject : ConvertHitObject, IHasEndTime
{
public double EndTime { get; set; }
public double EndTime => StartTime + Duration;
public double Duration => EndTime - StartTime;
public double Duration { get; set; }
}
private class DrawableTestHitObject : DrawableHitObject<TestHitObject>

View File

@ -56,7 +56,7 @@ protected override HitObject CreateSlider(Vector2 position, bool newCombo, int c
};
}
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double duration)
{
// Convert spinners don't create the new combo themselves, but force the next non-spinner hitobject to create a new combo
// Their combo offset is still added to that next hitobject's combo index
@ -65,11 +65,11 @@ protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int
return new ConvertSpinner
{
EndTime = endTime
Duration = duration
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return null;
}

View File

@ -10,9 +10,9 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
/// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasXPosition, IHasCombo
{
public double EndTime { get; set; }
public double EndTime => StartTime + Duration;
public double Duration => EndTime - StartTime;
public double Duration { get; set; }
public float X => 256; // Required for CatchBeatmapConverter

View File

@ -189,9 +189,9 @@ public override HitObject Parse(string text)
}
else if (type.HasFlag(LegacyHitObjectType.Spinner))
{
double endTime = Math.Max(startTime, Parsing.ParseDouble(split[5]) + Offset);
double duration = Math.Max(0, Parsing.ParseDouble(split[5]) + Offset - startTime);
result = CreateSpinner(new Vector2(512, 384) / 2, combo, comboOffset, endTime);
result = CreateSpinner(new Vector2(512, 384) / 2, combo, comboOffset, duration);
if (split.Length > 6)
readCustomSampleBanks(split[6], bankInfo);
@ -209,7 +209,7 @@ public override HitObject Parse(string text)
readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo);
}
result = CreateHold(pos, combo, comboOffset, endTime + Offset);
result = CreateHold(pos, combo, comboOffset, endTime + Offset - startTime);
}
if (result == null)
@ -321,9 +321,9 @@ protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int c
/// <param name="position">The position of the hit object.</param>
/// <param name="newCombo">Whether the hit object creates a new combo.</param>
/// <param name="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</param>
/// <param name="endTime">The spinner end time.</param>
/// <param name="duration">The spinner duration.</param>
/// <returns>The hit object.</returns>
protected abstract HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double endTime);
protected abstract HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double duration);
/// <summary>
/// Creates a legacy Hold-type hit object.
@ -331,8 +331,8 @@ protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int c
/// <param name="position">The position of the hit object.</param>
/// <param name="newCombo">Whether the hit object creates a new combo.</param>
/// <param name="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</param>
/// <param name="endTime">The hold end time.</param>
protected abstract HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double endTime);
/// <param name="duration">The hold end time.</param>
protected abstract HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double duration);
private List<HitSampleInfo> convertSoundType(LegacyHitSoundType type, SampleBankInfo bankInfo)
{

View File

@ -26,13 +26,13 @@ internal abstract class ConvertSlider : ConvertHitObject, IHasCurve, IHasLegacyL
public List<IList<HitSampleInfo>> NodeSamples { get; set; }
public int RepeatCount { get; set; }
public double EndTime
public double Duration
{
get => StartTime + this.SpanCount() * Distance / Velocity;
get => this.SpanCount() * Distance / Velocity;
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
}
public double Duration => EndTime - StartTime;
public double EndTime => StartTime + Duration;
public double Velocity = 1;

View File

@ -37,21 +37,21 @@ protected override HitObject CreateSlider(Vector2 position, bool newCombo, int c
};
}
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return new ConvertSpinner
{
X = position.X,
EndTime = endTime
Duration = duration
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return new ConvertHold
{
X = position.X,
EndTime = endTime
Duration = duration
};
}
}

View File

@ -9,8 +9,8 @@ internal sealed class ConvertHold : ConvertHitObject, IHasXPosition, IHasEndTime
{
public float X { get; set; }
public double EndTime { get; set; }
public double Duration { get; set; }
public double Duration => EndTime - StartTime;
public double EndTime => StartTime + Duration;
}
}

View File

@ -10,9 +10,9 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
/// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasXPosition
{
public double EndTime { get; set; }
public double Duration { get; set; }
public double Duration => EndTime - StartTime;
public double EndTime => StartTime + Duration;
public float X { get; set; }
}

View File

@ -56,7 +56,7 @@ protected override HitObject CreateSlider(Vector2 position, bool newCombo, int c
};
}
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double duration)
{
// Convert spinners don't create the new combo themselves, but force the next non-spinner hitobject to create a new combo
// Their combo offset is still added to that next hitobject's combo index
@ -66,11 +66,11 @@ protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int
return new ConvertSpinner
{
Position = position,
EndTime = endTime
Duration = duration
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return null;
}

View File

@ -11,9 +11,9 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
/// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasPosition, IHasCombo
{
public double EndTime { get; set; }
public double Duration { get; set; }
public double Duration => EndTime - StartTime;
public double EndTime => StartTime + Duration;
public Vector2 Position { get; set; }

View File

@ -33,15 +33,15 @@ protected override HitObject CreateSlider(Vector2 position, bool newCombo, int c
};
}
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return new ConvertSpinner
{
EndTime = endTime
Duration = duration
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double endTime)
protected override HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return null;
}

View File

@ -10,8 +10,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
/// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime
{
public double EndTime { get; set; }
public double Duration { get; set; }
public double Duration => EndTime - StartTime;
public double EndTime => StartTime + Duration;
}
}

View File

@ -13,12 +13,12 @@ public interface IHasEndTime
/// <summary>
/// The time at which the HitObject ends.
/// </summary>
[JsonIgnore]
double EndTime { get; set; }
double EndTime { get; }
/// <summary>
/// The duration of the HitObject.
/// </summary>
double Duration { get; }
[JsonIgnore]
double Duration { get; set; }
}
}

View File

@ -296,7 +296,7 @@ protected override void OnDrag(DragEvent e)
if (endTimeHitObject.EndTime == snappedTime)
return;
endTimeHitObject.EndTime = snappedTime;
endTimeHitObject.Duration = snappedTime - hitObject.StartTime;
break;
}