Decompiled source of UEZortFixes v1.0.0

BepInEx/plugins/KRW's UnityExplorer Zort Fixes.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KRW's UnityExplorer Zort Fixes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KRW's UnityExplorer Zort Fixes")]
[assembly: AssemblyTitle("KRW's UnityExplorer Zort Fixes")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UEZortFixes;

[BepInPlugin("mods.krwclassic.uezortfixes", "KRW's UnityExplorer Zort Fixes", "1.0.0")]
public class UEZortFixesPlugin : BaseUnityPlugin
{
	private const string CameraPath = "PlayerController [connId=0]/viewTransform/Punch/Lean/CameraBob/shaker/ZoomieCameraAnimation/Camera And Insanity";

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("mods.krwclassic.uezortfixes");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"UEZortFixes loaded!");
	}

	private void OnEnable()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnDisable()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name == "Players")
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Players scene loaded. Applying UnityExplorer camera fix...");
			((MonoBehaviour)this).StartCoroutine(ApplyMainCameraTagWithRetry());
		}
	}

	private IEnumerator ApplyMainCameraTagWithRetry()
	{
		GameObject cameraObject = null;
		Camera cam = default(Camera);
		while ((Object)(object)cameraObject == (Object)null)
		{
			cameraObject = GameObject.Find("PlayerController [connId=0]/viewTransform/Punch/Lean/CameraBob/shaker/ZoomieCameraAnimation/Camera And Insanity");
			if ((Object)(object)cameraObject == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Player camera not found yet. Retrying in 1 second...");
				yield return (object)new WaitForSeconds(1f);
			}
			else if (!cameraObject.TryGetComponent<Camera>(ref cam))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Camera object found, but Camera component not ready. Retrying...");
				cameraObject = null;
				yield return (object)new WaitForSeconds(1f);
			}
			else
			{
				cam = null;
			}
		}
		cameraObject.tag = "MainCamera";
		((BaseUnityPlugin)this).Logger.LogInfo((object)"MainCamera tag successfully applied. UnityExplorer should now work.");
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "mods.krwclassic.uezortfixes";

	public const string PLUGIN_NAME = "KRW's UnityExplorer Zort Fixes";

	public const string PLUGIN_VERSION = "1.0.0";
}