Decompiled source of QuotaInfo v1.0.2

BepInEx/plugins/QuotaInfo_v1.0.0.dll

Decompiled 9 months 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyTemplate.Component;
using LethalCompanyTemplate.Patches;
using Microsoft.CodeAnalysis;
using QuotaInfo;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalCompanyTemplate")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("LethalCompanyTemplate")]
[assembly: AssemblyTitle("LethalCompanyTemplate")]
[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 QuotaInfo
{
	[BepInPlugin("soitchu.QuotaInfo", "Quota Info", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "soitchu.QuotaInfo";

		private const string modName = "Quota Info";

		private const string modVersion = "1.0.0";

		internal static GUILoader myGUI;

		private readonly Harmony harmony = new Harmony("soitchu.QuotaInfo");

		private static Plugin Instance;

		internal static ManualLogSource mls;

		public static ConfigEntry<int> positionX;

		public static ConfigEntry<int> positionY;

		private void Awake()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			positionX = ((BaseUnityPlugin)this).Config.Bind<int>("General", "InfoBoxPositionX", 0, "X position of the info box");
			positionY = ((BaseUnityPlugin)this).Config.Bind<int>("General", "InfoBoxPositionY", 0, "Y position of the info box");
			mls = Logger.CreateLogSource("soitchu.QuotaInfo");
			mls.LogInfo((object)"Yo");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(StatePatcher));
			harmony.PatchAll(typeof(MenuPatch));
			harmony.PatchAll(typeof(GameStartPatch));
			harmony.PatchAll(typeof(GUILoader));
			GameObject val = new GameObject("GUILoader");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<GUILoader>();
			myGUI = (GUILoader)(object)val.GetComponent("GUILoader");
		}
	}
}
namespace LethalCompanyTemplate
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalCompanyTemplate";

		public const string PLUGIN_NAME = "LethalCompanyTemplate";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LethalCompanyTemplate.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class StatePatcher
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Test(ref TimeOfDay __instance)
		{
			GUILoader.hasGameStarted = true;
			GUILoader.text = $"Day {3 - __instance.daysUntilDeadline + 1} \n Quota: {__instance.quotaFulfilled} / {__instance.profitQuota}";
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class GameStartPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Patch()
		{
			GUILoader.isMenuOpen = false;
			GUILoader.hasLeftTheGame = false;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class MenuPatch
	{
		[HarmonyPatch("CloseQuickMenu")]
		[HarmonyPrefix]
		private static void CloseMenu1()
		{
			GUILoader.isMenuOpen = false;
			GUILoader.hasLeftTheGame = false;
		}

		[HarmonyPatch("OpenQuickMenu")]
		[HarmonyPrefix]
		private static void OpenMenu()
		{
			GUILoader.isMenuOpen = true;
			GUILoader.hasLeftTheGame = false;
		}

		[HarmonyPatch("LeaveGameConfirm")]
		[HarmonyPrefix]
		private static void CloseMenu2()
		{
			GUILoader.isMenuOpen = false;
			GUILoader.hasLeftTheGame = true;
		}
	}
}
namespace LethalCompanyTemplate.Component
{
	internal class GUILoader : MonoBehaviour
	{
		private static GUIStyle labelStyle;

		public static string text = "";

		public static bool hasLeftTheGame = false;

		public static bool isMenuOpen = false;

		public static bool hasGameStarted = false;

		public static bool isEditMode = false;

		private KeyboardShortcut Up;

		private KeyboardShortcut Down;

		private KeyboardShortcut Left;

		private KeyboardShortcut Right;

		private KeyboardShortcut EditOnShortcut1;

		private KeyboardShortcut EditOnShortcut2;

		private KeyboardShortcut EditOffShortcut1;

		private KeyboardShortcut EditOffShortcut2;

		private void Awake()
		{
			//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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			EditOnShortcut1 = new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[2]
			{
				(KeyCode)306,
				(KeyCode)304
			});
			EditOnShortcut2 = new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[2]
			{
				(KeyCode)305,
				(KeyCode)303
			});
			EditOffShortcut1 = new KeyboardShortcut((KeyCode)100, (KeyCode[])(object)new KeyCode[2]
			{
				(KeyCode)306,
				(KeyCode)304
			});
			EditOffShortcut2 = new KeyboardShortcut((KeyCode)100, (KeyCode[])(object)new KeyCode[2]
			{
				(KeyCode)305,
				(KeyCode)303
			});
			Up = new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 });
			Down = new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 });
			Left = new KeyboardShortcut((KeyCode)276, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 });
			Right = new KeyboardShortcut((KeyCode)275, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 });
		}

		private static Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private static void intitializeMenu()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (labelStyle == null)
			{
				labelStyle = new GUIStyle(GUI.skin.label);
				labelStyle.normal.textColor = Color.white;
				labelStyle.fontSize = 25;
				labelStyle.alignment = (TextAnchor)4;
				((Object)labelStyle.normal.background).hideFlags = (HideFlags)61;
			}
		}

		public void Update()
		{
			if (!ShouldRender())
			{
				return;
			}
			int num = 2;
			int num2 = 0;
			int num3 = 0;
			if (((KeyboardShortcut)(ref EditOnShortcut1)).IsPressed() || ((KeyboardShortcut)(ref EditOnShortcut2)).IsPressed())
			{
				isEditMode = true;
			}
			else if (((KeyboardShortcut)(ref EditOffShortcut1)).IsPressed() || ((KeyboardShortcut)(ref EditOffShortcut2)).IsPressed())
			{
				isEditMode = false;
			}
			if (isEditMode)
			{
				if (((KeyboardShortcut)(ref Up)).IsPressed())
				{
					num2 = -1;
				}
				else if (((KeyboardShortcut)(ref Down)).IsPressed())
				{
					num2 = 1;
				}
				else if (((KeyboardShortcut)(ref Right)).IsPressed())
				{
					num3 = 1;
				}
				else if (((KeyboardShortcut)(ref Left)).IsPressed())
				{
					num3 = -1;
				}
				ConfigEntry<int> positionX = Plugin.positionX;
				positionX.Value += num3 * num;
				ConfigEntry<int> positionY = Plugin.positionY;
				positionY.Value += num2 * num;
			}
		}

		private bool ShouldRender()
		{
			return !hasLeftTheGame && hasGameStarted && !isMenuOpen;
		}

		public void OnGUI()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (ShouldRender())
			{
				if (labelStyle == null)
				{
					intitializeMenu();
				}
				if (isEditMode)
				{
					GUI.Label(new Rect((float)Plugin.positionX.Value, (float)Plugin.positionY.Value, 300f, 200f), "Editing mode enalbed. Use CTRL + UP/DOWN/RIGHT/LEFT to move this text box. \n Press CTRL + SHIFT + D to disable this mode", labelStyle);
				}
				else
				{
					GUI.Label(new Rect((float)Plugin.positionX.Value, (float)Plugin.positionY.Value, 300f, 200f), text, labelStyle);
				}
			}
		}
	}
}