Decompiled source of Silver Pot Icon v0.1.0

Silver_Pot_Icon.dll

Decompiled 3 weeks 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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Silver_Pot_Icon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template Mod")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("Silver_Pot_Icon")]
[assembly: AssemblyTitle("Silver_Pot_Icon")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Silver_Pot_Icon
{
	[BepInPlugin("BedlessSleeper_Silver_Pot_Icon", "Silver_Pot_Icon", "0.1.0")]
	public class Plugin : BasePlugin
	{
		public const string MODNAME = "Silver_Pot_Icon";

		public const string AUTHOR = "BedlessSleeper";

		public const string GUID = "BedlessSleeper_Silver_Pot_Icon";

		public const string VERSION = "0.1.0";

		public static ManualLogSource log;

		public override void Load()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			log = ((BasePlugin)this).Log;
			ManualLogSource val = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Silver_Pot_Icon");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("0.1.0");
			}
			val.LogInfo(val2);
			Harmony val3 = new Harmony("BedlessSleeper_Silver_Pot_Icon");
			val3.PatchAll();
		}
	}
	[HarmonyPatch(typeof(SpawnInteractables), "SpawnOther")]
	public static class SpawnInteractables_SpawnOther_PotBruteForce
	{
		[HarmonyPostfix]
		public static void Postfix(SpawnInteractables __instance)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[2] { "PotSmallSilver(Clone)", "PotBigSilver(Clone)" };
			string[] array2 = array;
			bool flag = default(bool);
			foreach (string text in array2)
			{
				int num = 0;
				while (num++ < 99)
				{
					GameObject val = null;
					try
					{
						val = GameObject.Find(text);
					}
					catch (Exception ex)
					{
						ManualLogSource log = Plugin.log;
						BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("GameObject.Find threw for '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
						}
						log.LogError(val2);
						break;
					}
					if ((Object)(object)val == (Object)null)
					{
						break;
					}
					Transform val3 = FindChildByName(val.transform, "Quad");
					if ((Object)(object)val3 != (Object)null)
					{
						Renderer component = ((Component)val3).GetComponent<Renderer>();
						if ((Object)(object)component != (Object)null)
						{
							component.material = new Material(component.material);
							component.material.color = Color32.op_Implicit(new Color32((byte)51, (byte)204, byte.MaxValue, byte.MaxValue));
						}
						else
						{
							ManualLogSource log2 = Plugin.log;
							BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Quad found but has no Renderer for ");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val).name);
							}
							log2.LogInfo(val4);
						}
					}
					else
					{
						ManualLogSource log3 = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("No Quad child found for ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val).name);
						}
						log3.LogInfo(val4);
					}
					try
					{
						((Object)val).name = text + "_processed_" + Guid.NewGuid().ToString("N").Substring(0, 8);
					}
					catch (Exception ex2)
					{
						ManualLogSource log4 = Plugin.log;
						BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(23, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to rename pot ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex2);
						}
						log4.LogError(val2);
						break;
					}
				}
			}
		}

		private static Transform FindChildByName(Transform parent, string name)
		{
			if (((Object)parent).name == name)
			{
				return parent;
			}
			for (int i = 0; i < parent.childCount; i++)
			{
				Transform child = parent.GetChild(i);
				Transform val = FindChildByName(child, name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}
	}
}