2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-02 09:35:49 +00:00
|
|
|
|
|
2016-12-06 12:14:38 +00:00
|
|
|
|
using OpenTK;
|
2017-02-15 09:48:29 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-02-12 19:38:05 +00:00
|
|
|
|
using osu.Game.Beatmaps.Samples;
|
2017-02-15 17:55:49 +00:00
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
2017-02-15 09:48:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-09-02 09:35:49 +00:00
|
|
|
|
|
2016-11-14 09:54:24 +00:00
|
|
|
|
namespace osu.Game.Modes.Osu.Objects
|
2016-09-02 09:35:49 +00:00
|
|
|
|
{
|
2016-11-19 10:07:57 +00:00
|
|
|
|
public class Slider : OsuHitObject
|
2016-09-02 09:35:49 +00:00
|
|
|
|
{
|
2016-11-28 09:45:50 +00:00
|
|
|
|
public override double EndTime => StartTime + RepeatCount * Curve.Length / Velocity;
|
2016-11-28 06:31:54 +00:00
|
|
|
|
|
2016-12-06 12:14:38 +00:00
|
|
|
|
public override Vector2 EndPosition => RepeatCount % 2 == 0 ? Position : Curve.PositionAt(1);
|
|
|
|
|
|
2017-02-09 07:29:21 +00:00
|
|
|
|
private int stackHeight;
|
|
|
|
|
public override int StackHeight
|
|
|
|
|
{
|
|
|
|
|
get { return stackHeight; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
stackHeight = value;
|
2017-02-14 09:40:37 +00:00
|
|
|
|
Curve.Offset = StackOffset;
|
2017-02-09 07:29:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-14 09:40:37 +00:00
|
|
|
|
public List<Vector2> ControlPoints
|
|
|
|
|
{
|
|
|
|
|
get { return Curve.ControlPoints; }
|
|
|
|
|
set { Curve.ControlPoints = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double Length
|
|
|
|
|
{
|
|
|
|
|
get { return Curve.Length; }
|
|
|
|
|
set { Curve.Length = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CurveTypes CurveType
|
|
|
|
|
{
|
|
|
|
|
get { return Curve.CurveType; }
|
|
|
|
|
set { Curve.CurveType = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 09:45:50 +00:00
|
|
|
|
public double Velocity;
|
2017-02-12 19:38:05 +00:00
|
|
|
|
public double TickDistance;
|
2016-11-28 09:45:50 +00:00
|
|
|
|
|
|
|
|
|
public override void SetDefaultsFromBeatmap(Beatmap beatmap)
|
|
|
|
|
{
|
2016-12-11 09:11:22 +00:00
|
|
|
|
base.SetDefaultsFromBeatmap(beatmap);
|
|
|
|
|
|
2017-02-12 19:38:05 +00:00
|
|
|
|
var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
|
|
|
|
|
2017-02-15 17:55:49 +00:00
|
|
|
|
ControlPoint overridePoint;
|
|
|
|
|
ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint);
|
|
|
|
|
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
|
2017-02-18 06:54:16 +00:00
|
|
|
|
var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment;
|
2017-02-12 19:38:05 +00:00
|
|
|
|
|
2017-02-18 06:54:16 +00:00
|
|
|
|
Velocity = baseVelocity / timingPoint.BeatLength;
|
|
|
|
|
TickDistance = baseVelocity / baseDifficulty.SliderTickRate;
|
2016-11-28 09:45:50 +00:00
|
|
|
|
}
|
2016-09-02 09:35:49 +00:00
|
|
|
|
|
2017-02-14 02:15:40 +00:00
|
|
|
|
public int RepeatCount = 1;
|
2016-11-17 12:29:35 +00:00
|
|
|
|
|
2017-02-14 09:40:37 +00:00
|
|
|
|
internal readonly SliderCurve Curve = new SliderCurve();
|
2017-02-12 19:38:05 +00:00
|
|
|
|
|
|
|
|
|
public IEnumerable<SliderTick> Ticks
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-02-16 04:20:30 +00:00
|
|
|
|
if (TickDistance == 0) yield break;
|
|
|
|
|
|
2017-02-12 19:38:05 +00:00
|
|
|
|
var length = Curve.Length;
|
|
|
|
|
var tickDistance = Math.Min(TickDistance, length);
|
|
|
|
|
var repeatDuration = length / Velocity;
|
|
|
|
|
|
|
|
|
|
var minDistanceFromEnd = Velocity * 0.01;
|
|
|
|
|
|
|
|
|
|
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
|
|
|
|
{
|
|
|
|
|
var repeatStartTime = StartTime + repeat * repeatDuration;
|
|
|
|
|
var reversed = repeat % 2 == 1;
|
|
|
|
|
|
|
|
|
|
for (var d = tickDistance; d <= length; d += tickDistance)
|
|
|
|
|
{
|
|
|
|
|
if (d > length - minDistanceFromEnd)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
var distanceProgress = d / length;
|
|
|
|
|
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
|
|
|
|
|
|
|
|
|
yield return new SliderTick
|
|
|
|
|
{
|
|
|
|
|
RepeatIndex = repeat,
|
|
|
|
|
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
2017-02-16 08:02:36 +00:00
|
|
|
|
Position = Curve.PositionAt(distanceProgress),
|
2017-02-12 19:38:05 +00:00
|
|
|
|
StackHeight = StackHeight,
|
|
|
|
|
Scale = Scale,
|
|
|
|
|
Colour = Colour,
|
|
|
|
|
Sample = new HitSampleInfo
|
|
|
|
|
{
|
|
|
|
|
Type = SampleType.None,
|
|
|
|
|
Set = SampleSet.Soft,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-19 16:41:51 +00:00
|
|
|
|
|
|
|
|
|
public override HitObjectType Type => HitObjectType.Slider;
|
2016-09-02 09:35:49 +00:00
|
|
|
|
}
|
2016-11-17 12:29:35 +00:00
|
|
|
|
|
|
|
|
|
public enum CurveTypes
|
|
|
|
|
{
|
|
|
|
|
Catmull,
|
|
|
|
|
Bezier,
|
|
|
|
|
Linear,
|
|
|
|
|
PerfectCurve
|
2016-11-28 03:15:25 +00:00
|
|
|
|
}
|
2016-09-02 09:35:49 +00:00
|
|
|
|
}
|