Skip to content

Commit

Permalink
Merge pull request #381 from LumpBloom7/Beatmap-conversion-revamp
Browse files Browse the repository at this point in the history
Alter beatmap conversion to allow variance in taps generated from repeats
  • Loading branch information
LumpBloom7 authored Aug 31, 2022
2 parents 4987dda + 9b6abc2 commit 17f4b7a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
46 changes: 37 additions & 9 deletions osu.Game.Rulesets.Sentakki/Beatmaps/SentakkiBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private IEnumerable<SentakkiHitObject> convertSlider(HitObject original)
if (twin)
yield return createHoldNote(original, nodeSamples, true, breakNote);
else
foreach (var note in createTapsFromTicks(original, nodeSamples))
foreach (var note in createTapsFromNodes(original, nodeSamples, breakNote))
yield return note;

yield return createHoldNote(original, nodeSamples, false, breakNote);
Expand All @@ -188,11 +188,13 @@ private IEnumerable<SentakkiHitObject> tryConvertSliderToSlide(HitObject origina
if (twin)
slides.Add((Slide)createSlideNote(original, nodeSamples, true, isBreak));
else
taps.AddRange(createTapsFromTicks(original, nodeSamples));
taps.AddRange(createTapsFromNodes(original, nodeSamples, isBreak));
}

slides.Add((Slide)createSlideNote(original, nodeSamples, false, isBreak));

slides.RemoveAll(x => x == null);

// If there is a SlideFan, we always prioritize that, and ignore the rest
foreach (var slide in slides)
if (slide.SlideInfoList[0].ID == SlidePaths.FANID)
Expand Down Expand Up @@ -314,20 +316,29 @@ private SentakkiHitObject createSlideNote(HitObject original, IList<IList<HitSam
};
}

private IEnumerable<Tap> createTapsFromTicks(HitObject original, IList<IList<HitSampleInfo>> nodeSamples)
private IEnumerable<Tap> createTapsFromNodes(HitObject original, IList<IList<HitSampleInfo>> nodeSamples, bool isBreak = false)
{
if (original is not IHasPathWithRepeats)
yield break;

int noteLane = patternGenerator.GetNextLane(true);

var curve = original as IHasPathWithRepeats;
double spanDuration = curve.Duration / (curve.RepeatCount + 1);
bool isRepeatSpam = spanDuration < 75 && curve.RepeatCount > 0;

if (isRepeatSpam)
yield break;

// There's a chance no taps will be generated from nodes
if (patternGenerator.RNG.NextDouble() < 0.5)
yield break;

// There's a chance no taps will be generated from head nodes
bool shouldConsiderStartTick = patternGenerator.RNG.NextDouble() < 0.5;

// There's a chance no taps will be generated from head nodes
// If the head node isn't considered, then neither will the tail
bool shouldConsiderTailTick = shouldConsiderStartTick && patternGenerator.RNG.NextDouble() < 0.5;

var difficulty = Beatmap.BeatmapInfo.Difficulty;

var controlPointInfo = (LegacyControlPointInfo)Beatmap.ControlPointInfo;
Expand All @@ -342,19 +353,36 @@ private IEnumerable<Tap> createTapsFromTicks(HitObject original, IList<IList<Hit

double legacyLastTickOffset = (original as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0;

int nodeSampleIndex = 1;
int nodeSampleIndex = 0;

foreach (var e in SliderEventGenerator.Generate(original.StartTime, spanDuration, velocity, tickDistance, curve.Path.Distance, curve.RepeatCount + 1, legacyLastTickOffset, CancellationToken.None))
{
switch (e.Type)
{
case SliderEventType.Head:
if (shouldConsiderStartTick)
goto case SliderEventType.Repeat;

++nodeSampleIndex;
break;

case SliderEventType.Tail:
if (shouldConsiderTailTick)
goto case SliderEventType.Repeat;

++nodeSampleIndex;
break;

case SliderEventType.Repeat:
yield return new Tap
{
Lane = noteLane,
Samples = nodeSamples[nodeSampleIndex++],
StartTime = e.Time
Lane = patternGenerator.GetNextLane(true),
Samples = nodeSamples[nodeSampleIndex],
StartTime = e.Time,
Break = e.Type is SliderEventType.Head && isBreak
};

++nodeSampleIndex;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void StartNextPattern()
// Lane difference determined by offset2, but will make sure offset2 is never 0.
(twin)=>{
offset2 = offset2 == 0 ? 1 : offset2;
offset+=offset2;
offset+=offset2 * (twin ? 2: 1);
offset2= -offset2;

return offset;
Expand Down

0 comments on commit 17f4b7a

Please sign in to comment.