Decompiled source of KingLirCore v1.0.1

KingLirCore.dll

Decompiled 15 hours 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 Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KingLirCore")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("KingLirCore")]
[assembly: AssemblyTitle("KingLirCore")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 __MODNAME__
{
	[BepInPlugin("kinglir.__MODID__", "__MODNAME__", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "kinglir.__MODID__";

		public const string Name = "__MODNAME__";

		public const string Version = "0.1.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("kinglir.__MODID__").PatchAll();
			Log.LogInfo((object)"__MODNAME__ 0.1.0 laddad.");
		}
	}
}
namespace KingLirCore
{
	[HarmonyPatch(typeof(MenuPageMain), "Start")]
	internal static class MenuPageMainStartPatch
	{
		private static void Postfix(MenuPageMain __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<MenuBanner>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<MenuBanner>();
			}
		}
	}
	internal sealed class MenuBanner : MonoBehaviour
	{
		private const string Title = "Mods by KingLir Community";

		private const float LogoSize = 190f;

		private const float Margin = 25f;

		private static Texture2D sheet;

		private static int columns;

		private static int rows;

		private static int frameCount;

		private static float[] delays;

		private GameObject canvasObject;

		private RawImage logo;

		private int frame;

		private float frameTimer;

		private void Start()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (LoadSheet())
			{
				canvasObject = new GameObject("KingLir Menu Banner");
				Canvas obj = canvasObject.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 100;
				CanvasScaler obj2 = canvasObject.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				TextMeshProUGUI val = CreateChild("Title", canvasObject.transform).AddComponent<TextMeshProUGUI>();
				((TMP_Text)val).text = "Mods by KingLir Community";
				((TMP_Text)val).alignment = (TextAlignmentOptions)516;
				((TMP_Text)val).fontSize = 30f;
				((Graphic)val).color = Color.white;
				((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
				TMP_Text componentInChildren = ((Component)this).GetComponentInChildren<TMP_Text>(true);
				if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.font != (Object)null)
				{
					((TMP_Text)val).font = componentInChildren.font;
				}
				Anchor(((TMP_Text)val).rectTransform, new Vector2(-25f, -25f), new Vector2(800f, 40f));
				logo = CreateChild("Logo", canvasObject.transform).AddComponent<RawImage>();
				logo.texture = (Texture)(object)sheet;
				((Graphic)logo).raycastTarget = false;
				Anchor(((Graphic)logo).rectTransform, new Vector2(-85f, -70f), new Vector2(190f, 190f));
				SetFrame(0);
			}
		}

		private void Update()
		{
			if (!((Object)(object)logo == (Object)null))
			{
				frameTimer += Time.unscaledDeltaTime * 1000f;
				if (frameTimer >= delays[frame])
				{
					frameTimer -= delays[frame];
					SetFrame((frame + 1) % frameCount);
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)canvasObject != (Object)null)
			{
				Object.Destroy((Object)(object)canvasObject);
			}
		}

		private void SetFrame(int index)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			frame = index;
			int num = index % columns;
			int num2 = index / columns;
			logo.uvRect = new Rect((float)num / (float)columns, 1f - (float)(num2 + 1) / (float)rows, 1f / (float)columns, 1f / (float)rows);
		}

		private static GameObject CreateChild(string name, Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			return val;
		}

		private static void Anchor(RectTransform rect, Vector2 position, Vector2 size)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(1f, 1f);
			rect.anchorMax = val;
			rect.anchorMin = val;
			rect.pivot = new Vector2(1f, 1f);
			rect.anchoredPosition = position;
			rect.sizeDelta = size;
		}

		private static bool LoadSheet()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			if ((Object)(object)sheet != (Object)null)
			{
				return true;
			}
			Assembly assembly = typeof(MenuBanner).Assembly;
			using (Stream stream = assembly.GetManifestResourceStream("KingLirCore.logo_sheet.png"))
			{
				using Stream stream2 = assembly.GetManifestResourceStream("KingLirCore.logo_sheet.txt");
				if (stream == null || stream2 == null)
				{
					Plugin.Log.LogError((object)"Loggans resurser saknas i DLL:en.");
					return false;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				string[] array2 = new StreamReader(stream2).ReadToEnd().Split(';');
				columns = int.Parse(array2[0]);
				rows = int.Parse(array2[1]);
				frameCount = int.Parse(array2[2]);
				string[] array3 = array2[3].Split(',');
				delays = new float[frameCount];
				for (int i = 0; i < frameCount; i++)
				{
					delays[i] = float.Parse(array3[i]);
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, array))
				{
					Plugin.Log.LogError((object)"Kunde inte läsa loggans spritesheet.");
					return false;
				}
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				Object.DontDestroyOnLoad((Object)(object)val);
				sheet = val;
			}
			return true;
		}
	}
	[BepInPlugin("kinglir.core", "KingLirCore", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "kinglir.core";

		public const string Name = "KingLirCore";

		public const string Version = "1.0.1";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("kinglir.core").PatchAll();
			Log.LogInfo((object)"KingLirCore 1.0.1 laddad.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}