forked from zombieb/undead-universal-patch-il2cpp
VideoTamperPatch, configurable outside of the BepInEx config
This commit is contained in:
63
Patches/Video/VideoTamperPatch.cs
Normal file
63
Patches/Video/VideoTamperPatch.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using HarmonyLib;
|
||||
using undead_universal_patch_il2cpp.Core;
|
||||
using undead_universal_patch_il2cpp.Core.Config;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Patches.Video;
|
||||
|
||||
[HarmonyPatch]
|
||||
public class VideoTamperPatch
|
||||
{
|
||||
public static DediConfig<BaseOptionConfig> config = new("VideoTamperPatchConfig", JsonSerializer.Serialize(
|
||||
new BaseOptionConfig
|
||||
{
|
||||
Enabled = false
|
||||
}
|
||||
), null);
|
||||
|
||||
static PatchTypesResult patchTypesResult = Util.PreparePatchTypes(
|
||||
"Video anti-tamper hash disabler patch",
|
||||
"RecRoom.Core.Cinematics.CinematicVideoPlayer",
|
||||
"Start"
|
||||
);
|
||||
|
||||
static bool Prepare()
|
||||
{
|
||||
if (config.Get().Enabled) return patchTypesResult.Success;
|
||||
else return false;
|
||||
}
|
||||
|
||||
static MethodBase TargetMethod() => patchTypesResult.Method;
|
||||
|
||||
static void Prefix(ref object __instance)
|
||||
{
|
||||
PropertyInfo useProp = __instance.GetType().GetRuntimeProperty("useAntiTamperHash");
|
||||
if (useProp == null)
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogError("VideoTamperPatch prefix: useAntiTamperHash was not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
useProp.SetValue(__instance, false);
|
||||
}
|
||||
|
||||
static void Postfix(ref object __instance)
|
||||
{
|
||||
PropertyInfo autoProp = __instance.GetType().GetRuntimeProperty("autoPlay");
|
||||
if (autoProp == null)
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogError("VideoTamperPatch postfix: autoPlay was not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
MethodInfo playMethod = __instance.GetType().GetMethod("Play");
|
||||
if (playMethod == null)
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogError("VideoTamperPatch postfix: playMethod was not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((bool)autoProp.GetValue(__instance)) playMethod.Invoke(__instance, []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user