Decompiled source of RadarZoom v1.0.1

RadarZoom.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RadarZoom.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RadiationIsCool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationIsCool")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RadarZoom
{
	public class ToggleZoom : NetworkBehaviour
	{
		public int cameraSize;

		private void Start()
		{
		}

		public void ToggleRadarZoom(PlayerControllerB playerControllerB)
		{
			if (cameraSize == 0)
			{
				cameraSize = 1;
			}
			else if (cameraSize == 1)
			{
				cameraSize = 2;
			}
			else if (cameraSize == 2)
			{
				cameraSize = 0;
			}
		}

		public void AddRadarZoom(int num)
		{
			GameObject.Find("StartGameLever").GetComponent<AudioSource>().PlayOneShot(Plugin.zoomSound);
			switch (num)
			{
			case 0:
				cameraSize = 1;
				break;
			case 1:
				cameraSize = 2;
				break;
			case 2:
				cameraSize = 0;
				break;
			}
		}

		private void Update()
		{
			if (cameraSize == 0)
			{
				GameObject.Find("MapCamera").GetComponent<Camera>().orthographicSize = Mathf.Lerp(GameObject.Find("MapCamera").GetComponent<Camera>().orthographicSize, 9.7f * (float)Plugin.configZoom1.Value, Time.deltaTime * 10f);
			}
			else if (cameraSize == 1)
			{
				GameObject.Find("MapCamera").GetComponent<Camera>().orthographicSize = Mathf.Lerp(GameObject.Find("MapCamera").GetComponent<Camera>().orthographicSize, 19.7f * (float)Plugin.configZoom2.Value, Time.deltaTime * 10f);
			}
			else if (cameraSize == 2)
			{
				GameObject.Find("MapCamera").GetComponent<Camera>().orthographicSize = Mathf.Lerp(GameObject.Find("MapCamera").GetComponent<Camera>().orthographicSize, 29.7f * (float)Plugin.configZoom3.Value, Time.deltaTime * 10f);
			}
		}
	}
	[BepInPlugin("Piggy.RadarZoom", "RadarZoom", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Piggy.RadarZoom";

		private const string modName = "RadarZoom";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Piggy.RadarZoom");

		private static Plugin Instance;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		public static GameObject ButtonPrefab;

		public static AudioClip zoomSound;

		public static Material ButtonMaterial;

		public static ConfigEntry<int> configZoom1;

		public static ConfigEntry<int> configZoom2;

		public static ConfigEntry<int> configZoom3;

		public static bool IsKorean;

		public static string PluginDirectory;

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			LoadAssets();
			mls = Logger.CreateLogSource("Piggy.RadarZoom");
			mls.LogInfo((object)"Radar Zoom is loaded");
			configZoom1 = ((BaseUnityPlugin)this).Config.Bind<int>("General", "configZoomFirst", 1, new ConfigDescription("Set the size of level 1 magnification. It is calculated by multiplying.", (AcceptableValueBase)null, Array.Empty<object>()));
			configZoom2 = ((BaseUnityPlugin)this).Config.Bind<int>("General", "configZoomSecond", 1, new ConfigDescription("Set the size of level 2 magnification. It is calculated by multiplying.", (AcceptableValueBase)null, Array.Empty<object>()));
			configZoom3 = ((BaseUnityPlugin)this).Config.Bind<int>("General", "configZoomThird", 1, new ConfigDescription("Set the size of level 3 magnification. It is calculated by multiplying.", (AcceptableValueBase)null, Array.Empty<object>()));
			IsKorean = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Korean", false, "Change Language to Korean").Value;
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(StartOfRoundPatch));
		}

		private void LoadAssets()
		{
			try
			{
				Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory), "radarzoom"));
			}
			catch (Exception ex)
			{
				mls.LogError((object)("Couldn't load asset bundle: " + ex.Message));
				return;
			}
			try
			{
				ButtonPrefab = Bundle.LoadAsset<GameObject>("CameraZoomSwitchButton.prefab");
				zoomSound = Bundle.LoadAsset<AudioClip>("zoom.wav");
				ButtonMaterial = Bundle.LoadAsset<Material>("GreenButton.mat");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded assets!");
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load assets: " + ex2.Message));
			}
		}
	}
}
namespace RadarZoom.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameObject.Find("CameraZoomSwitchButton(Clone)") == (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.ButtonPrefab);
				val.transform.parent = GameObject.Find("CameraMonitorSwitchButton").transform.parent;
				val.transform.localPosition = new Vector3(GameObject.Find("CameraMonitorSwitchButton").transform.localPosition.x, GameObject.Find("CameraMonitorSwitchButton").transform.localPosition.y, 0.397f);
				val.transform.rotation = GameObject.Find("CameraMonitorSwitchButton").transform.rotation;
				((Component)val.transform.GetChild(0)).gameObject.AddComponent<ToggleZoom>();
				((UnityEvent<PlayerControllerB>)(object)((Component)val.transform.GetChild(0)).GetComponent<InteractTrigger>().onInteract).AddListener((UnityAction<PlayerControllerB>)((Component)val.transform.GetChild(0)).GetComponent<ToggleZoom>().ToggleRadarZoom);
				if (Plugin.IsKorean)
				{
					((Component)val.transform.GetChild(0)).GetComponent<InteractTrigger>().hoverTip = "확대 전환하기 : [E]";
				}
				else
				{
					((Component)val.transform.GetChild(0)).GetComponent<InteractTrigger>().hoverTip = "Toggle Zoom : [E]";
				}
			}
		}
	}
}