Decompiled source of ShopName v1.1.2

plugins/ShopName/ShopName.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 Newtonsoft.Json.Linq;
using PotionCraft.ManagersSystem.Game;
using PotionCraft.SceneLoader;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ShopName")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShopName")]
[assembly: AssemblyTitle("ShopName")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShopName;

[BepInPlugin("com.mattdeduck.potioncraftshopname", "PotionCraftShopName", "1.1.2.0")]
[BepInProcess("Potion Craft.exe")]
public class Plugin : BaseUnityPlugin
{
	public const string PLUGIN_GUID = "com.mattdeduck.potioncraftshopname";

	public static string pluginLoc = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	public static Texture2D shopNameBigTexture;

	public static Sprite shopNameBigSprite;

	public static string t_shopNameText;

	public static TextMeshPro shopNameText;

	public static ManualLogSource Log { get; set; }

	public void Awake()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		shopNameBigTexture = LoadTextureFromFile(pluginLoc + "/shopbgBIG.png");
		shopNameBigSprite = Sprite.Create(shopNameBigTexture, new Rect(0f, 0f, (float)((Texture)shopNameBigTexture).width, (float)((Texture)shopNameBigTexture).height), new Vector2(0.5f, 0.5f));
		JObject val = JObject.Parse(File.ReadAllText(pluginLoc + "/shopname.json"));
		t_shopNameText = (string)val["Shop Name"];
		Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameManager), "Start")]
	public static void Start_Postfix()
	{
		ObjectsLoader.AddLast("SaveLoadManager.SaveNewGameState", (Action)delegate
		{
			CreateShopPlate();
		});
	}

	public static void CreateShopPlate()
	{
		CreateShopNameObject(shopNameBigSprite);
		AddShopNameText();
	}

	public static void CreateShopNameObject(Sprite spriteSize)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Shop Name");
		Transform transform = GameObject.Find("Room Meeting").transform;
		val.transform.parent = transform;
		SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
		val2.sprite = spriteSize;
		SortingGroup val3 = val.AddComponent<SortingGroup>();
		val3.sortingLayerID = -1758066705;
		val3.sortingLayerName = "GuiBackground";
		val.layer = LayerMask.NameToLayer("UI");
		val.transform.localPosition = new Vector3(-3f, -6.3f, 0f);
		val.SetActive(true);
		Log.LogInfo((object)"Shop Name object created");
	}

	public static void AddShopNameText()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject();
		GameObject val2 = GameObject.Find("Shop Name");
		if (val2 != null)
		{
			val.transform.SetParent(val2.transform);
		}
		((Object)val).name = "ShopNameText";
		val.transform.Translate(val2.transform.position + new Vector3(0f, -0.02f));
		val.layer = 5;
		shopNameText = val.AddComponent<TextMeshPro>();
		((TMP_Text)shopNameText).alignment = (TextAlignmentOptions)514;
		((TMP_Text)shopNameText).enableAutoSizing = true;
		shopNameText.sortingLayerID = -1650695527;
		shopNameText.sortingOrder = 100;
		((TMP_Text)shopNameText).fontSize = 8f;
		((TMP_Text)shopNameText).fontSizeMin = 3f;
		((TMP_Text)shopNameText).fontSizeMax = 8f;
		((Graphic)shopNameText).color = Color32.op_Implicit(new Color32((byte)57, (byte)30, (byte)20, byte.MaxValue));
		((TMP_Text)shopNameText).rectTransform.sizeDelta = new Vector2(11f, 1f);
		((TMP_Text)shopNameText).text = t_shopNameText;
		val.SetActive(true);
		Log.LogInfo((object)"Shop Name Text object created");
	}

	public static Texture2D LoadTextureFromFile(string filePath)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		byte[] array = File.ReadAllBytes(filePath);
		Texture2D val = new Texture2D(0, 0, (TextureFormat)5, false, false)
		{
			filterMode = (FilterMode)1
		};
		if (!ImageConversion.LoadImage(val, array))
		{
			throw new Exception("Failed to load image from file at \"" + filePath + "\".");
		}
		return val;
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "ShopName";

	public const string PLUGIN_NAME = "ShopName";

	public const string PLUGIN_VERSION = "1.0.0";
}