Decompiled source of JetpackWarning Watermark Remover v1.0.0

BepInEx/plugins/JetpackWarningWatermarkRemover.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JetpackWarningFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JetpackWarningFix")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("79bf4344-ce5b-484d-8af9-eac5bd8f194a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JetpackWarningWatermarkRemover;

[BepInPlugin("Azx.JetpackWarningWatermarkRemover", "JetpackWarning Watermark Remover", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	private Harmony _harmony;

	private static FieldInfo _meterContainerField;

	private static FieldInfo MeterContainerField
	{
		get
		{
			if (_meterContainerField == null)
			{
				Type type = AccessTools.TypeByName("JetpackWarning.JetpackWarningPlugin");
				if (type != null)
				{
					_meterContainerField = AccessTools.Field(type, "meterContainer");
				}
			}
			return _meterContainerField;
		}
	}

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		_harmony = new Harmony("Azx.JetpackWarningWatermarkRemover");
		TryPatchJetpackWarning();
		SceneManager.sceneLoaded += SceneLoadedHide;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"JetpackWarning Watermark Remover loaded.");
	}

	private void TryPatchJetpackWarning()
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		Type type = AccessTools.TypeByName("JetpackWarning.JetpackWarningPlugin");
		if (type == null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"JetpackWarning not detected, nothing to patch.");
			return;
		}
		MethodInfo methodInfo = AccessTools.Method(type, "OnSceneRelayLoaded", new Type[2]
		{
			typeof(Scene),
			typeof(LoadSceneMode)
		}, (Type[])null);
		if (methodInfo == null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find JetpackWarning.OnSceneRelayLoaded to patch.");
			return;
		}
		HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("HideInRelayPostfix", BindingFlags.Static | BindingFlags.NonPublic));
		_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched JetpackWarning successfully.");
	}

	private static void HideInRelayPostfix(Scene scene, LoadSceneMode loadMode)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		HideMeterIfRelay(scene);
	}

	private void SceneLoadedHide(Scene scene, LoadSceneMode mode)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		HideMeterIfRelay(scene);
	}

	private static void HideMeterIfRelay(Scene scene)
	{
		if (((Scene)(ref scene)).name != "SampleSceneRelay")
		{
			return;
		}
		FieldInfo meterContainerField = MeterContainerField;
		if (!(meterContainerField == null))
		{
			object? value = meterContainerField.GetValue(null);
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if ((Object)(object)val != (Object)null)
			{
				val.SetActive(false);
			}
		}
	}
}