fix loading to world without mods not triggering download
This commit is contained in:
@@ -44,6 +44,22 @@ internal static class ModInjector
|
||||
__state.Add(mod);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MyWorkshop), nameof(MyWorkshop.DownloadModsAsync))]
|
||||
[HarmonyTranspiler]
|
||||
private static IEnumerable<CodeInstruction> DownloadModsAsyncTranspiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var getCount = AccessTools.PropertyGetter(typeof(List<MyObjectBuilder_Checkpoint.ModItem>), nameof(List<MyObjectBuilder_Checkpoint.ModItem>.Count));
|
||||
return new CodeMatcher(instructions)
|
||||
.SearchForward(b => b.Calls(getCount))
|
||||
.Advance(1)
|
||||
.Insert(
|
||||
CodeInstruction.LoadField(typeof(ModInjector), nameof(Mods)),
|
||||
new(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(HashSet<ulong>), nameof(HashSet<ulong>.Count))),
|
||||
new(OpCodes.Add)
|
||||
)
|
||||
.Instructions();
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MyDefinitionManager), nameof(MyDefinitionManager.LoadData))]
|
||||
[HarmonyPrefix]
|
||||
|
Reference in New Issue
Block a user