Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed generating note data for chains #133

Merged
merged 3 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resharper_indent_preprocessor_directives = normal
resharper_max_attribute_length_for_same_line = 100
resharper_place_accessorholder_attribute_on_same_line = false
resharper_place_accessor_attribute_on_same_line = true
resharper_place_field_attribute_on_same_line = false
resharper_place_field_attribute_on_same_line = if_owner_is_single_line
resharper_place_simple_case_statement_on_same_line = if_owner_is_single_line
resharper_use_continuous_indent_inside_initializer_braces = false
resharper_use_indent_from_vs = false
Expand Down
92 changes: 68 additions & 24 deletions Source/2_Core/Replayer/Emulation/Scoring/ReplayerScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,38 @@ private bool TryFindNoteData(NoteEvent noteEvent, out NoteData? noteData) {
}

private static IEnumerable<NoteData> CreateSortedNoteDataList(IEnumerable<BeatmapDataItem> items) {
return items
.Select(static x => x switch {
NoteData data => data,
SliderData sliderData => NoteData.CreateBurstSliderNoteData(
sliderData.time, sliderData.headLineIndex, sliderData.headLineLayer,
sliderData.headBeforeJumpLineLayer, sliderData.colorType, NoteCutDirection.Any, 1f),
_ => null
})
.OfType<NoteData>()
.OrderBy(static x => x, beatmapItemsComparer);
var result = new List<NoteData>();
foreach (var item in items) {
switch (item) {
case NoteData data:
result.Add(data);
break;
case SliderData sliderData:
ConvertAndAddSliderData(sliderData, result);
break;
}
}
result.Sort(beatmapItemsComparer);
return result;

static void ConvertAndAddSliderData(SliderData sliderData, ICollection<NoteData> list) {
var sliceCount = sliderData.sliceCount;
for (var i = 1; i < sliceCount; ++i) {
var lineIndex = i < sliceCount - 1 ? sliderData.headLineIndex : sliderData.tailLineIndex;
var noteLineLayer = i < sliceCount - 1 ? sliderData.headLineLayer : sliderData.tailLineLayer;
var time = Mathf.LerpUnclamped(sliderData.time, sliderData.tailTime, (float)i / (sliceCount - 1));
var sliderNoteData = NoteData.CreateBurstSliderNoteData(
time,
lineIndex,
noteLineLayer,
sliderData.headBeforeJumpLineLayer,
sliderData.colorType,
NoteCutDirection.Any,
1f
);
list.Add(sliderNoteData);
}
}
}

#endregion
Expand Down Expand Up @@ -245,26 +267,48 @@ private void HandleReprocessDone() {
};

private static readonly HarmonyPatchDescriptor finishSwingRatingCounterPatchDescriptor = new(
typeof(GoodCutScoringElement).GetMethod(nameof(
GoodCutScoringElement.Init), ReflectionUtils.DefaultFlags)!, postfix:
typeof(ReplayerScoreProcessor).GetMethod(nameof(
GoodCutScoringInitPostfix), BindingFlags.NonPublic | BindingFlags.Static));
typeof(GoodCutScoringElement).GetMethod(
nameof(GoodCutScoringElement.Init),
ReflectionUtils.DefaultFlags
)!,
postfix:
typeof(ReplayerScoreProcessor).GetMethod(
nameof(GoodCutScoringInitPostfix),
BindingFlags.NonPublic | BindingFlags.Static
)
);

private static readonly HarmonyPatchDescriptor noteWasCutEnergyCounterPatchDescriptor = new(
typeof(GameEnergyCounter).GetMethod(nameof(
GameEnergyCounter.HandleNoteWasCut), ReflectionUtils.DefaultFlags)!, postfix:
typeof(ReplayerScoreProcessor).GetMethod(nameof(
NoteWasProcessedPostfix), ReflectionUtils.StaticFlags));
typeof(GameEnergyCounter).GetMethod(
nameof(GameEnergyCounter.HandleNoteWasCut),
ReflectionUtils.DefaultFlags
)!,
postfix:
typeof(ReplayerScoreProcessor).GetMethod(
nameof(NoteWasProcessedPostfix),
ReflectionUtils.StaticFlags
)
);

private static readonly HarmonyPatchDescriptor noteWasMissedEnergyCounterPatchDescriptor = new(
typeof(GameEnergyCounter).GetMethod(nameof(
GameEnergyCounter.HandleNoteWasMissed), ReflectionUtils.DefaultFlags)!, postfix:
typeof(ReplayerScoreProcessor).GetMethod(nameof(
NoteWasProcessedPostfix), ReflectionUtils.StaticFlags));
typeof(GameEnergyCounter).GetMethod(
nameof(GameEnergyCounter.HandleNoteWasMissed),
ReflectionUtils.DefaultFlags
)!,
postfix:
typeof(ReplayerScoreProcessor).GetMethod(
nameof(NoteWasProcessedPostfix),
ReflectionUtils.StaticFlags
)
);

private readonly HarmonySilencer _cutScoreSpawnerSilencer = new(
typeof(NoteCutScoreSpawner).GetMethod(nameof(NoteCutScoreSpawner
.HandleScoringForNoteStarted), ReflectionUtils.DefaultFlags)!, false);
typeof(NoteCutScoreSpawner).GetMethod(
nameof(NoteCutScoreSpawner.HandleScoringForNoteStarted),
ReflectionUtils.DefaultFlags
)!,
false
);

private readonly HarmonyAutoPatch _finishSwingRatingCounterPatch = new(finishSwingRatingCounterPatchDescriptor);
private readonly HarmonyAutoPatch _noteWasCutEnergyCounterPatch = new(noteWasCutEnergyCounterPatchDescriptor);
Expand Down
Loading