1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 05:42:55 +08:00
osu-lazer/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs

65 lines
2.2 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
using Newtonsoft.Json;
2023-04-26 00:12:53 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Objects.Legacy
{
internal abstract class ConvertSlider : ConvertHitObject, IHasPathWithRepeats, IHasSliderVelocity
2018-04-13 17:19:50 +08:00
{
/// <summary>
/// Scoring distance with a speed-adjusted beat length of 1 second.
/// </summary>
private const float base_scoring_distance = 100;
/// <summary>
/// <see cref="ConvertSlider"/>s don't need a curve since they're converted to ruleset-specific hitobjects.
/// </summary>
2023-10-17 16:48:51 +08:00
public SliderPath Path { get; set; } = null!;
2018-04-13 17:19:50 +08:00
2018-11-12 13:07:48 +08:00
public double Distance => Path.Distance;
2018-04-13 17:19:50 +08:00
2023-10-17 16:48:51 +08:00
public IList<IList<HitSampleInfo>> NodeSamples { get; set; } = null!;
2018-04-13 17:19:50 +08:00
public int RepeatCount { get; set; }
[JsonIgnore]
2020-05-27 11:37:44 +08:00
public double Duration
2020-02-05 16:12:26 +08:00
{
2020-05-27 11:37:44 +08:00
get => this.SpanCount() * Distance / Velocity;
2020-02-06 12:16:32 +08:00
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
2020-02-05 16:12:26 +08:00
}
2020-05-27 11:37:44 +08:00
public double EndTime => StartTime + Duration;
2018-04-13 17:19:50 +08:00
public double Velocity = 1;
public BindableNumber<double> SliderVelocityMultiplierBindable { get; } = new BindableDouble(1);
2023-04-26 00:12:53 +08:00
public double SliderVelocityMultiplier
2023-04-26 00:12:53 +08:00
{
get => SliderVelocityMultiplierBindable.Value;
set => SliderVelocityMultiplierBindable.Value = value;
2023-04-26 00:12:53 +08:00
}
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
2018-04-13 17:19:50 +08:00
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier * SliderVelocityMultiplier;
2018-04-13 17:19:50 +08:00
Velocity = scoringDistance / timingPoint.BeatLength;
}
}
}