Decompiled source of BetterThiefWarning v1.0.1

BetterThiefWarning.dll

Decompiled 7 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 System.Threading.Tasks;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
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("BetterThiefWarning")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("BetterThiefWarning")]
[assembly: AssemblyTitle("BetterThiefWarning")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BetterThiefWarning
{
	[BepInPlugin("BetterThiefWarning", "Better Thief Warning", "1.0.0")]
	public class BetterThiefWarning : BaseUnityPlugin
	{
		private static Harmony Harmony;

		private static BetterThiefWarning instance;

		public static BetterThiefWarning Instance
		{
			get
			{
				if ((Object)(object)instance == (Object)null)
				{
					instance = new BetterThiefWarning();
				}
				return instance;
			}
		}

		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Harmony = new Harmony("BetterThiefWarning");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Better Thief Warning Loaded!");
			Harmony.PatchAll();
		}

		public void OnDestroy()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Better Thief Warning Unloaded!");
			Harmony.UnpatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BetterThiefWarning";

		public const string PLUGIN_NAME = "BetterThiefWarning";

		public const string PLUGIN_VERSION = "1.0.0.0";
	}
}
namespace BetterThiefWarning.Patches
{
	[HarmonyPatch(typeof(NPC_Info))]
	public class NPC_InfoPatches : MonoBehaviour
	{
		[HarmonyPostfix]
		[HarmonyPatch("CreateNPCCharacter")]
		private static async void CreateNPCCharacter(NPC_Info __instance)
		{
			Transform canvas = ((Component)__instance).transform.Find("ThiefCanvas");
			if (!__instance.isAThief || (Object)(object)canvas == (Object)null)
			{
				return;
			}
			((Component)canvas).gameObject.SetActive(true);
			Transform obj = canvas.Find("ThiefSymbol");
			Image image = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			if (!((Object)(object)image == (Object)null))
			{
				Transform obj2 = ((Component)image).transform.Find("Cross");
				if (obj2 != null)
				{
					((Component)obj2).gameObject.SetActive(false);
				}
				await SetImage(image, "https://i.ibb.co/Yp1WWvr/thief.png");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("UserCode_RpcShowThief")]
		private static bool UserCode_RpcShowThief()
		{
			return false;
		}

		private static async Task SetImage(Image image, string url)
		{
			UnityWebRequest www = UnityWebRequestTexture.GetTexture(url);
			Awaiter val = AsyncOperationAwaitableExtensions.GetAwaiter((AsyncOperation)(object)www.SendWebRequest());
			if (!((Awaiter)(ref val)).IsCompleted)
			{
				await val;
				Awaiter val2 = default(Awaiter);
				val = val2;
			}
			((Awaiter)(ref val)).GetResult();
			if ((int)www.result == 1)
			{
				Texture2D texture = DownloadHandlerTexture.GetContent(www);
				image.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f));
				((Transform)((Graphic)image).rectTransform).localScale = new Vector3(-1f, 1f, 1f);
			}
		}
	}
}