1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Rename to IHasDuration

This commit is contained in:
Dean Herbert 2020-05-27 12:38:39 +09:00
parent 534dccc0c3
commit dd7dbfd548
27 changed files with 60 additions and 48 deletions

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0 LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0
}.Yield(); }.Yield();
case IHasEndTime endTime: case IHasDuration endTime:
return new BananaShower return new BananaShower
{ {
StartTime = obj.StartTime, StartTime = obj.StartTime,

View File

@ -7,7 +7,7 @@ using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Catch.Objects namespace osu.Game.Rulesets.Catch.Objects
{ {
public class BananaShower : CatchHitObject, IHasEndTime public class BananaShower : CatchHitObject, IHasDuration
{ {
public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana; public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana;

View File

@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Mania.Tests
foreach (var obj in content.OfType<DrawableHitObject>()) foreach (var obj in content.OfType<DrawableHitObject>())
{ {
if (!(obj.HitObject is IHasEndTime endTime)) if (!(obj.HitObject is IHasDuration endTime))
continue; continue;
foreach (var nested in obj.NestedHitObjects) foreach (var nested in obj.NestedHitObjects)

View File

@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
} }
else else
{ {
float percentSliderOrSpinner = (float)beatmap.HitObjects.Count(h => h is IHasEndTime) / beatmap.HitObjects.Count; float percentSliderOrSpinner = (float)beatmap.HitObjects.Count(h => h is IHasDuration) / beatmap.HitObjects.Count;
if (percentSliderOrSpinner < 0.2) if (percentSliderOrSpinner < 0.2)
TargetColumns = 7; TargetColumns = 7;
else if (percentSliderOrSpinner < 0.3 || roundedCircleSize >= 5) else if (percentSliderOrSpinner < 0.3 || roundedCircleSize >= 5)
@ -175,7 +175,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
break; break;
} }
case IHasEndTime endTimeData: case IHasDuration endTimeData:
{ {
conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap); conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
@ -231,7 +231,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
var pattern = new Pattern(); var pattern = new Pattern();
if (HitObject is IHasEndTime endTimeData) if (HitObject is IHasDuration endTimeData)
{ {
pattern.Add(new HoldNote pattern.Add(new HoldNote
{ {

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
public EndTimeObjectPatternGenerator(FastRandom random, HitObject hitObject, ManiaBeatmap beatmap, IBeatmap originalBeatmap) public EndTimeObjectPatternGenerator(FastRandom random, HitObject hitObject, ManiaBeatmap beatmap, IBeatmap originalBeatmap)
: base(random, hitObject, beatmap, new Pattern(), originalBeatmap) : base(random, hitObject, beatmap, new Pattern(), originalBeatmap)
{ {
endTime = (HitObject as IHasEndTime)?.EndTime ?? 0; endTime = (HitObject as IHasDuration)?.EndTime ?? 0;
} }
public override IEnumerable<Pattern> Generate() public override IEnumerable<Pattern> Generate()

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Objects
/// <summary> /// <summary>
/// Represents a hit object which requires pressing, holding, and releasing a key. /// Represents a hit object which requires pressing, holding, and releasing a key.
/// </summary> /// </summary>
public class HoldNote : ManiaHitObject, IHasEndTime public class HoldNote : ManiaHitObject, IHasDuration
{ {
public double EndTime public double EndTime
{ {

View File

@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
TickDistanceMultiplier = beatmap.BeatmapInfo.BeatmapVersion < 8 ? 1f / beatmap.ControlPointInfo.DifficultyPointAt(original.StartTime).SpeedMultiplier : 1 TickDistanceMultiplier = beatmap.BeatmapInfo.BeatmapVersion < 8 ? 1f / beatmap.ControlPointInfo.DifficultyPointAt(original.StartTime).SpeedMultiplier : 1
}.Yield(); }.Yield();
case IHasEndTime endTimeData: case IHasDuration endTimeData:
return new Spinner return new Spinner
{ {
StartTime = original.StartTime, StartTime = original.StartTime,

View File

@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Mods
break; break;
// already hit or beyond the hittable end time. // already hit or beyond the hittable end time.
if (h.IsHit || (h.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime)) if (h.IsHit || (h.HitObject is IHasDuration hasEnd && time > hasEnd.EndTime))
continue; continue;
switch (h) switch (h)

View File

@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Mods
} }
// Keep wiggling sliders and spinners for their duration // Keep wiggling sliders and spinners for their duration
if (!(osuObject is IHasEndTime endTime)) if (!(osuObject is IHasDuration endTime))
return; return;
amountWiggles = (int)(endTime.Duration / wiggle_duration); amountWiggles = (int)(endTime.Duration / wiggle_duration);

View File

@ -11,7 +11,7 @@ using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
public class Spinner : OsuHitObject, IHasEndTime public class Spinner : OsuHitObject, IHasDuration
{ {
public double EndTime public double EndTime
{ {

View File

@ -150,7 +150,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
break; break;
} }
case IHasEndTime endTimeData: case IHasDuration endTimeData:
{ {
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier; double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;

View File

@ -9,7 +9,7 @@ using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects namespace osu.Game.Rulesets.Taiko.Objects
{ {
public class Swell : TaikoHitObject, IHasEndTime public class Swell : TaikoHitObject, IHasDuration
{ {
public double EndTime public double EndTime
{ {

View File

@ -281,7 +281,7 @@ namespace osu.Game.Tests.Visual.Gameplay
yield return new TestHitObject yield return new TestHitObject
{ {
StartTime = original.StartTime, StartTime = original.StartTime,
Duration = (original as IHasEndTime)?.Duration ?? 100 Duration = (original as IHasDuration)?.Duration ?? 100
}; };
} }
} }
@ -290,7 +290,7 @@ namespace osu.Game.Tests.Visual.Gameplay
#region HitObject #region HitObject
private class TestHitObject : ConvertHitObject, IHasEndTime private class TestHitObject : ConvertHitObject, IHasDuration
{ {
public double EndTime => StartTime + Duration; public double EndTime => StartTime + Duration;

View File

@ -240,7 +240,7 @@ namespace osu.Game.Beatmaps.Formats
} }
else else
{ {
if (hitObject is IHasEndTime) if (hitObject is IHasDuration)
addEndTimeData(writer, hitObject); addEndTimeData(writer, hitObject);
writer.Write(getSampleBank(hitObject.Samples)); writer.Write(getSampleBank(hitObject.Samples));
@ -267,7 +267,7 @@ namespace osu.Game.Beatmaps.Formats
type |= LegacyHitObjectType.Slider; type |= LegacyHitObjectType.Slider;
break; break;
case IHasEndTime _: case IHasDuration _:
if (beatmap.BeatmapInfo.RulesetID == 3) if (beatmap.BeatmapInfo.RulesetID == 3)
type |= LegacyHitObjectType.Hold; type |= LegacyHitObjectType.Hold;
else else
@ -352,7 +352,7 @@ namespace osu.Game.Beatmaps.Formats
private void addEndTimeData(TextWriter writer, HitObject hitObject) private void addEndTimeData(TextWriter writer, HitObject hitObject)
{ {
var endTimeData = (IHasEndTime)hitObject; var endTimeData = (IHasDuration)hitObject;
var type = getObjectType(hitObject); var type = getObjectType(hitObject);
char suffix = ','; char suffix = ',';

View File

@ -63,7 +63,7 @@ namespace osu.Game.Beatmaps
length = emptyLength; length = emptyLength;
break; break;
case IHasEndTime endTime: case IHasDuration endTime:
length = endTime.EndTime + excess_length; length = endTime.EndTime + excess_length;
break; break;

View File

@ -175,10 +175,10 @@ namespace osu.Game.Rulesets.Objects
/// Returns the end time of this object. /// Returns the end time of this object.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This returns the <see cref="IHasEndTime.EndTime"/> where available, falling back to <see cref="HitObject.StartTime"/> otherwise. /// This returns the <see cref="IHasDuration.EndTime"/> where available, falling back to <see cref="HitObject.StartTime"/> otherwise.
/// </remarks> /// </remarks>
/// <param name="hitObject">The object.</param> /// <param name="hitObject">The object.</param>
/// <returns>The end time of this object.</returns> /// <returns>The end time of this object.</returns>
public static double GetEndTime(this HitObject hitObject) => (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime; public static double GetEndTime(this HitObject hitObject) => (hitObject as IHasDuration)?.EndTime ?? hitObject.StartTime;
} }
} }

View File

@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
/// <summary> /// <summary>
/// Legacy osu!catch Spinner-type, used for parsing Beatmaps. /// Legacy osu!catch Spinner-type, used for parsing Beatmaps.
/// </summary> /// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasXPosition, IHasCombo internal sealed class ConvertSpinner : ConvertHitObject, IHasDuration, IHasXPosition, IHasCombo
{ {
public double EndTime => StartTime + Duration; public double EndTime => StartTime + Duration;

View File

@ -5,7 +5,7 @@ using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects.Legacy.Mania namespace osu.Game.Rulesets.Objects.Legacy.Mania
{ {
internal sealed class ConvertHold : ConvertHitObject, IHasXPosition, IHasEndTime internal sealed class ConvertHold : ConvertHitObject, IHasXPosition, IHasDuration
{ {
public float X { get; set; } public float X { get; set; }

View File

@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
/// <summary> /// <summary>
/// Legacy osu!mania Spinner-type, used for parsing Beatmaps. /// Legacy osu!mania Spinner-type, used for parsing Beatmaps.
/// </summary> /// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasXPosition internal sealed class ConvertSpinner : ConvertHitObject, IHasDuration, IHasXPosition
{ {
public double Duration { get; set; } public double Duration { get; set; }

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
/// <summary> /// <summary>
/// Legacy osu! Spinner-type, used for parsing Beatmaps. /// Legacy osu! Spinner-type, used for parsing Beatmaps.
/// </summary> /// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasPosition, IHasCombo internal sealed class ConvertSpinner : ConvertHitObject, IHasDuration, IHasPosition, IHasCombo
{ {
public double Duration { get; set; } public double Duration { get; set; }

View File

@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
/// <summary> /// <summary>
/// Legacy osu!taiko Spinner-type, used for parsing Beatmaps. /// Legacy osu!taiko Spinner-type, used for parsing Beatmaps.
/// </summary> /// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime internal sealed class ConvertSpinner : ConvertHitObject, IHasDuration
{ {
public double Duration { get; set; } public double Duration { get; set; }

View File

@ -6,7 +6,7 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary> /// <summary>
/// A HitObject that has a positional length. /// A HitObject that has a positional length.
/// </summary> /// </summary>
public interface IHasDistance : IHasEndTime public interface IHasDistance : IHasDuration
{ {
/// <summary> /// <summary>
/// The positional length of the HitObject. /// The positional length of the HitObject.

View File

@ -0,0 +1,24 @@
// 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.
using Newtonsoft.Json;
namespace osu.Game.Rulesets.Objects.Types
{
/// <summary>
/// A HitObject that ends at a different time than its start time.
/// </summary>
public interface IHasDuration
{
/// <summary>
/// The time at which the HitObject ends.
/// </summary>
double EndTime { get; }
/// <summary>
/// The duration of the HitObject.
/// </summary>
[JsonIgnore]
double Duration { get; set; }
}
}

View File

@ -1,24 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using Newtonsoft.Json; using System;
namespace osu.Game.Rulesets.Objects.Types namespace osu.Game.Rulesets.Objects.Types
{ {
/// <summary> [Obsolete("Use IHasDuration instead.")] // can be removed 20201126
/// A HitObject that ends at a different time than its start time. public interface IHasEndTime : IHasDuration
/// </summary>
public interface IHasEndTime
{ {
/// <summary>
/// The time at which the HitObject ends.
/// </summary>
double EndTime { get; }
/// <summary>
/// The duration of the HitObject.
/// </summary>
[JsonIgnore]
double Duration { get; set; }
} }
} }

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary> /// <summary>
/// A HitObject that spans some length. /// A HitObject that spans some length.
/// </summary> /// </summary>
public interface IHasRepeats : IHasEndTime public interface IHasRepeats : IHasDuration
{ {
/// <summary> /// <summary>
/// The amount of times the HitObject repeats. /// The amount of times the HitObject repeats.

View File

@ -270,7 +270,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
// Cant use AddOnce() since the delegate is re-constructed every invocation // Cant use AddOnce() since the delegate is re-constructed every invocation
private void computeInitialStateRecursive(DrawableHitObject hitObject) => hitObject.Schedule(() => private void computeInitialStateRecursive(DrawableHitObject hitObject) => hitObject.Schedule(() =>
{ {
if (hitObject.HitObject is IHasEndTime e) if (hitObject.HitObject is IHasDuration e)
{ {
switch (direction.Value) switch (direction.Value)
{ {

View File

@ -72,7 +72,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
shadowComponents.Add(circle); shadowComponents.Add(circle);
if (hitObject is IHasEndTime) if (hitObject is IHasDuration)
{ {
DragBar dragBarUnderlay; DragBar dragBarUnderlay;
Container extensionBar; Container extensionBar;
@ -290,7 +290,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
repeatHitObject.RepeatCount = proposedCount; repeatHitObject.RepeatCount = proposedCount;
break; break;
case IHasEndTime endTimeHitObject: case IHasDuration endTimeHitObject:
var snappedTime = Math.Max(hitObject.StartTime, beatSnapProvider.SnapTime(time)); var snappedTime = Math.Max(hitObject.StartTime, beatSnapProvider.SnapTime(time));
if (endTimeHitObject.EndTime == snappedTime) if (endTimeHitObject.EndTime == snappedTime)