Decompiled source of VerySmallUIMod v1.2.0

Hopscotch.VerySmallUIMod.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Hopscotch.VerySmallUIMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("Hopscotch.VerySmallUIMod")]
[assembly: AssemblyTitle("VerySmallUIMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace VerySmallUIMod
{
	[BepInPlugin("Hopscotch.VerySmallUIMod", "VerySmallUIMod", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(LoadingScreen), "Awake")]
		private class LoadingScreenAwakePatch
		{
			private static void Postfix(LoadingScreen __instance)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Expected O, but got Unknown
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Expected O, but got Unknown
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Expected O, but got Unknown
				//IL_0223: Unknown result type (might be due to invalid IL or missing references)
				//IL_0244: Unknown result type (might be due to invalid IL or missing references)
				//IL_0265: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)__instance == (Object)null))
				{
					Transform transform = ((Component)__instance).transform;
					if (!((Object)(object)transform == (Object)null) && !((Object)(object)((Component)__instance).transform.Find("PlanePivot") == (Object)null))
					{
						Log.LogInfo((object)"Found plane pivot");
						GameObject val = new GameObject("Tower1", new Type[1] { typeof(RectTransform) });
						val.transform.SetParent(transform, false);
						Image val2 = val.AddComponent<Image>();
						val2.sprite = Tower1;
						Log.LogInfo((object)"Added image");
						val.transform.localPosition = new Vector3(300f, -120f, 0f);
						val.transform.localRotation = Quaternion.Euler(0f, 0f, 341f);
						val.transform.localScale = new Vector3(1.6f, 1.6f, 1.6f);
						GameObject val3 = new GameObject("Tower2", new Type[1] { typeof(RectTransform) });
						val3.transform.SetParent(transform, false);
						Image val4 = val3.AddComponent<Image>();
						val4.sprite = Tower2;
						Log.LogInfo((object)"Added image");
						val3.transform.localPosition = new Vector3(378f, -150f, 0f);
						val3.transform.localRotation = Quaternion.Euler(0f, 0f, 337f);
						val3.transform.localScale = new Vector3(1.6f, 1.6f, 1.6f);
						GameObject val5 = new GameObject("TowerBoom", new Type[1] { typeof(RectTransform) });
						val5.transform.SetParent(transform, false);
						Image val6 = val5.AddComponent<Image>();
						val6.sprite = TowerBoom;
						Log.LogInfo((object)"Added image");
						val5.transform.localPosition = new Vector3(220f, -70f, 0f);
						val5.transform.localRotation = Quaternion.Euler(0f, 0f, 341f);
						val5.transform.localScale = new Vector3(2f, 2f, 2f);
						val5.SetActive(false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(LoadingScreenAnimation), "Update")]
		private class LoadingScreenUpdatePatch
		{
			private static void Postfix(LoadingScreenAnimation __instance)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				Transform transform = GameObject.Find("LoadingScreen(Clone)").transform;
				if (!((Object)(object)transform == (Object)null) && !((Object)(object)((Component)__instance).transform.Find("PlanePivot") == (Object)null))
				{
					Transform val = transform.Find("PlanePivot");
					Transform val2 = val.Find("Plane");
					if ((double)val2.rotation.z < -0.11)
					{
						Log.LogInfo((object)"activate boom");
						Transform val3 = transform.Find("TowerBoom");
						((Component)val3).gameObject.SetActive(true);
					}
				}
			}
		}

		[HarmonyPatch(typeof(LocalizedText), "GetText", new Type[]
		{
			typeof(string),
			typeof(bool)
		})]
		private class LocalizedTextPatch
		{
			private static bool Prefix(string id, bool printDebug, ref string __result)
			{
				return HandleGetTextPatch(id, ref __result);
			}
		}

		[HarmonyPatch(typeof(LocalizedText), "GetText", new Type[]
		{
			typeof(string),
			typeof(Language)
		})]
		private class LocalizedTextPatch3
		{
			private static bool Prefix(string id, Language language, ref string __result)
			{
				return HandleGetTextPatch(id, ref __result);
			}
		}

		[HarmonyPatch(typeof(LocalizedText), "GetText", new Type[]
		{
			typeof(string),
			typeof(TextMeshProUGUI)
		})]
		private class LocalizedTextPatch4
		{
			private static bool Prefix(string id, TextMeshProUGUI text, ref string __result)
			{
				return HandleGetTextPatch(id, ref __result);
			}
		}

		[HarmonyPatch(typeof(LocalizedText), "GetText", new Type[]
		{
			typeof(string),
			typeof(TextMeshPro)
		})]
		private class LocalizedTextPatch5
		{
			private static bool Prefix(string id, TextMeshPro text, ref string __result)
			{
				return HandleGetTextPatch(id, ref __result);
			}
		}

		[HarmonyPatch(typeof(LocalizedText), "GetText", new Type[]
		{
			typeof(string),
			typeof(Text)
		})]
		private class LocalizedTextPatch6
		{
			private static bool Prefix(string id, Text text, ref string __result)
			{
				return HandleGetTextPatch(id, ref __result);
			}
		}

		public static Sprite Tower1;

		public static Sprite Tower2;

		public static Sprite TowerBoom;

		public static int? bingbongindex;

		public const string Id = "Hopscotch.VerySmallUIMod";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "VerySmallUIMod";

		public static string Version => "0.1.0";

		private void Awake()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			Log.LogInfo((object)"Loading assets...");
			loadAllAssets();
			Log.LogInfo((object)"Assets loaded.");
			Harmony val = new Harmony("Hopscotch.VerySmallUIMod");
			val.PatchAll();
		}

		private static bool HandleGetTextPatch(string id, ref string __result)
		{
			if (id == LocalizedText.GetNameIndex("Bing Bong"))
			{
				__result = "OSAMA BING LADEN";
				return false;
			}
			return true;
		}

		private static void TestPatch()
		{
			Log.LogInfo((object)"Test Patch Ran");
		}

		private void loadAllAssets()
		{
			string text = Path.Combine(Paths.PluginPath, "Hopscotch-VerySmallUIMod", "modbundle1");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"Failed to load AssetBundle!");
				return;
			}
			Tower1 = val.LoadAsset<Sprite>("Tower1");
			Tower2 = val.LoadAsset<Sprite>("Tower2");
			TowerBoom = val.LoadAsset<Sprite>("TowerBoom");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}