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 invalid hitscores. #135

Merged
merged 1 commit into from
Jul 14, 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
26 changes: 26 additions & 0 deletions Source/2_Core/Replayer/Tweaking/Tweaks/ScoringTweak.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using BeatLeader.Utils;
using JetBrains.Annotations;

namespace BeatLeader.Replayer.Tweaking {
internal class ScoringTweak : GameTweak {
private static readonly HarmonyPatchDescriptor patchDescriptor = new(
ReflectionUtils.GetMethod<GoodCutScoringElement>("Init")!,
ReflectionUtils.GetMethod<ScoringTweak>("Prefix")
);

private HarmonyAutoPatch _patch = null!;

public override void Initialize() {
_patch = patchDescriptor;
}

public override void Dispose() {
_patch.Dispose();
}

[UsedImplicitly]
private static void Prefix(ref CutScoreBuffer ____cutScoreBuffer) {
____cutScoreBuffer = new();
}
}
}
3 changes: 2 additions & 1 deletion Source/2_Core/Replayer/Tweaking/TweaksHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ private enum ActionType {
new RoomOffsetsTweak(),
new ReplayFailTweak(),
new ReplayFinishTweak(),
new JumpDistanceTweak()
new JumpDistanceTweak(),
new ScoringTweak()
};

#region Installation
Expand Down
6 changes: 5 additions & 1 deletion Source/7_Utils/StaticUtils/ReflectionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public static Dictionary<Type, T> GetTypesWithAttribute<T>(this Assembly assembl
#endregion

#region GetMethod


public static MethodInfo? GetMethod<TDeclarator>(string name) {
return typeof(TDeclarator).GetMethod(name, UniversalFlags);
}

public static MethodInfo GetMethod(
this Type targetType,
string name,
Expand Down
Loading