Decompiled source of Vision Mod v1.0.0

Vision Mod.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Teleport_Thingy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Teleport_Thingy")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0460d0a2-fff8-4a5b-ac4a-29c7832e1a7a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Teleport_Thingy;

[BepInPlugin("com.000diggity000.vision_mod", "Vision Mod", "1.0.0")]
public class Main : BaseUnityPlugin
{
	public static AssetBundle bundle;

	public static GameObject vision;

	public static Image visionImage;

	public static bool inMatch;

	public static Stream GetResourceStream(string namespaceName, string path)
	{
		return Assembly.GetExecutingAssembly().GetManifestResourceStream(namespaceName + "." + path);
	}

	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("com.000diggity000.vision_mod");
		val.PatchAll(typeof(Patches));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Vision Mod Loaded");
	}

	private void Start()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		string pluginPath = Paths.PluginPath;
		string namespaceName = "Teleport_Thingy";
		string path = "test.bundle";
		bundle = AssetBundle.LoadFromStream(GetResourceStream(namespaceName, path));
		GameObject val = (GameObject)bundle.LoadAsset("Vision_Canvas");
		vision = Object.Instantiate<GameObject>(val, Vector2.op_Implicit(new Vector2(0f, 0f)), Quaternion.identity);
		Object.DontDestroyOnLoad((Object)(object)vision);
		visionImage = vision.GetComponentInChildren<Image>();
		((Behaviour)visionImage).enabled = false;
	}

	private void FixedUpdate()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if (inMatch)
		{
			((Transform)((Graphic)visionImage).rectTransform).localScale = Vector2.op_Implicit(new Vector2(((Transform)((Graphic)visionImage).rectTransform).localScale.x + 0.0008f, ((Transform)((Graphic)visionImage).rectTransform).localScale.y + 0.0008f));
		}
	}

	private void OnApplicationQuit()
	{
	}

	public static void ZoomOut()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (((Transform)((Graphic)visionImage).rectTransform).localScale.x < 50f)
		{
			((Transform)((Graphic)visionImage).rectTransform).localScale = Vector2.op_Implicit(new Vector2(((Transform)((Graphic)visionImage).rectTransform).localScale.x + 0.0008f, ((Transform)((Graphic)visionImage).rectTransform).localScale.y + 0.0008f));
			ZoomOut();
		}
		else
		{
			((Behaviour)visionImage).enabled = false;
		}
	}
}
public class Patches
{
	[HarmonyPatch(typeof(GameSessionHandler), "LeaveGame")]
	[HarmonyPrefix]
	public static void LeavePatch()
	{
		Main.inMatch = false;
		((Behaviour)Main.visionImage).enabled = false;
	}

	[HarmonyPatch(typeof(GameSessionHandler), "LoadNextLevelScene")]
	[HarmonyPrefix]
	public static void NextLevelPatch()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		((Behaviour)Main.visionImage).enabled = true;
		((Transform)((Graphic)Main.visionImage).rectTransform).localScale = new Vector3(1f, 1f, 1f);
		Main.inMatch = true;
	}

	[HarmonyPatch(typeof(GameSessionHandler), "LoadAbilitySelectScene")]
	[HarmonyPrefix]
	public static void AbilitySelectPatch()
	{
		Main.inMatch = false;
		((Behaviour)Main.visionImage).enabled = false;
	}

	[HarmonyPatch(typeof(ExitGameMenu), "LeaveGame")]
	[HarmonyPostfix]
	public static void LeaveGamePatch()
	{
		Main.inMatch = false;
		((Behaviour)Main.visionImage).enabled = false;
	}

	[HarmonyPatch(typeof(GameSessionHandler), "DeclareGameUndecided")]
	[HarmonyPrefix]
	public static void UndecidedPatch()
	{
		Main.inMatch = false;
		((Behaviour)Main.visionImage).enabled = false;
	}

	[HarmonyPatch(typeof(GameSessionHandler), "WinGame")]
	[HarmonyPrefix]
	public static void WinGamePatch()
	{
		Main.inMatch = false;
		((Behaviour)Main.visionImage).enabled = false;
	}

	[HarmonyPatch(typeof(CharacterSelectHandler), "TryStartGame")]
	[HarmonyPrefix]
	public static void StartPatch(CharacterSelectHandler __instance)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		((Behaviour)Main.visionImage).enabled = true;
		((Transform)((Graphic)Main.visionImage).rectTransform).localScale = new Vector3(1f, 1f, 1f);
		Main.inMatch = true;
	}

	[HarmonyPatch(typeof(CharacterSelectHandler_online), "TryStartGame")]
	[HarmonyPrefix]
	public static void StartOnlinePatch(CharacterSelectHandler_online __instance)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		((Behaviour)Main.visionImage).enabled = true;
		((Transform)((Graphic)Main.visionImage).rectTransform).localScale = new Vector3(1f, 1f, 1f);
		Main.inMatch = true;
	}
}