1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 10:42:55 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs

134 lines
5.0 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
using System.Collections.Generic;
using System.Linq;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Catch.Objects
{
public class JuiceStream : CatchHitObject, IHasCurve
{
/// <summary>
/// Positional distance that results in a duration of one second, before any speed adjustments.
/// </summary>
private const float base_scoring_distance = 100;
public int RepeatCount { get; set; }
public double Velocity;
public double TickDistance;
2019-03-08 18:57:30 +08:00
/// <summary>
/// The length of one span of this <see cref="JuiceStream"/>.
/// </summary>
public double SpanDuration => Duration / this.SpanCount();
2018-04-13 17:19:50 +08:00
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
Velocity = scoringDistance / timingPoint.BeatLength;
TickDistance = scoringDistance / difficulty.SliderTickRate;
}
protected override void CreateNestedHitObjects()
{
base.CreateNestedHitObjects();
2019-06-30 20:58:30 +08:00
var tickSamples = Samples.Select(s => new HitSampleInfo
2019-01-26 15:16:49 +08:00
{
Bank = s.Bank,
Name = @"slidertick",
Volume = s.Volume
}).ToList();
2019-03-08 18:57:30 +08:00
SliderEventDescriptor? lastEvent = null;
2018-04-13 17:19:50 +08:00
2019-03-08 18:57:30 +08:00
foreach (var e in SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset))
2018-04-13 17:19:50 +08:00
{
2019-03-08 18:57:30 +08:00
// generate tiny droplets since the last point
if (lastEvent != null)
2018-04-13 17:19:50 +08:00
{
double sinceLastTick = e.Time - lastEvent.Value.Time;
2018-04-13 17:19:50 +08:00
2019-03-08 18:57:30 +08:00
if (sinceLastTick > 80)
2018-06-13 21:20:34 +08:00
{
2019-03-08 18:57:30 +08:00
double timeBetweenTiny = sinceLastTick;
while (timeBetweenTiny > 100)
timeBetweenTiny /= 2;
2018-06-13 21:20:34 +08:00
2019-03-08 18:57:30 +08:00
for (double t = timeBetweenTiny; t < sinceLastTick; t += timeBetweenTiny)
{
AddNested(new TinyDroplet
{
Samples = tickSamples,
StartTime = t + lastEvent.Value.Time,
2019-03-08 18:57:30 +08:00
X = X + Path.PositionAt(
lastEvent.Value.PathProgress + (t / sinceLastTick) * (e.PathProgress - lastEvent.Value.PathProgress)).X / CatchPlayfield.BASE_WIDTH,
});
}
}
2019-03-08 18:57:30 +08:00
}
2018-04-13 17:19:50 +08:00
// this also includes LegacyLastTick and this is used for TinyDroplet generation above.
// this means that the final segment of TinyDroplets are increasingly mistimed where LegacyLastTickOffset is being applied.
2019-03-08 18:57:30 +08:00
lastEvent = e;
2018-04-13 17:19:50 +08:00
2019-03-08 18:57:30 +08:00
switch (e.Type)
{
case SliderEventType.Tick:
AddNested(new Droplet
2018-04-13 17:19:50 +08:00
{
2019-03-08 18:57:30 +08:00
Samples = tickSamples,
StartTime = e.Time,
2019-03-08 18:57:30 +08:00
X = X + Path.PositionAt(e.PathProgress).X / CatchPlayfield.BASE_WIDTH,
});
break;
2019-04-01 11:44:46 +08:00
2019-03-08 18:57:30 +08:00
case SliderEventType.Head:
case SliderEventType.Tail:
case SliderEventType.Repeat:
AddNested(new Fruit
{
Samples = Samples,
StartTime = e.Time,
2019-03-08 18:57:30 +08:00
X = X + Path.PositionAt(e.PathProgress).X / CatchPlayfield.BASE_WIDTH,
2018-04-13 17:19:50 +08:00
});
break;
2018-04-13 17:19:50 +08:00
}
}
}
2018-11-12 13:07:48 +08:00
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
2018-04-13 17:19:50 +08:00
public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH;
public double Duration => EndTime - StartTime;
private SliderPath path;
2018-04-13 17:19:50 +08:00
public SliderPath Path
2018-04-13 17:19:50 +08:00
{
get => path;
set => path = value;
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
2019-06-30 20:58:30 +08:00
public List<List<HitSampleInfo>> NodeSamples { get; set; } = new List<List<HitSampleInfo>>();
2018-06-13 21:20:34 +08:00
public double? LegacyLastTickOffset { get; set; }
2018-04-13 17:19:50 +08:00
}
}