mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:35:10 +08:00
Merge pull request #9123 from peppy/move-setter-to-duration
Move setter from EndTime to Duration
This commit is contained in:
commit
a8b137bb71
@ -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,
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -115,15 +115,15 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
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 EndTime => StartTime + Duration;
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
|
||||||
|
|
||||||
private readonly SliderPath path = new SliderPath();
|
private readonly SliderPath path = new SliderPath();
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -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()
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -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,
|
||||||
|
@ -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)
|
||||||
|
@ -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);
|
||||||
|
@ -19,14 +19,14 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
public class Slider : OsuHitObject, IHasPathWithRepeats
|
public class Slider : OsuHitObject, IHasPathWithRepeats
|
||||||
{
|
{
|
||||||
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.
|
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>();
|
private readonly Cached<Vector2> endPositionCache = new Cached<Vector2>();
|
||||||
|
|
||||||
public override Vector2 EndPosition => endPositionCache.IsValid ? endPositionCache.Value : endPositionCache.Value = Position + this.CurvePositionAt(1);
|
public override Vector2 EndPosition => endPositionCache.IsValid ? endPositionCache.Value : endPositionCache.Value = Position + this.CurvePositionAt(1);
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
|
|
||||||
case ArmedState.Miss:
|
case ArmedState.Miss:
|
||||||
case ArmedState.Hit:
|
case ArmedState.Hit:
|
||||||
using (BeginAbsoluteSequence(Time.Current, true))
|
using (BeginDelayedSequence(HitObject.Duration, true))
|
||||||
{
|
{
|
||||||
this.FadeOut(transition_duration, Easing.Out);
|
this.FadeOut(transition_duration, Easing.Out);
|
||||||
bodyContainer.ScaleTo(1.4f, transition_duration);
|
bodyContainer.ScaleTo(1.4f, transition_duration);
|
||||||
|
@ -10,7 +10,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
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
yield return new TestHitObject
|
yield return new TestHitObject
|
||||||
{
|
{
|
||||||
StartTime = original.StartTime,
|
StartTime = original.StartTime,
|
||||||
EndTime = (original as IHasEndTime)?.EndTime ?? (original.StartTime + 100)
|
Duration = (original as IHasDuration)?.Duration ?? 100
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,11 +290,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
#region HitObject
|
#region HitObject
|
||||||
|
|
||||||
private class TestHitObject : ConvertHitObject, IHasEndTime
|
private class TestHitObject : ConvertHitObject, IHasDuration
|
||||||
{
|
{
|
||||||
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>
|
private class DrawableTestHitObject : DrawableHitObject<TestHitObject>
|
||||||
|
@ -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 = ',';
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// 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
|
// Their combo offset is still added to that next hitobject's combo index
|
||||||
@ -65,11 +65,11 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
|
|||||||
|
|
||||||
return new ConvertSpinner
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ 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 { get; set; }
|
public double EndTime => StartTime + Duration;
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
public double Duration { get; set; }
|
||||||
|
|
||||||
public float X => 256; // Required for CatchBeatmapConverter
|
public float X => 256; // Required for CatchBeatmapConverter
|
||||||
|
|
||||||
|
@ -189,9 +189,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
}
|
}
|
||||||
else if (type.HasFlag(LegacyHitObjectType.Spinner))
|
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)
|
if (split.Length > 6)
|
||||||
readCustomSampleBanks(split[6], bankInfo);
|
readCustomSampleBanks(split[6], bankInfo);
|
||||||
@ -209,7 +209,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo);
|
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)
|
if (result == null)
|
||||||
@ -321,9 +321,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
/// <param name="position">The position of the hit object.</param>
|
/// <param name="position">The position of the hit object.</param>
|
||||||
/// <param name="newCombo">Whether the hit object creates a new combo.</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="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>
|
/// <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>
|
/// <summary>
|
||||||
/// Creates a legacy Hold-type hit object.
|
/// Creates a legacy Hold-type hit object.
|
||||||
@ -331,8 +331,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
/// <param name="position">The position of the hit object.</param>
|
/// <param name="position">The position of the hit object.</param>
|
||||||
/// <param name="newCombo">Whether the hit object creates a new combo.</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="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>
|
/// <param name="duration">The hold duration.</param>
|
||||||
protected abstract HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double endTime);
|
protected abstract HitObject CreateHold(Vector2 position, bool newCombo, int comboOffset, double duration);
|
||||||
|
|
||||||
private List<HitSampleInfo> convertSoundType(LegacyHitSoundType type, SampleBankInfo bankInfo)
|
private List<HitSampleInfo> convertSoundType(LegacyHitSoundType type, SampleBankInfo bankInfo)
|
||||||
{
|
{
|
||||||
|
@ -29,13 +29,13 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
public List<IList<HitSampleInfo>> NodeSamples { get; set; }
|
public List<IList<HitSampleInfo>> NodeSamples { get; set; }
|
||||||
public int RepeatCount { 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.
|
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;
|
public double Velocity = 1;
|
||||||
|
|
||||||
|
@ -37,21 +37,21 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
return new ConvertSpinner
|
||||||
{
|
{
|
||||||
X = position.X,
|
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
|
return new ConvertHold
|
||||||
{
|
{
|
||||||
X = position.X,
|
X = position.X,
|
||||||
EndTime = endTime
|
Duration = duration
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ 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; }
|
||||||
|
|
||||||
public double EndTime { get; set; }
|
public double Duration { get; set; }
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
public double EndTime => StartTime + Duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ 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 EndTime { get; set; }
|
public double Duration { get; set; }
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
public double EndTime => StartTime + Duration;
|
||||||
|
|
||||||
public float X { get; set; }
|
public float X { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// 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
|
// Their combo offset is still added to that next hitobject's combo index
|
||||||
@ -66,11 +66,11 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
|
|||||||
return new ConvertSpinner
|
return new ConvertSpinner
|
||||||
{
|
{
|
||||||
Position = position,
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ 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 EndTime { get; set; }
|
public double Duration { get; set; }
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
public double EndTime => StartTime + Duration;
|
||||||
|
|
||||||
public Vector2 Position { get; set; }
|
public Vector2 Position { get; set; }
|
||||||
|
|
||||||
|
@ -33,15 +33,15 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ 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 EndTime { get; set; }
|
public double Duration { get; set; }
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
public double EndTime => StartTime + Duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
34
osu.Game/Rulesets/Objects/Types/IHasDuration.cs
Normal file
34
osu.Game/Rulesets/Objects/Types/IHasDuration.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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>
|
||||||
|
#pragma warning disable 618
|
||||||
|
public interface IHasDuration : IHasEndTime
|
||||||
|
#pragma warning restore 618
|
||||||
|
{
|
||||||
|
double IHasEndTime.EndTime
|
||||||
|
{
|
||||||
|
get => EndTime;
|
||||||
|
set => Duration = (Duration - EndTime) + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double IHasEndTime.Duration => Duration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time at which the HitObject ends.
|
||||||
|
/// </summary>
|
||||||
|
new double EndTime { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The duration of the HitObject.
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
new double Duration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
// 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 System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Types
|
namespace osu.Game.Rulesets.Objects.Types
|
||||||
@ -8,6 +9,7 @@ namespace osu.Game.Rulesets.Objects.Types
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A HitObject that ends at a different time than its start time.
|
/// A HitObject that ends at a different time than its start time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("Use IHasDuration instead.")] // can be removed 20201126
|
||||||
public interface IHasEndTime
|
public interface IHasEndTime
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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.
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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,13 +290,13 @@ 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)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
endTimeHitObject.EndTime = snappedTime;
|
endTimeHitObject.Duration = snappedTime - hitObject.StartTime;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user