1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Rename to IHasDuration

This commit is contained in:
Dean Herbert 2020-05-27 12:38:39 +09:00
parent b8e0a6f127
commit cbd563e80b
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
}.Yield();
case IHasEndTime endTime:
case IHasDuration endTime:
return new BananaShower
{
StartTime = obj.StartTime,

View File

@ -7,7 +7,7 @@ using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Catch.Objects
{
public class BananaShower : CatchHitObject, IHasEndTime
public class BananaShower : CatchHitObject, IHasDuration
{
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>())
{
if (!(obj.HitObject is IHasEndTime endTime))
if (!(obj.HitObject is IHasDuration endTime))
continue;
foreach (var nested in obj.NestedHitObjects)

View File

@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
}
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)
TargetColumns = 7;
else if (percentSliderOrSpinner < 0.3 || roundedCircleSize >= 5)
@ -175,7 +175,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
break;
}
case IHasEndTime endTimeData:
case IHasDuration endTimeData:
{
conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
@ -231,7 +231,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
var pattern = new Pattern();
if (HitObject is IHasEndTime endTimeData)
if (HitObject is IHasDuration endTimeData)
{
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)
: base(random, hitObject, beatmap, new Pattern(), originalBeatmap)
{
endTime = (HitObject as IHasEndTime)?.EndTime ?? 0;
endTime = (HitObject as IHasDuration)?.EndTime ?? 0;
}
public override IEnumerable<Pattern> Generate()

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Objects
/// <summary>
/// Represents a hit object which requires pressing, holding, and releasing a key.
/// </summary>
public class HoldNote : ManiaHitObject, IHasEndTime
public class HoldNote : ManiaHitObject, IHasDuration
{
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
}.Yield();
case IHasEndTime endTimeData:
case IHasDuration endTimeData:
return new Spinner
{
StartTime = original.StartTime,

View File

@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Mods
break;
// 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;
switch (h)

View File

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

View File

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

View File

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

View File

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

View File

@ -281,7 +281,7 @@ namespace osu.Game.Tests.Visual.Gameplay
yield return new TestHitObject
{
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
private class TestHitObject : ConvertHitObject, IHasEndTime
private class TestHitObject : ConvertHitObject, IHasDuration
{
public double EndTime => StartTime + Duration;

View File

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

View File

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

View File

@ -175,10 +175,10 @@ namespace osu.Game.Rulesets.Objects
/// Returns the end time of this object.
/// </summary>
/// <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>
/// <param name="hitObject">The object.</param>
/// <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>
/// Legacy osu!catch Spinner-type, used for parsing Beatmaps.
/// </summary>
internal sealed class ConvertSpinner : ConvertHitObject, IHasEndTime, IHasXPosition, IHasCombo
internal sealed class ConvertSpinner : ConvertHitObject, IHasDuration, IHasXPosition, IHasCombo
{
public double EndTime => StartTime + Duration;

View File

@ -5,7 +5,7 @@ using osu.Game.Rulesets.Objects.Types;
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; }

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary>
/// A HitObject that has a positional length.
/// </summary>
public interface IHasDistance : IHasEndTime
public interface IHasDistance : IHasDuration
{
/// <summary>
/// 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.
using Newtonsoft.Json;
using System;
namespace osu.Game.Rulesets.Objects.Types
{
/// <summary>
/// A HitObject that ends at a different time than its start time.
/// </summary>
public interface IHasEndTime
[Obsolete("Use IHasDuration instead.")] // can be removed 20201126
public interface IHasEndTime : 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

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary>
/// A HitObject that spans some length.
/// </summary>
public interface IHasRepeats : IHasEndTime
public interface IHasRepeats : IHasDuration
{
/// <summary>
/// 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
private void computeInitialStateRecursive(DrawableHitObject hitObject) => hitObject.Schedule(() =>
{
if (hitObject.HitObject is IHasEndTime e)
if (hitObject.HitObject is IHasDuration e)
{
switch (direction.Value)
{

View File

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