-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change to .user File * I hate patching async methods this took me 2 hours * Change async method finder location; added more transpiler patches * Attempted patch - commit for history * Changed to much simpler & compact method kept async method finder function for future usage * Changed to Lord's GameLibs; Updated Leaderboard Patch Respectively * remove file left from user stuff * Added older sdk support * Lowered patch priorities Allows other mods to override the prefix patch before it is ran - as these patches only change the parameter based on specific circumstances that would be changed by another mod * Shortened Leaderboard Patchfile Done so by publicizing game assets from GameLibs * Change Binding Flags * Fix incorrect patch * Minor Refactoring & Reorganization
- Loading branch information
Ryan Gregory
authored
Feb 1, 2024
1 parent
f82a7fe
commit 85df43f
Showing
6 changed files
with
76 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using HarmonyLib; | ||
|
||
namespace LobbyCompatibility.Features; | ||
|
||
/// <summary> | ||
/// Helper class related to Harmony Patching. | ||
/// </summary> | ||
internal class HarmonyHelper | ||
{ | ||
/// <summary> | ||
/// Retrieves the MethodInfo of the compiler-generated async method. | ||
/// Async method content is not actually in the <c>async Method()</c>, but instead is in a separate <c>struct</c> under the method "MoveNext"; | ||
/// this function retrieves that method info. | ||
/// </summary> | ||
/// <param name="type">(<see cref="Type"/>) The type of the class housing the method.</param> | ||
/// <param name="method">(<see cref="string"/>) The name of the method being patched.</param> | ||
/// <returns>(<see cref="MethodInfo"/>) The info of the async "MoveNext" method.</returns> | ||
public static MethodInfo? GetAsyncInfo(Type type, string method) | ||
{ | ||
// Get the Method Info of the target Async Method | ||
return AccessTools.Method(type, method) | ||
// Find the AsyncStateMachine class from target method | ||
.GetCustomAttribute<AsyncStateMachineAttribute>() | ||
// Get the struct type (random compiler junk) | ||
.StateMachineType.GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.NonPublic); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
LobbyCompatibility/Patches/ES3SettingsConstructorPrefix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using HarmonyLib; | ||
|
||
namespace LobbyCompatibility.Patches; | ||
|
||
/// <summary> | ||
/// Patches <see cref="ES3Settings(string, ES3Settings)" />. | ||
/// Creates a separate modded challenge save file. | ||
/// </summary> | ||
/// <seealso cref="ES3Settings(string, ES3Settings)" /> | ||
[HarmonyPatch(typeof(ES3Settings), MethodType.Constructor, new Type[] { typeof(string), typeof(ES3Settings) })] | ||
[HarmonyPriority(Priority.Last)] | ||
[HarmonyWrapSafe] | ||
internal class ES3SettingsConstructorPrefix | ||
{ | ||
[HarmonyPrefix] | ||
private static void FileSettings(ref string path) | ||
{ | ||
path = path == "LCChallengeFile" ? "LCModdedChallengeFile" : path; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
LobbyCompatibility/Patches/FindOrCreateLeaderboardPrefix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using HarmonyLib; | ||
using Steamworks; | ||
|
||
namespace LobbyCompatibility.Patches; | ||
|
||
/// <summary> | ||
/// Patches <see cref="ISteamUserStats.FindOrCreateLeaderboard" />. | ||
/// Changes the target leaderboard to a modded one. | ||
/// </summary> | ||
/// <seealso cref="ISteamUserStats.FindOrCreateLeaderboard" /> | ||
[HarmonyPatch(typeof(ISteamUserStats), nameof(ISteamUserStats.FindOrCreateLeaderboard))] | ||
[HarmonyPriority(Priority.Last)] | ||
[HarmonyWrapSafe] | ||
internal class FindOrCreateLeaderboardPrefix | ||
{ | ||
[HarmonyPrefix] | ||
private static void Prefix(ref string pchLeaderboardName) | ||
{ | ||
pchLeaderboardName = (pchLeaderboardName.StartsWith("challenge")) ? $"modded_{pchLeaderboardName}" : pchLeaderboardName; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.