26 lines
833 B
C#
26 lines
833 B
C#
using System.Reflection;
|
|
using System.Reflection.Emit;
|
|
using HarmonyLib;
|
|
using VRage.Render11.Sprites;
|
|
using VRageRender;
|
|
|
|
namespace CringeLauncher.Patches;
|
|
|
|
[HarmonyPatch(typeof(MyRender11), nameof(MyRender11.FullDraw))]
|
|
public class RenderHookPatch
|
|
{
|
|
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
{
|
|
var placedHook = false;
|
|
var method = AccessTools.Method(typeof(MySpritesManager), nameof(MySpritesManager.FrameEnd));
|
|
foreach (var instruction in instructions)
|
|
{
|
|
if (!placedHook && instruction.Calls(method))
|
|
{
|
|
yield return CodeInstruction.CallClosure(() => ImGuiHandler.Instance?.DoRender());
|
|
placedHook = true;
|
|
}
|
|
yield return instruction;
|
|
}
|
|
}
|
|
} |