Decompiled source of Impossible Repo v1.0.1

Repo2.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Repo2")]
[assembly: AssemblyTitle("Repo2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 Repo2TotalConversion
{
	[BepInPlugin("Omniscye.Repo2.TotalConversion", "Repo2 Total Conversion", "2.0.0")]
	public class Repo2 : BaseUnityPlugin
	{
		internal static Random Rand = new Random(777);

		internal static int Seed;

		internal static int[] DigitMap = Enumerable.Range(0, 10).ToArray();

		internal static GameObject StartupOverlay;

		internal static bool OverlayShown;

		internal static string PluginDir = "";

		internal static Repo2 Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath;
			Patch();
			GameObject val = new GameObject("Repo2DirectorHost");
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<Repo2Director>();
			Object.DontDestroyOnLoad((Object)(object)val);
			GameObject val2 = new GameObject("Repo2TextureHost");
			((Object)val2).hideFlags = (HideFlags)61;
			val2.AddComponent<Repo2TextureReplacer>();
			Object.DontDestroyOnLoad((Object)(object)val2);
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll(typeof(P_Splash));
			Harmony.PatchAll(typeof(P_SemiDollar));
			Harmony.PatchAll(typeof(P_PlayerSpeed));
			Harmony.PatchAll(typeof(P_CameraTilt));
			Harmony.PatchAll(typeof(P_InventorySlot));
			Harmony.PatchAll(typeof(P_ShopChaos));
			Harmony.PatchAll(typeof(P_EnemyWeird));
			Harmony.PatchAll(typeof(P_LevelDone));
			Harmony.PatchAll(typeof(P_CameraZoom));
			Harmony.PatchAll(typeof(P_TextureOverride_ResTyped));
			Harmony.PatchAll(typeof(P_TextureOverride_ResUntyped));
			Harmony.PatchAll(typeof(P_TextureOverride_BundleTyped));
			Harmony.PatchAll(typeof(P_TextureOverride_BundleUntyped));
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public class Repo2Director : MonoBehaviourPunCallbacks
	{
		private const string KSeed = "repo2.seed";

		private const string KGravity = "repo2.gravity";

		private const string KTimescale = "repo2.timescale";

		private float t;

		private Vector3 gBase;

		private bool seeded;

		private float timePulse;

		private void Start()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			gBase = Physics.gravity;
			((MonoBehaviour)this).InvokeRepeating("EnsureSeed", 0.2f, 1f);
		}

		private void EnsureSeed()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (PhotonNetwork.InRoom && !seeded && PhotonNetwork.IsMasterClient)
			{
				int num = Random.Range(int.MinValue, int.MaxValue);
				Hashtable val = new Hashtable();
				val[(object)"repo2.seed"] = num;
				val[(object)"repo2.gravity"] = 1f;
				val[(object)"repo2.timescale"] = 1f;
				PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			}
			TryAdopt();
		}

		private void TryAdopt()
		{
			if (!PhotonNetwork.InRoom)
			{
				return;
			}
			Room currentRoom = PhotonNetwork.CurrentRoom;
			if (currentRoom != null && ((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"repo2.seed", out object value))
			{
				Repo2.Seed = Convert.ToInt32(value);
				Repo2.Rand = new Random(Repo2.Seed);
				Repo2.DigitMap = (from _ in Enumerable.Range(0, 10)
					orderby Repo2.Rand.Next()
					select _).ToArray();
				seeded = true;
			}
		}

		private void Update()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			if (!seeded)
			{
				TryAdopt();
			}
			t += Time.unscaledDeltaTime;
			float num = Mathf.Sin(t * 0.6f);
			float num2 = Mathf.Lerp(-0.5f, 1.5f, (num + 1f) * 0.5f);
			Physics.gravity = gBase * num2;
			timePulse += Time.deltaTime;
			float num3 = 0.85f + Mathf.Abs(Mathf.Sin(timePulse * 0.35f + (float)Repo2.Seed)) * 0.65f;
			Time.timeScale = Mathf.Clamp(num3, 0.33f, 1.75f);
			if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
			{
				Hashtable val = new Hashtable();
				val[(object)"repo2.gravity"] = num2;
				val[(object)"repo2.timescale"] = Time.timeScale;
				PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			}
		}

		public override void OnJoinedRoom()
		{
			TryAdopt();
		}

		public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"repo2.gravity"))
			{
				float num = Convert.ToSingle(propertiesThatChanged[(object)"repo2.gravity"]);
				Physics.gravity = gBase * num;
			}
			if (((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"repo2.timescale"))
			{
				float num2 = Convert.ToSingle(propertiesThatChanged[(object)"repo2.timescale"]);
				Time.timeScale = Mathf.Clamp(num2, 0.33f, 1.75f);
			}
		}
	}
	[HarmonyPatch]
	public static class P_Splash
	{
		private class OverlayPulse : MonoBehaviour
		{
			private float t;

			private TextMeshProUGUI tmp;

			private void Awake()
			{
				tmp = ((Component)this).GetComponentInChildren<TextMeshProUGUI>(true);
			}

			private void Update()
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				t += Time.unscaledDeltaTime;
				float num = 1f + Mathf.Sin(t * 3.2f) * 0.06f;
				if (Object.op_Implicit((Object)(object)tmp))
				{
					((Transform)((TMP_Text)tmp).rectTransform).localScale = Vector3.one * num;
				}
				if (t > 4.2f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("SplashScreen");
			return AccessTools.Method(type, "StateSemiwork", (Type[])null, (Type[])null);
		}

		private static void Postfix()
		{
			if (!Repo2.OverlayShown)
			{
				SplashScreenUI val = Object.FindObjectOfType<SplashScreenUI>();
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.semiworkTransform))
				{
					((Component)val.semiworkTransform).gameObject.SetActive(false);
				}
				CreateOverlay("REPO 2");
				Repo2.OverlayShown = true;
			}
		}

		private static void CreateOverlay(string text)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Repo2.StartupOverlay))
			{
				GameObject val = new GameObject("Repo2_Overlay");
				Canvas val2 = val.AddComponent<Canvas>();
				val2.renderMode = (RenderMode)0;
				CanvasScaler val3 = val.AddComponent<CanvasScaler>();
				val3.uiScaleMode = (ScaleMode)1;
				val.AddComponent<GraphicRaycaster>();
				TextMeshProUGUI val4 = new GameObject("Text").AddComponent<TextMeshProUGUI>();
				((Transform)((TMP_Text)val4).rectTransform).SetParent(val.transform, false);
				((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val4).fontSize = 128f;
				((TMP_Text)val4).text = text;
				((TMP_Text)val4).enableWordWrapping = false;
				((Graphic)val4).color = new Color(1f, 0.1f, 0.7f, 1f);
				((TMP_Text)val4).rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
				((TMP_Text)val4).rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
				((TMP_Text)val4).rectTransform.anchoredPosition = Vector2.zero;
				Repo2.StartupOverlay = val;
				Object.DontDestroyOnLoad((Object)(object)val);
				val.AddComponent<OverlayPulse>();
			}
		}
	}
	[HarmonyPatch]
	public static class P_SemiDollar
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("SemiFunc");
			return AccessTools.Method(type, "DollarGetString", new Type[1] { typeof(int) }, (Type[])null);
		}

		private static void Postfix(ref string __result, int value)
		{
			int[] digitMap = Repo2.DigitMap;
			char[] array = __result.ToCharArray();
			for (int i = 0; i < array.Length; i++)
			{
				char c = array[i];
				if (c >= '0' && c <= '9')
				{
					int num = c - 48;
					array[i] = (char)(48 + digitMap[num]);
				}
			}
			string text = new string(array);
			if ((value & 1) == 0)
			{
				text = text.Replace(".", ",");
			}
			__result = text;
		}
	}
	[HarmonyPatch]
	public static class P_PlayerSpeed
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("PlayerController");
			return AccessTools.Method(type, "OverrideSpeedLogic", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			Type type = __instance.GetType();
			FieldInfo fieldInfo = AccessTools.Field(type, "MoveSpeed");
			FieldInfo fieldInfo2 = AccessTools.Field(type, "SprintSpeed");
			FieldInfo fieldInfo3 = AccessTools.Field(type, "CrouchSpeed");
			FieldInfo fieldInfo4 = AccessTools.Field(type, "rb");
			if (!(fieldInfo == null) && !(fieldInfo2 == null) && !(fieldInfo3 == null))
			{
				float num = (float)fieldInfo.GetValue(__instance);
				float num2 = (float)fieldInfo2.GetValue(__instance);
				float num3 = (float)fieldInfo3.GetValue(__instance);
				float num4 = Mathf.Abs(Mathf.Sin(Time.time * 0.35f + (float)Repo2.Seed)) + 0.25f;
				float num5 = Mathf.Sign(Mathf.Sin(Time.time * 0.11f + (float)Repo2.Seed * 0.001f));
				float num6 = Mathf.Clamp(num4 * 1.85f, 0.1f, 3.75f);
				fieldInfo.SetValue(__instance, Mathf.Clamp(num * num6, 0.05f, 7f));
				fieldInfo2.SetValue(__instance, Mathf.Clamp(num2 * (num6 + 0.5f * num5), 0.05f, 9f));
				fieldInfo3.SetValue(__instance, Mathf.Clamp(num3 * (1.35f * num6), 0.01f, 6f));
				object? obj = fieldInfo4?.GetValue(__instance);
				Rigidbody val = (Rigidbody)((obj is Rigidbody) ? obj : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.drag = Mathf.Clamp(0.25f + Mathf.PingPong(Time.time * 0.6f, 3f), 0f, 4f);
					val.angularDrag = Mathf.Clamp(0.05f + Mathf.PingPong(Time.time * 0.44f, 0.7f), 0f, 2f);
				}
			}
		}
	}
	[HarmonyPatch]
	public static class P_CameraTilt
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("CameraTilt");
			return AccessTools.Method(type, "Update", (Type[])null, (Type[])null);
		}

		private static void Prefix(object __instance)
		{
			Type type = __instance.GetType();
			FieldInfo fieldInfo = AccessTools.Field(type, "tiltZ");
			FieldInfo fieldInfo2 = AccessTools.Field(type, "tiltX");
			FieldInfo fieldInfo3 = AccessTools.Field(type, "tiltZMax");
			FieldInfo fieldInfo4 = AccessTools.Field(type, "tiltXMax");
			if (!(fieldInfo == null) && !(fieldInfo2 == null) && !(fieldInfo3 == null) && !(fieldInfo4 == null))
			{
				float num = 1f + Mathf.Abs(Mathf.Sin(Time.time * 0.75f + (float)Repo2.Seed)) * 2.25f;
				fieldInfo.SetValue(__instance, 250f * num);
				fieldInfo2.SetValue(__instance, 250f * num);
				fieldInfo3.SetValue(__instance, 12f * num);
				fieldInfo4.SetValue(__instance, 12f * num);
			}
		}
	}
	[HarmonyPatch]
	public static class P_InventorySlot
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("Inventory");
			return AccessTools.Method(type, "GetFirstFreeInventorySpotIndex", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance, ref int __result)
		{
			Type type = __instance.GetType();
			MethodInfo methodInfo = AccessTools.Method(type, "GetAllSpots", (Type[])null, (Type[])null);
			if (!(methodInfo.Invoke(__instance, null) is IEnumerable enumerable))
			{
				return;
			}
			List<(int, object)> list = new List<(int, object)>();
			int num = 0;
			foreach (object item in enumerable)
			{
				MethodInfo methodInfo2 = AccessTools.Method(item.GetType(), "IsOccupied", (Type[])null, (Type[])null);
				if (!(bool)methodInfo2.Invoke(item, null))
				{
					list.Add((num, item));
				}
				num++;
			}
			if (list.Count != 0)
			{
				int index = Mathf.Abs(Repo2.Rand.Next()) % list.Count;
				__result = list[index].Item1;
			}
		}
	}
	[HarmonyPatch]
	public static class P_ShopChaos
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("ShopManager");
			return AccessTools.Method(type, "ShopInitialize", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			Type type = __instance.GetType();
			if (!(AccessTools.Field(type, "itemVolumes")?.GetValue(__instance) is IList list) || list.Count == 0)
			{
				return;
			}
			List<object> list2 = new List<object>();
			foreach (object item in list)
			{
				list2.Add(item);
			}
			for (int i = 0; i < list2.Count; i++)
			{
				int index = Repo2.Rand.Next(list2.Count);
				object value = list2[i];
				list2[i] = list2[index];
				list2[index] = value;
			}
			list.Clear();
			foreach (object item2 in list2)
			{
				list.Add(item2);
			}
		}
	}
	[HarmonyPatch]
	public static class P_EnemyWeird
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("Enemy");
			return AccessTools.Method(type, "Start", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)((__instance is Component) ? __instance : null)).transform;
			float num = 0.5f + Mathf.Abs(Mathf.Sin((float)Repo2.Rand.NextDouble() * 3.1415f + Time.time)) * 1.75f;
			transform.localScale = Vector3.one * Mathf.Clamp(num, 0.5f, 2.25f);
		}
	}
	[HarmonyPatch]
	public static class P_LevelDone
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("LevelGenerator");
			return AccessTools.Method(type, "GenerateDone", (Type[])null, (Type[])null);
		}

		private static void Postfix()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			RenderSettings.ambientLight = Color.Lerp(new Color(0.1f, 0f, 0.1f, 1f), new Color(0f, 0.1f, 0.15f, 1f), Mathf.Abs(Mathf.Sin(Time.time * 0.7f)));
			RenderSettings.fog = true;
			RenderSettings.fogDensity = 0.01f + Mathf.Abs(Mathf.Sin(Time.time * 0.5f)) * 0.02f;
		}
	}
	[HarmonyPatch]
	public static class P_CameraZoom
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("CameraZoom");
			return AccessTools.Method(type, "Update", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			Type type = __instance.GetType();
			if (!(AccessTools.Field(type, "cams")?.GetValue(__instance) is IEnumerable enumerable))
			{
				return;
			}
			float num = 60f + Mathf.Sin(Time.time * 0.75f + (float)Repo2.Seed) * 20f;
			foreach (object item in enumerable)
			{
				Camera val = (Camera)((item is Camera) ? item : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.fieldOfView = Mathf.Clamp(num, 40f, 110f);
				}
			}
		}
	}
	internal static class Repo2TextureBank
	{
		private static Texture2D _tex;

		private static Sprite _sprite;

		private static bool _loaded;

		private static readonly string target = "repo_logo_shadow_alpha";

		public static Texture2D Tex
		{
			get
			{
				Ensure();
				return _tex;
			}
		}

		public static Sprite Sprite
		{
			get
			{
				Ensure();
				return _sprite;
			}
		}

		public static string TargetName => target;

		private static bool TryLoadPng(Texture2D t, byte[] data, bool markNonReadable)
		{
			Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule") ?? Type.GetType("UnityEngine.ImageConversion, UnityEngine");
			if (type == null)
			{
				return false;
			}
			MethodInfo methodInfo = type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[3]
			{
				typeof(Texture2D),
				typeof(byte[]),
				typeof(bool)
			}, null) ?? type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[2]
			{
				typeof(Texture2D),
				typeof(byte[])
			}, null);
			if (methodInfo == null)
			{
				return false;
			}
			object[] parameters = ((methodInfo.GetParameters().Length != 3) ? new object[2] { t, data } : new object[3] { t, data, markNonReadable });
			object obj = methodInfo.Invoke(null, parameters);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}

		public static void Ensure()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			if (_loaded)
			{
				return;
			}
			byte[] array = null;
			string path = Path.Combine(Repo2.PluginDir, "repo_logo_shadow_alpha.png");
			if (File.Exists(path))
			{
				array = File.ReadAllBytes(path);
			}
			else
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string n) => n.EndsWith("repo_logo_shadow_alpha.png", StringComparison.OrdinalIgnoreCase));
				if (text != null)
				{
					using Stream stream = executingAssembly.GetManifestResourceStream(text);
					if (stream != null)
					{
						using MemoryStream memoryStream = new MemoryStream();
						stream.CopyTo(memoryStream);
						array = memoryStream.ToArray();
					}
				}
			}
			if (array != null)
			{
				Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false);
				if (TryLoadPng(val, array, markNonReadable: true))
				{
					((Texture)val).wrapMode = (TextureWrapMode)1;
					((Texture)val).filterMode = (FilterMode)1;
					((Object)val).name = target;
					_tex = val;
				}
			}
			if ((Object)(object)_tex == (Object)null)
			{
				Texture2D val2 = new Texture2D(512, 256, (TextureFormat)5, false);
				Color32[] array2 = (Color32[])(object)new Color32[131072];
				for (int i = 0; i < 256; i++)
				{
					for (int j = 0; j < 512; j++)
					{
						array2[i * 512 + j] = (((((j >> 4) ^ (i >> 4)) & 1) == 0) ? new Color32(byte.MaxValue, (byte)0, byte.MaxValue, byte.MaxValue) : new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
					}
				}
				val2.SetPixels32(array2);
				val2.Apply(false, true);
				((Texture)val2).wrapMode = (TextureWrapMode)1;
				((Texture)val2).filterMode = (FilterMode)1;
				((Object)val2).name = target;
				_tex = val2;
			}
			((Object)_tex).hideFlags = (HideFlags)61;
			_sprite = Sprite.Create(_tex, new Rect(0f, 0f, (float)((Texture)_tex).width, (float)((Texture)_tex).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)_sprite).name = target;
			((Object)_sprite).hideFlags = (HideFlags)61;
			_loaded = true;
		}

		public static bool NameMatch(Object o)
		{
			if (!Object.op_Implicit(o))
			{
				return false;
			}
			string name = o.name;
			if (string.IsNullOrEmpty(name))
			{
				return false;
			}
			name = name.ToLowerInvariant();
			if (name.EndsWith(".png"))
			{
				name = name.Substring(0, name.Length - 4);
			}
			return name == target || name.EndsWith("/" + target) || name.Contains(target);
		}
	}
	public class Repo2TextureReplacer : MonoBehaviour
	{
		private void OnEnable()
		{
			SceneManager.sceneLoaded += OnScene;
			((MonoBehaviour)this).InvokeRepeating("Sweep", 0.5f, 2f);
		}

		private void OnDisable()
		{
			SceneManager.sceneLoaded -= OnScene;
			((MonoBehaviour)this).CancelInvoke("Sweep");
		}

		private void OnScene(Scene s, LoadSceneMode m)
		{
			Sweep();
		}

		private void Sweep()
		{
			Repo2TextureBank.Ensure();
			Image[] array = Resources.FindObjectsOfTypeAll<Image>();
			Image[] array2 = array;
			foreach (Image val in array2)
			{
				Sprite sprite = val.sprite;
				if ((Object.op_Implicit((Object)(object)sprite) && Repo2TextureBank.NameMatch((Object)(object)sprite)) || (Object.op_Implicit((Object)(object)sprite) && Repo2TextureBank.NameMatch((Object)(object)sprite.texture)))
				{
					val.sprite = Repo2TextureBank.Sprite;
				}
			}
			RawImage[] array3 = Resources.FindObjectsOfTypeAll<RawImage>();
			RawImage[] array4 = array3;
			foreach (RawImage val2 in array4)
			{
				Texture texture = val2.texture;
				if (Object.op_Implicit((Object)(object)texture) && Repo2TextureBank.NameMatch((Object)(object)texture))
				{
					val2.texture = (Texture)(object)Repo2TextureBank.Tex;
				}
			}
			SpriteRenderer[] array5 = Resources.FindObjectsOfTypeAll<SpriteRenderer>();
			SpriteRenderer[] array6 = array5;
			foreach (SpriteRenderer val3 in array6)
			{
				Sprite sprite2 = val3.sprite;
				if ((Object.op_Implicit((Object)(object)sprite2) && Repo2TextureBank.NameMatch((Object)(object)sprite2)) || (Object.op_Implicit((Object)(object)sprite2) && Repo2TextureBank.NameMatch((Object)(object)sprite2.texture)))
				{
					val3.sprite = Repo2TextureBank.Sprite;
				}
			}
			Renderer[] array7 = Resources.FindObjectsOfTypeAll<Renderer>();
			Renderer[] array8 = array7;
			foreach (Renderer val4 in array8)
			{
				Material[] sharedMaterials = val4.sharedMaterials;
				if (sharedMaterials == null)
				{
					continue;
				}
				foreach (Material val5 in sharedMaterials)
				{
					if (Object.op_Implicit((Object)(object)val5) && val5.HasProperty("_MainTex"))
					{
						Texture mainTexture = val5.mainTexture;
						if (Object.op_Implicit((Object)(object)mainTexture) && Repo2TextureBank.NameMatch((Object)(object)mainTexture))
						{
							val5.mainTexture = (Texture)(object)Repo2TextureBank.Tex;
						}
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public static class P_TextureOverride_ResTyped
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(Resources), "Load", new Type[2]
			{
				typeof(string),
				typeof(Type)
			}, (Type[])null);
		}

		private static bool Prefix(string path, Type systemTypeInstance, ref Object __result)
		{
			if (string.IsNullOrEmpty(path))
			{
				return true;
			}
			string text = path.ToLowerInvariant();
			if (text.EndsWith(".png"))
			{
				text = text.Substring(0, text.Length - 4);
			}
			if (text.Contains(Repo2TextureBank.TargetName))
			{
				Repo2TextureBank.Ensure();
				if (systemTypeInstance == typeof(Texture2D))
				{
					__result = (Object)(object)Repo2TextureBank.Tex;
					return false;
				}
				if (systemTypeInstance == typeof(Sprite))
				{
					__result = (Object)(object)Repo2TextureBank.Sprite;
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch]
	public static class P_TextureOverride_ResUntyped
	{
		private static MethodBase TargetMethod()
		{
			return (from m in typeof(Resources).GetMethods(BindingFlags.Static | BindingFlags.Public)
				where m.Name == "Load" && !m.IsGenericMethodDefinition
				select m).First(delegate(MethodInfo m)
			{
				ParameterInfo[] parameters = m.GetParameters();
				return parameters.Length == 1 && parameters[0].ParameterType == typeof(string);
			});
		}

		private static bool Prefix(string path, ref Object __result)
		{
			if (string.IsNullOrEmpty(path))
			{
				return true;
			}
			string text = path.ToLowerInvariant();
			if (text.EndsWith(".png"))
			{
				text = text.Substring(0, text.Length - 4);
			}
			if (text.Contains(Repo2TextureBank.TargetName))
			{
				Repo2TextureBank.Ensure();
				__result = (Object)(object)Repo2TextureBank.Tex;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	public static class P_TextureOverride_BundleTyped
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(AssetBundle), "LoadAsset", new Type[2]
			{
				typeof(string),
				typeof(Type)
			}, (Type[])null);
		}

		private static bool Prefix(AssetBundle __instance, string name, Type type, ref Object __result)
		{
			if (string.IsNullOrEmpty(name))
			{
				return true;
			}
			string text = name.ToLowerInvariant();
			if (text.EndsWith(".png"))
			{
				text = text.Substring(0, text.Length - 4);
			}
			if (text.Contains(Repo2TextureBank.TargetName))
			{
				Repo2TextureBank.Ensure();
				if (type == typeof(Texture2D))
				{
					__result = (Object)(object)Repo2TextureBank.Tex;
					return false;
				}
				if (type == typeof(Sprite))
				{
					__result = (Object)(object)Repo2TextureBank.Sprite;
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch]
	public static class P_TextureOverride_BundleUntyped
	{
		private static MethodBase TargetMethod()
		{
			return (from m in typeof(AssetBundle).GetMethods(BindingFlags.Instance | BindingFlags.Public)
				where m.Name == "LoadAsset" && !m.IsGenericMethodDefinition
				select m).First(delegate(MethodInfo m)
			{
				ParameterInfo[] parameters = m.GetParameters();
				return parameters.Length == 1 && parameters[0].ParameterType == typeof(string);
			});
		}

		private static bool Prefix(AssetBundle __instance, string name, ref Object __result)
		{
			if (string.IsNullOrEmpty(name))
			{
				return true;
			}
			string text = name.ToLowerInvariant();
			if (text.EndsWith(".png"))
			{
				text = text.Substring(0, text.Length - 4);
			}
			if (text.Contains(Repo2TextureBank.TargetName))
			{
				Repo2TextureBank.Ensure();
				__result = (Object)(object)Repo2TextureBank.Tex;
				return false;
			}
			return true;
		}
	}
}