Decompiled source of UnknownUpgrades v1.0.0

UnknownUpgrades.dll

Decompiled 15 hours ago
using System;
using System.Diagnostics;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("OrigamiCoder")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bc6a1ca08adcef9a98297fadee20aff0235e1aab")]
[assembly: AssemblyProduct("UnknownUpgrades")]
[assembly: AssemblyTitle("UnknownUpgrades")]
[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 UnknownUpgrades
{
	[HarmonyPatch(typeof(ItemUpgrade))]
	internal static class ItemUpgradePatch
	{
		private static readonly Color CornflowerBlue = new Color(0.3921569f, 0.5843138f, 0.9294118f, 1f);

		private static readonly Color DeepSkyBlue = new Color(0f, 0.7490196f, 1f, 1f);

		private static readonly Color DodgerBlue = new Color(0.1176471f, 48f / 85f, 1f, 1f);

		private static readonly Color SteelBlue = new Color(0.2745098f, 0.509804f, 0.7058824f, 1f);

		private static Color _color = SteelBlue;

		private static readonly string FontName = "Teko-VariableFont_wght SDF 1";

		private static readonly string SpriteName = "emojis";

		private static TMP_FontAsset? _fontAsset;

		private static TMP_SpriteAsset? _spriteAsset;

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		[HarmonyWrapSafe]
		private static void Start_Postfix(ItemUpgrade __instance)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			__instance.itemAttributes.itemName = "???";
			MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>();
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					((Renderer)val).material = new Material(Shader.Find("Standard"));
					((Renderer)val).material.color = _color;
				}
			}
			Light[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Light>();
			Light[] array2 = componentsInChildren2;
			foreach (Light val2 in array2)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					val2.color = _color;
				}
			}
			AddTMP(__instance);
		}

		private static bool TryGetFontAsset(out TMP_FontAsset? fontAsset)
		{
			if ((Object)(object)_fontAsset != (Object)null)
			{
				fontAsset = _fontAsset;
				return true;
			}
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			TMP_FontAsset[] array2 = array;
			foreach (TMP_FontAsset val in array2)
			{
				if (((Object)val).name == FontName)
				{
					fontAsset = val;
					return true;
				}
			}
			fontAsset = null;
			return false;
		}

		private static bool TryGetSpriteAsset(out TMP_SpriteAsset? spriteAsset)
		{
			if ((Object)(object)_spriteAsset != (Object)null)
			{
				spriteAsset = _spriteAsset;
				return true;
			}
			TMP_SpriteAsset[] array = Resources.FindObjectsOfTypeAll<TMP_SpriteAsset>();
			TMP_SpriteAsset[] array2 = array;
			foreach (TMP_SpriteAsset val in array2)
			{
				if (((Object)val).name == SpriteName)
				{
					_spriteAsset = val;
					spriteAsset = _spriteAsset;
					return true;
				}
			}
			spriteAsset = null;
			return false;
		}

		private static void AddTMP(ItemUpgrade upgrade)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Unknown Upgrade Text", new Type[1] { typeof(TextMeshPro) });
			val.transform.SetParent(((Component)upgrade).transform, false);
			val.transform.localScale = Vector3.one;
			val.transform.localPosition = new Vector3(0f, 0f, 0.036f);
			val.transform.localRotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
			RectTransform val2 = (RectTransform)val.transform;
			val2.offsetMin = new Vector2(-0.088f, -0.1335f);
			val2.offsetMax = new Vector2(0.088f, 0.1335f);
			TextMeshPro component = val.GetComponent<TextMeshPro>();
			if (TryGetSpriteAsset(out TMP_SpriteAsset spriteAsset))
			{
				((TMP_Text)component).spriteAsset = spriteAsset;
				((TMP_Text)component).text = "<sprite name=?>";
			}
			else
			{
				if (TryGetFontAsset(out _fontAsset))
				{
					((TMP_Text)component).font = _fontAsset;
				}
				((TMP_Text)component).text = "?";
			}
			((TMP_Text)component).margin = new Vector4(0f, 0f, 0f, 0f);
			((TMP_Text)component).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component).fontSize = 2f;
			((Graphic)component).color = _color;
		}
	}
	[BepInPlugin("OrigamiCoder.UnknownUpgrades", "UnknownUpgrades", "1.0.0")]
	public class UnknownUpgrades : BaseUnityPlugin
	{
		internal static UnknownUpgrades Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

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

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has 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();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}