Split slider samples into head + tail + repeats + body (the original HitObject.Samples).

This commit is contained in:
smoogipooo
2017-04-21 18:49:49 +09:00
parent a7afde02bf
commit a999c42d8a
10 changed files with 54 additions and 16 deletions

View File

@ -22,7 +22,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType,
int repeatCount, List<SampleInfo> headSamples, List<SampleInfo> tailSamples, List<List<SampleInfo>> repeatSamples)
{
return new Slider
{
@ -32,6 +33,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
Distance = length,
CurveType = curveType,
RepeatCount = repeatCount,
HeadSamples = headSamples,
TailSamples = tailSamples,
RepeatSamples = repeatSamples
};
}

View File

@ -26,7 +26,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
var soundType = (LegacySoundType)int.Parse(split[4]);
var bankInfo = new SampleBankInfo();
List<SampleInfo> startSamples = null;
HitObject result;
@ -129,13 +128,14 @@ namespace osu.Game.Rulesets.Objects.Legacy
for (int i = 0; i <= repeatCount; i++)
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
// Extract the first node as the first sample
startSamples = nodeSamples[0];
// Extract the first and last samples for the head and tail respectively
List<SampleInfo> headSamples = nodeSamples.First();
List<SampleInfo> tailSamples = nodeSamples.Last();
// Repeat samples are all the samples excluding the one from the first node (note this includes the end node)
var repeatSamples = nodeSamples.Skip(1).ToList();
// Repeat samples are all the samples between head and tail
var repeatSamples = nodeSamples.Skip(1).TakeWhile(s => s != tailSamples).ToList();
result = CreateSlider(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, points, length, curveType, repeatCount, repeatSamples);
result = CreateSlider(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, points, length, curveType, repeatCount, headSamples, tailSamples, repeatSamples);
}
else if ((type & HitObjectType.Spinner) > 0)
{
@ -161,7 +161,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
throw new InvalidOperationException($@"Unknown hit object type {type}");
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
result.Samples = startSamples ?? convertSoundType(soundType, bankInfo);
result.Samples = convertSoundType(soundType, bankInfo);
return result;
}
@ -212,7 +212,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="repeatCount">The slider repeat count.</param>
/// <param name="repeatSamples">The slider repeat sounds (this includes the end node, but NOT the start node).</param>
/// <returns>The hit object.</returns>
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples);
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType,
int repeatCount, List<SampleInfo> headSamples, List<SampleInfo> tailSamples, List<List<SampleInfo>> repeatSamples);
/// <summary>
/// Creates a legacy Spinner-type hit object.

View File

@ -22,7 +22,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType,
int repeatCount, List<SampleInfo> headSamples, List<SampleInfo> tailSamples, List<List<SampleInfo>> repeatSamples)
{
return new Slider
{
@ -32,6 +33,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
Distance = length,
CurveType = curveType,
RepeatCount = repeatCount,
HeadSamples = headSamples,
TailSamples = tailSamples,
RepeatSamples = repeatSamples
};
}

View File

@ -22,7 +22,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType,
int repeatCount, List<SampleInfo> headSamples, List<SampleInfo> tailSamples, List<List<SampleInfo>> repeatSamples)
{
return new Slider
{
@ -32,6 +33,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
Distance = length,
CurveType = curveType,
RepeatCount = repeatCount,
HeadSamples = headSamples,
TailSamples = tailSamples,
RepeatSamples = repeatSamples
};
}

View File

@ -21,7 +21,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType,
int repeatCount, List<SampleInfo> headSamples, List<SampleInfo> tailSamples, List<List<SampleInfo>> repeatSamples)
{
return new Slider
{
@ -30,6 +31,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
Distance = length,
CurveType = curveType,
RepeatCount = repeatCount,
HeadSamples = headSamples,
TailSamples = tailSamples,
RepeatSamples = repeatSamples
};
}