mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 18:12:56 +08:00
Use pattern matching.
This commit is contained in:
parent
7d7b9e36b2
commit
e5e8e70704
@ -145,8 +145,8 @@ dotnet_style_prefer_compound_assignment = true:warning
|
|||||||
#Style - null/type checks
|
#Style - null/type checks
|
||||||
dotnet_style_coalesce_expression = true:warning
|
dotnet_style_coalesce_expression = true:warning
|
||||||
dotnet_style_null_propagation = true:warning
|
dotnet_style_null_propagation = true:warning
|
||||||
csharp_style_pattern_matching_over_is_with_cast_check = true:silent
|
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
|
||||||
csharp_style_pattern_matching_over_as_with_null_check = true:silent
|
csharp_style_pattern_matching_over_as_with_null_check = true:warning
|
||||||
csharp_style_throw_expression = true:silent
|
csharp_style_throw_expression = true:silent
|
||||||
csharp_style_conditional_delegate_call = true:suggestion
|
csharp_style_conditional_delegate_call = true:suggestion
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using System;
|
|||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Beatmaps
|
namespace osu.Game.Rulesets.Catch.Beatmaps
|
||||||
{
|
{
|
||||||
@ -22,48 +23,44 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
|
|
||||||
protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap)
|
protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
var curveData = obj as IHasCurve;
|
|
||||||
var positionData = obj as IHasXPosition;
|
var positionData = obj as IHasXPosition;
|
||||||
var comboData = obj as IHasCombo;
|
var comboData = obj as IHasCombo;
|
||||||
var endTime = obj as IHasEndTime;
|
|
||||||
var legacyOffset = obj as IHasLegacyLastTickOffset;
|
|
||||||
|
|
||||||
if (curveData != null)
|
switch (obj)
|
||||||
{
|
{
|
||||||
yield return new JuiceStream
|
case IHasCurve curveData:
|
||||||
{
|
return new JuiceStream
|
||||||
StartTime = obj.StartTime,
|
{
|
||||||
Samples = obj.Samples,
|
StartTime = obj.StartTime,
|
||||||
Path = curveData.Path,
|
Samples = obj.Samples,
|
||||||
NodeSamples = curveData.NodeSamples,
|
Path = curveData.Path,
|
||||||
RepeatCount = curveData.RepeatCount,
|
NodeSamples = curveData.NodeSamples,
|
||||||
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
|
RepeatCount = curveData.RepeatCount,
|
||||||
NewCombo = comboData?.NewCombo ?? false,
|
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
|
||||||
ComboOffset = comboData?.ComboOffset ?? 0,
|
NewCombo = comboData?.NewCombo ?? false,
|
||||||
LegacyLastTickOffset = legacyOffset?.LegacyLastTickOffset ?? 0
|
ComboOffset = comboData?.ComboOffset ?? 0,
|
||||||
};
|
LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0
|
||||||
}
|
}.Yield();
|
||||||
else if (endTime != null)
|
|
||||||
{
|
case IHasEndTime endTime:
|
||||||
yield return new BananaShower
|
return new BananaShower
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
StartTime = obj.StartTime,
|
||||||
Samples = obj.Samples,
|
Samples = obj.Samples,
|
||||||
Duration = endTime.Duration,
|
Duration = endTime.Duration,
|
||||||
NewCombo = comboData?.NewCombo ?? false,
|
NewCombo = comboData?.NewCombo ?? false,
|
||||||
ComboOffset = comboData?.ComboOffset ?? 0,
|
ComboOffset = comboData?.ComboOffset ?? 0,
|
||||||
};
|
}.Yield();
|
||||||
}
|
|
||||||
else
|
default:
|
||||||
{
|
return new Fruit
|
||||||
yield return new Fruit
|
{
|
||||||
{
|
StartTime = obj.StartTime,
|
||||||
StartTime = obj.StartTime,
|
Samples = obj.Samples,
|
||||||
Samples = obj.Samples,
|
NewCombo = comboData?.NewCombo ?? false,
|
||||||
NewCombo = comboData?.NewCombo ?? false,
|
ComboOffset = comboData?.ComboOffset ?? 0,
|
||||||
ComboOffset = comboData?.ComboOffset ?? 0,
|
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH
|
||||||
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH
|
}.Yield();
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,37 +156,44 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
/// <returns>The hit objects generated.</returns>
|
/// <returns>The hit objects generated.</returns>
|
||||||
private IEnumerable<ManiaHitObject> generateConverted(HitObject original, IBeatmap originalBeatmap)
|
private IEnumerable<ManiaHitObject> generateConverted(HitObject original, IBeatmap originalBeatmap)
|
||||||
{
|
{
|
||||||
var endTimeData = original as IHasEndTime;
|
|
||||||
var distanceData = original as IHasDistance;
|
|
||||||
var positionData = original as IHasPosition;
|
|
||||||
|
|
||||||
Patterns.PatternGenerator conversion = null;
|
Patterns.PatternGenerator conversion = null;
|
||||||
|
|
||||||
if (distanceData != null)
|
switch (original)
|
||||||
{
|
{
|
||||||
var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
|
case IHasDistance _:
|
||||||
conversion = generator;
|
|
||||||
|
|
||||||
for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration)
|
|
||||||
{
|
{
|
||||||
recordNote(time, positionData?.Position ?? Vector2.Zero);
|
var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
|
||||||
computeDensity(time);
|
conversion = generator;
|
||||||
|
|
||||||
|
var positionData = original as IHasPosition;
|
||||||
|
|
||||||
|
for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration)
|
||||||
|
{
|
||||||
|
recordNote(time, positionData?.Position ?? Vector2.Zero);
|
||||||
|
computeDensity(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (endTimeData != null)
|
|
||||||
{
|
|
||||||
conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
|
|
||||||
|
|
||||||
recordNote(endTimeData.EndTime, new Vector2(256, 192));
|
case IHasEndTime endTimeData:
|
||||||
computeDensity(endTimeData.EndTime);
|
{
|
||||||
}
|
conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
|
||||||
else if (positionData != null)
|
|
||||||
{
|
|
||||||
computeDensity(original.StartTime);
|
|
||||||
|
|
||||||
conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);
|
recordNote(endTimeData.EndTime, new Vector2(256, 192));
|
||||||
|
computeDensity(endTimeData.EndTime);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
recordNote(original.StartTime, positionData.Position);
|
case IHasPosition positionData:
|
||||||
|
{
|
||||||
|
computeDensity(original.StartTime);
|
||||||
|
|
||||||
|
conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);
|
||||||
|
|
||||||
|
recordNote(original.StartTime, positionData.Position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conversion == null)
|
if (conversion == null)
|
||||||
@ -219,14 +226,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
|
|
||||||
private Pattern generate()
|
private Pattern generate()
|
||||||
{
|
{
|
||||||
var endTimeData = HitObject as IHasEndTime;
|
|
||||||
var positionData = HitObject as IHasXPosition;
|
var positionData = HitObject as IHasXPosition;
|
||||||
|
|
||||||
int column = GetColumn(positionData?.X ?? 0);
|
int column = GetColumn(positionData?.X ?? 0);
|
||||||
|
|
||||||
var pattern = new Pattern();
|
var pattern = new Pattern();
|
||||||
|
|
||||||
if (endTimeData != null)
|
if (HitObject is IHasEndTime endTimeData)
|
||||||
{
|
{
|
||||||
pattern.Add(new HoldNote
|
pattern.Add(new HoldNote
|
||||||
{
|
{
|
||||||
@ -237,7 +243,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) },
|
Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (positionData != null)
|
else if (HitObject is IHasXPosition)
|
||||||
{
|
{
|
||||||
pattern.Add(new Note
|
pattern.Add(new Note
|
||||||
{
|
{
|
||||||
@ -257,15 +263,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
||||||
{
|
{
|
||||||
var curveData = HitObject as IHasCurve;
|
if (HitObject is IHasCurve curveData)
|
||||||
|
{
|
||||||
|
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
|
||||||
|
|
||||||
if (curveData == null)
|
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||||
return HitObject.Samples;
|
return curveData.NodeSamples[index];
|
||||||
|
}
|
||||||
|
|
||||||
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
|
return HitObject.Samples;
|
||||||
|
|
||||||
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
|
||||||
return curveData.NodeSamples[index];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,15 +474,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
||||||
{
|
{
|
||||||
var curveData = HitObject as IHasCurve;
|
if (HitObject is IHasCurve curveData)
|
||||||
|
{
|
||||||
|
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
|
||||||
|
|
||||||
if (curveData == null)
|
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||||
return HitObject.Samples;
|
return curveData.NodeSamples[index];
|
||||||
|
}
|
||||||
|
|
||||||
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
|
return HitObject.Samples;
|
||||||
|
|
||||||
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
|
||||||
return curveData.NodeSamples[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -379,26 +379,25 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||||
{
|
{
|
||||||
var osuObject = judgedObject as DrawableOsuHitObject;
|
if (judgedObject is DrawableOsuHitObject osuObject)
|
||||||
if (osuObject == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OsuSpriteText text;
|
|
||||||
Add(text = new OsuSpriteText
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
OsuSpriteText text;
|
||||||
Origin = Anchor.Centre,
|
Add(text = new OsuSpriteText
|
||||||
Text = result.IsHit ? "Hit!" : "Miss!",
|
{
|
||||||
Colour = result.IsHit ? Color4.Green : Color4.Red,
|
Anchor = Anchor.Centre,
|
||||||
Font = OsuFont.GetFont(size: 30),
|
Origin = Anchor.Centre,
|
||||||
Position = osuObject.HitObject.StackedEndPosition + judgementOffsetDirection * new Vector2(0, 45)
|
Text = result.IsHit ? "Hit!" : "Miss!",
|
||||||
});
|
Colour = result.IsHit ? Color4.Green : Color4.Red,
|
||||||
|
Font = OsuFont.GetFont(size: 30),
|
||||||
|
Position = osuObject.HitObject.StackedEndPosition + judgementOffsetDirection * new Vector2(0, 45)
|
||||||
|
});
|
||||||
|
|
||||||
text.Delay(150)
|
text.Delay(150)
|
||||||
.Then().FadeOut(200)
|
.Then().FadeOut(200)
|
||||||
.Then().Expire();
|
.Then().Expire();
|
||||||
|
|
||||||
judgementOffsetDirection *= -1;
|
judgementOffsetDirection *= -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Beatmaps
|
namespace osu.Game.Rulesets.Osu.Beatmaps
|
||||||
{
|
{
|
||||||
@ -23,52 +24,48 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
|
|||||||
|
|
||||||
protected override IEnumerable<OsuHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap)
|
protected override IEnumerable<OsuHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
var curveData = original as IHasCurve;
|
|
||||||
var endTimeData = original as IHasEndTime;
|
|
||||||
var positionData = original as IHasPosition;
|
var positionData = original as IHasPosition;
|
||||||
var comboData = original as IHasCombo;
|
var comboData = original as IHasCombo;
|
||||||
var legacyOffset = original as IHasLegacyLastTickOffset;
|
|
||||||
|
|
||||||
if (curveData != null)
|
switch (original)
|
||||||
{
|
{
|
||||||
yield return new Slider
|
case IHasCurve curveData:
|
||||||
{
|
return new Slider
|
||||||
StartTime = original.StartTime,
|
{
|
||||||
Samples = original.Samples,
|
StartTime = original.StartTime,
|
||||||
Path = curveData.Path,
|
Samples = original.Samples,
|
||||||
NodeSamples = curveData.NodeSamples,
|
Path = curveData.Path,
|
||||||
RepeatCount = curveData.RepeatCount,
|
NodeSamples = curveData.NodeSamples,
|
||||||
Position = positionData?.Position ?? Vector2.Zero,
|
RepeatCount = curveData.RepeatCount,
|
||||||
NewCombo = comboData?.NewCombo ?? false,
|
Position = positionData?.Position ?? Vector2.Zero,
|
||||||
ComboOffset = comboData?.ComboOffset ?? 0,
|
NewCombo = comboData?.NewCombo ?? false,
|
||||||
LegacyLastTickOffset = legacyOffset?.LegacyLastTickOffset,
|
ComboOffset = comboData?.ComboOffset ?? 0,
|
||||||
// prior to v8, speed multipliers don't adjust for how many ticks are generated over the same distance.
|
LegacyLastTickOffset = (original as IHasLegacyLastTickOffset)?.LegacyLastTickOffset,
|
||||||
// this results in more (or less) ticks being generated in <v8 maps for the same time duration.
|
// prior to v8, speed multipliers don't adjust for how many ticks are generated over the same distance.
|
||||||
TickDistanceMultiplier = beatmap.BeatmapInfo.BeatmapVersion < 8 ? 1f / beatmap.ControlPointInfo.DifficultyPointAt(original.StartTime).SpeedMultiplier : 1
|
// this results in more (or less) ticks being generated in <v8 maps for the same time duration.
|
||||||
};
|
TickDistanceMultiplier = beatmap.BeatmapInfo.BeatmapVersion < 8 ? 1f / beatmap.ControlPointInfo.DifficultyPointAt(original.StartTime).SpeedMultiplier : 1
|
||||||
}
|
}.Yield();
|
||||||
else if (endTimeData != null)
|
|
||||||
{
|
case IHasEndTime endTimeData:
|
||||||
yield return new Spinner
|
return new Spinner
|
||||||
{
|
{
|
||||||
StartTime = original.StartTime,
|
StartTime = original.StartTime,
|
||||||
Samples = original.Samples,
|
Samples = original.Samples,
|
||||||
EndTime = endTimeData.EndTime,
|
EndTime = endTimeData.EndTime,
|
||||||
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
|
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
|
||||||
NewCombo = comboData?.NewCombo ?? false,
|
NewCombo = comboData?.NewCombo ?? false,
|
||||||
ComboOffset = comboData?.ComboOffset ?? 0,
|
ComboOffset = comboData?.ComboOffset ?? 0,
|
||||||
};
|
}.Yield();
|
||||||
}
|
|
||||||
else
|
default:
|
||||||
{
|
return new HitCircle
|
||||||
yield return new HitCircle
|
{
|
||||||
{
|
StartTime = original.StartTime,
|
||||||
StartTime = original.StartTime,
|
Samples = original.Samples,
|
||||||
Samples = original.Samples,
|
Position = positionData?.Position ?? Vector2.Zero,
|
||||||
Position = positionData?.Position ?? Vector2.Zero,
|
NewCombo = comboData?.NewCombo ?? false,
|
||||||
NewCombo = comboData?.NewCombo ?? false,
|
ComboOffset = comboData?.ComboOffset ?? 0,
|
||||||
ComboOffset = comboData?.ComboOffset ?? 0,
|
}.Yield();
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,18 +22,17 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y);
|
osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y);
|
||||||
|
|
||||||
var slider = hitObject as Slider;
|
if (hitObject is Slider slider)
|
||||||
if (slider == null)
|
{
|
||||||
return;
|
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
|
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
|
|
||||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
var newControlPoints = new Vector2[slider.Path.ControlPoints.Length];
|
||||||
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
for (int i = 0; i < slider.Path.ControlPoints.Length; i++)
|
||||||
|
newControlPoints[i] = new Vector2(slider.Path.ControlPoints[i].X, -slider.Path.ControlPoints[i].Y);
|
||||||
|
|
||||||
var newControlPoints = new Vector2[slider.Path.ControlPoints.Length];
|
slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance);
|
||||||
for (int i = 0; i < slider.Path.ControlPoints.Length; i++)
|
}
|
||||||
newControlPoints[i] = new Vector2(slider.Path.ControlPoints[i].X, -slider.Path.ControlPoints[i].Y);
|
|
||||||
|
|
||||||
slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,127 +73,133 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
|
|||||||
|
|
||||||
protected override IEnumerable<TaikoHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap)
|
protected override IEnumerable<TaikoHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
var distanceData = obj as IHasDistance;
|
|
||||||
var repeatsData = obj as IHasRepeats;
|
|
||||||
var endTimeData = obj as IHasEndTime;
|
|
||||||
var curveData = obj as IHasCurve;
|
|
||||||
|
|
||||||
// Old osu! used hit sounding to determine various hit type information
|
// Old osu! used hit sounding to determine various hit type information
|
||||||
IList<HitSampleInfo> samples = obj.Samples;
|
IList<HitSampleInfo> samples = obj.Samples;
|
||||||
|
|
||||||
bool strong = samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
|
bool strong = samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
|
||||||
|
|
||||||
if (distanceData != null)
|
switch (obj)
|
||||||
{
|
{
|
||||||
// Number of spans of the object - one for the initial length and for each repeat
|
case IHasDistance distanceData:
|
||||||
int spans = repeatsData?.SpanCount() ?? 1;
|
|
||||||
|
|
||||||
TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime);
|
|
||||||
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime);
|
|
||||||
|
|
||||||
double speedAdjustment = difficultyPoint.SpeedMultiplier;
|
|
||||||
double speedAdjustedBeatLength = timingPoint.BeatLength / speedAdjustment;
|
|
||||||
|
|
||||||
// The true distance, accounting for any repeats. This ends up being the drum roll distance later
|
|
||||||
double distance = distanceData.Distance * spans * legacy_velocity_multiplier;
|
|
||||||
|
|
||||||
// The velocity of the taiko hit object - calculated as the velocity of a drum roll
|
|
||||||
double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
|
|
||||||
// The duration of the taiko hit object
|
|
||||||
double taikoDuration = distance / taikoVelocity;
|
|
||||||
|
|
||||||
// The velocity of the osu! hit object - calculated as the velocity of a slider
|
|
||||||
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
|
|
||||||
// The duration of the osu! hit object
|
|
||||||
double osuDuration = distance / osuVelocity;
|
|
||||||
|
|
||||||
// osu-stable always uses the speed-adjusted beatlength to determine the velocities, but
|
|
||||||
// only uses it for tick rate if beatmap version < 8
|
|
||||||
if (beatmap.BeatmapInfo.BeatmapVersion >= 8)
|
|
||||||
speedAdjustedBeatLength *= speedAdjustment;
|
|
||||||
|
|
||||||
// If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
|
|
||||||
double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate, taikoDuration / spans);
|
|
||||||
|
|
||||||
if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
|
|
||||||
{
|
{
|
||||||
List<IList<HitSampleInfo>> allSamples = curveData != null ? curveData.NodeSamples : new List<IList<HitSampleInfo>>(new[] { samples });
|
// Number of spans of the object - one for the initial length and for each repeat
|
||||||
|
int spans = (obj as IHasRepeats)?.SpanCount() ?? 1;
|
||||||
|
|
||||||
int i = 0;
|
TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime);
|
||||||
|
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime);
|
||||||
|
|
||||||
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
|
double speedAdjustment = difficultyPoint.SpeedMultiplier;
|
||||||
|
double speedAdjustedBeatLength = timingPoint.BeatLength / speedAdjustment;
|
||||||
|
|
||||||
|
// The true distance, accounting for any repeats. This ends up being the drum roll distance later
|
||||||
|
double distance = distanceData.Distance * spans * legacy_velocity_multiplier;
|
||||||
|
|
||||||
|
// The velocity of the taiko hit object - calculated as the velocity of a drum roll
|
||||||
|
double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
|
||||||
|
// The duration of the taiko hit object
|
||||||
|
double taikoDuration = distance / taikoVelocity;
|
||||||
|
|
||||||
|
// The velocity of the osu! hit object - calculated as the velocity of a slider
|
||||||
|
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
|
||||||
|
// The duration of the osu! hit object
|
||||||
|
double osuDuration = distance / osuVelocity;
|
||||||
|
|
||||||
|
// osu-stable always uses the speed-adjusted beatlength to determine the velocities, but
|
||||||
|
// only uses it for tick rate if beatmap version < 8
|
||||||
|
if (beatmap.BeatmapInfo.BeatmapVersion >= 8)
|
||||||
|
speedAdjustedBeatLength *= speedAdjustment;
|
||||||
|
|
||||||
|
// If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
|
||||||
|
double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate, taikoDuration / spans);
|
||||||
|
|
||||||
|
if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
|
||||||
{
|
{
|
||||||
IList<HitSampleInfo> currentSamples = allSamples[i];
|
List<IList<HitSampleInfo>> allSamples = obj is IHasCurve curveData ? curveData.NodeSamples : new List<IList<HitSampleInfo>>(new[] { samples });
|
||||||
bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
|
|
||||||
strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
|
|
||||||
|
|
||||||
if (isRim)
|
int i = 0;
|
||||||
{
|
|
||||||
yield return new RimHit
|
|
||||||
{
|
|
||||||
StartTime = j,
|
|
||||||
Samples = currentSamples,
|
|
||||||
IsStrong = strong
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yield return new CentreHit
|
|
||||||
{
|
|
||||||
StartTime = j,
|
|
||||||
Samples = currentSamples,
|
|
||||||
IsStrong = strong
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
i = (i + 1) % allSamples.Count;
|
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
|
||||||
|
{
|
||||||
|
IList<HitSampleInfo> currentSamples = allSamples[i];
|
||||||
|
bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
|
||||||
|
strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
|
||||||
|
|
||||||
|
if (isRim)
|
||||||
|
{
|
||||||
|
yield return new RimHit
|
||||||
|
{
|
||||||
|
StartTime = j,
|
||||||
|
Samples = currentSamples,
|
||||||
|
IsStrong = strong
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield return new CentreHit
|
||||||
|
{
|
||||||
|
StartTime = j,
|
||||||
|
Samples = currentSamples,
|
||||||
|
IsStrong = strong
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
i = (i + 1) % allSamples.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
yield return new DrumRoll
|
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
yield return new DrumRoll
|
||||||
Samples = obj.Samples,
|
{
|
||||||
IsStrong = strong,
|
StartTime = obj.StartTime,
|
||||||
Duration = taikoDuration,
|
Samples = obj.Samples,
|
||||||
TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4
|
IsStrong = strong,
|
||||||
};
|
Duration = taikoDuration,
|
||||||
}
|
TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4
|
||||||
}
|
};
|
||||||
else if (endTimeData != null)
|
}
|
||||||
{
|
|
||||||
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
|
|
||||||
|
|
||||||
yield return new Swell
|
break;
|
||||||
{
|
|
||||||
StartTime = obj.StartTime,
|
|
||||||
Samples = obj.Samples,
|
|
||||||
Duration = endTimeData.Duration,
|
|
||||||
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
|
|
||||||
|
|
||||||
if (isRim)
|
|
||||||
{
|
|
||||||
yield return new RimHit
|
|
||||||
{
|
|
||||||
StartTime = obj.StartTime,
|
|
||||||
Samples = obj.Samples,
|
|
||||||
IsStrong = strong
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
case IHasEndTime endTimeData:
|
||||||
{
|
{
|
||||||
yield return new CentreHit
|
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
|
||||||
|
|
||||||
|
yield return new Swell
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
StartTime = obj.StartTime,
|
||||||
Samples = obj.Samples,
|
Samples = obj.Samples,
|
||||||
IsStrong = strong
|
Duration = endTimeData.Duration,
|
||||||
|
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
|
||||||
|
|
||||||
|
if (isRim)
|
||||||
|
{
|
||||||
|
yield return new RimHit
|
||||||
|
{
|
||||||
|
StartTime = obj.StartTime,
|
||||||
|
Samples = obj.Samples,
|
||||||
|
IsStrong = strong
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield return new CentreHit
|
||||||
|
{
|
||||||
|
StartTime = obj.StartTime,
|
||||||
|
Samples = obj.Samples,
|
||||||
|
IsStrong = strong
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,76 +43,83 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
|||||||
IHasEndTime endTimeData = h as IHasEndTime;
|
IHasEndTime endTimeData = h as IHasEndTime;
|
||||||
double endTime = endTimeData?.EndTime ?? h.StartTime;
|
double endTime = endTimeData?.EndTime ?? h.StartTime;
|
||||||
|
|
||||||
Swell swell = h as Swell;
|
switch (h)
|
||||||
DrumRoll drumRoll = h as DrumRoll;
|
|
||||||
Hit hit = h as Hit;
|
|
||||||
|
|
||||||
if (swell != null)
|
|
||||||
{
|
{
|
||||||
int d = 0;
|
case Swell swell:
|
||||||
int count = 0;
|
|
||||||
int req = swell.RequiredHits;
|
|
||||||
double hitRate = Math.Min(swell_hit_speed, swell.Duration / req);
|
|
||||||
|
|
||||||
for (double j = h.StartTime; j < endTime; j += hitRate)
|
|
||||||
{
|
{
|
||||||
TaikoAction action;
|
int d = 0;
|
||||||
|
int count = 0;
|
||||||
|
int req = swell.RequiredHits;
|
||||||
|
double hitRate = Math.Min(swell_hit_speed, swell.Duration / req);
|
||||||
|
|
||||||
switch (d)
|
for (double j = h.StartTime; j < endTime; j += hitRate)
|
||||||
{
|
{
|
||||||
default:
|
TaikoAction action;
|
||||||
case 0:
|
|
||||||
action = TaikoAction.LeftCentre;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
switch (d)
|
||||||
action = TaikoAction.LeftRim;
|
{
|
||||||
break;
|
default:
|
||||||
|
case 0:
|
||||||
|
action = TaikoAction.LeftCentre;
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 1:
|
||||||
action = TaikoAction.RightCentre;
|
action = TaikoAction.LeftRim;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 2:
|
||||||
action = TaikoAction.RightRim;
|
action = TaikoAction.RightCentre;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
action = TaikoAction.RightRim;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames.Add(new TaikoReplayFrame(j, action));
|
||||||
|
d = (d + 1) % 4;
|
||||||
|
if (++count == req)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Frames.Add(new TaikoReplayFrame(j, action));
|
break;
|
||||||
d = (d + 1) % 4;
|
|
||||||
if (++count == req)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (drumRoll != null)
|
|
||||||
{
|
|
||||||
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
|
||||||
{
|
|
||||||
Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
|
|
||||||
hitButton = !hitButton;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (hit != null)
|
|
||||||
{
|
|
||||||
TaikoAction[] actions;
|
|
||||||
|
|
||||||
if (hit is CentreHit)
|
|
||||||
{
|
|
||||||
actions = h.IsStrong
|
|
||||||
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
|
||||||
: new[] { hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
actions = h.IsStrong
|
|
||||||
? new[] { TaikoAction.LeftRim, TaikoAction.RightRim }
|
|
||||||
: new[] { hitButton ? TaikoAction.LeftRim : TaikoAction.RightRim };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
|
case DrumRoll drumRoll:
|
||||||
|
{
|
||||||
|
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
||||||
|
{
|
||||||
|
Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
|
||||||
|
hitButton = !hitButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Hit hit:
|
||||||
|
{
|
||||||
|
TaikoAction[] actions;
|
||||||
|
|
||||||
|
if (hit is CentreHit)
|
||||||
|
{
|
||||||
|
actions = h.IsStrong
|
||||||
|
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
||||||
|
: new[] { hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actions = h.IsStrong
|
||||||
|
? new[] { TaikoAction.LeftRim, TaikoAction.RightRim }
|
||||||
|
: new[] { hitButton ? TaikoAction.LeftRim : TaikoAction.RightRim };
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidOperationException("Unknown hit object type.");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
throw new InvalidOperationException("Unknown hit object type.");
|
|
||||||
|
|
||||||
var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button
|
var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button
|
||||||
|
|
||||||
|
@ -125,22 +125,20 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
|
|
||||||
foreach (var c in Children)
|
foreach (var c in Children)
|
||||||
{
|
{
|
||||||
var stc = c as ScrollingTeam;
|
if (c is ScrollingTeam stc)
|
||||||
|
|
||||||
if (stc == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (closest == null)
|
|
||||||
{
|
{
|
||||||
closest = stc;
|
if (closest == null)
|
||||||
continue;
|
{
|
||||||
|
closest = stc;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
|
||||||
|
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
|
||||||
|
|
||||||
|
if (o < lastOffset)
|
||||||
|
closest = stc;
|
||||||
}
|
}
|
||||||
|
|
||||||
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
|
|
||||||
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
|
|
||||||
|
|
||||||
if (o < lastOffset)
|
|
||||||
closest = stc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace.Assert(closest != null, "closest != null");
|
Trace.Assert(closest != null, "closest != null");
|
||||||
@ -203,15 +201,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
|
|
||||||
foreach (var c in Children)
|
foreach (var c in Children)
|
||||||
{
|
{
|
||||||
ScrollingTeam st = c as ScrollingTeam;
|
if (c is ScrollingTeam st)
|
||||||
|
|
||||||
if (st == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (st.Team == team)
|
|
||||||
{
|
{
|
||||||
st.FadeOut(200);
|
if (st.Team == team)
|
||||||
st.Expire();
|
{
|
||||||
|
st.FadeOut(200);
|
||||||
|
st.Expire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,14 +291,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
{
|
{
|
||||||
foreach (var c in Children)
|
foreach (var c in Children)
|
||||||
{
|
{
|
||||||
ScrollingTeam st = c as ScrollingTeam;
|
if (c is ScrollingTeam st)
|
||||||
if (st == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (st.Selected)
|
|
||||||
{
|
{
|
||||||
st.Selected = false;
|
if (st.Selected)
|
||||||
RemoveTeam(st.Team);
|
{
|
||||||
|
st.Selected = false;
|
||||||
|
RemoveTeam(st.Team);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,10 +297,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
var h = Header as UserDropdownHeader;
|
if (Header is UserDropdownHeader h)
|
||||||
if (h == null) return;
|
h.StatusColour = value;
|
||||||
|
|
||||||
h.StatusColour = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,13 +148,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
// Generate the timing points, making non-timing changes use the previous timing change and vice-versa
|
// Generate the timing points, making non-timing changes use the previous timing change and vice-versa
|
||||||
var timingChanges = allPoints.Select(c =>
|
var timingChanges = allPoints.Select(c =>
|
||||||
{
|
{
|
||||||
var timingPoint = c as TimingControlPoint;
|
if (c is TimingControlPoint timingPoint)
|
||||||
var difficultyPoint = c as DifficultyControlPoint;
|
|
||||||
|
|
||||||
if (timingPoint != null)
|
|
||||||
lastTimingPoint = timingPoint;
|
lastTimingPoint = timingPoint;
|
||||||
|
else if (c is DifficultyControlPoint difficultyPoint)
|
||||||
if (difficultyPoint != null)
|
|
||||||
lastDifficultyPoint = difficultyPoint;
|
lastDifficultyPoint = difficultyPoint;
|
||||||
|
|
||||||
return new MultiplierControlPoint(c.Time)
|
return new MultiplierControlPoint(c.Time)
|
||||||
|
@ -17,10 +17,10 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
public override bool Equals(BackgroundScreen other)
|
public override bool Equals(BackgroundScreen other)
|
||||||
{
|
{
|
||||||
var backgroundScreenCustom = other as BackgroundScreenCustom;
|
if (other is BackgroundScreenCustom backgroundScreenCustom)
|
||||||
if (backgroundScreenCustom == null) return false;
|
return base.Equals(other) && textureName == backgroundScreenCustom.textureName;
|
||||||
|
|
||||||
return base.Equals(other) && textureName == backgroundScreenCustom.textureName;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user