Decompiled source of WrestlerMatchEditor v1.0.1

plugins/WrestlerMatchEditor.dll

Decompiled 2 years 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("WrestlerMatchEditor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WrestlerMatchEditor")]
[assembly: AssemblyTitle("WrestlerMatchEditor")]
[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]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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 WrestlerMatchEditor
{
	[BepInPlugin("GeeEm.WrestlingEmpire.WrestlerMatchEditor", "WrestlerMatchEditor", "1.0.1")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public struct CardStruct
		{
			public int date { get; set; }

			public int type { get; set; }

			public int size { get; set; }

			public int gimmick { get; set; }

			public int opponent { get; set; }

			public int match { get; set; }

			public CardStruct()
			{
				date = Progress.date;
				type = -1;
				size = -1;
				gimmick = -1;
				opponent = -1;
				match = -1;
			}
		}

		public const string PluginGuid = "GeeEm.WrestlingEmpire.WrestlerMatchEditor";

		public const string PluginName = "WrestlerMatchEditor";

		public const string PluginVer = "1.0.1";

		internal static ManualLogSource Log;

		internal static readonly Harmony Harmony = new Harmony("GeeEm.WrestlingEmpire.WrestlerMatchEditor");

		internal static string PluginPath;

		public static ConfigEntry<KeyCode> loadMatchButton;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			loadMatchButton = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Load custom match", (KeyCode)270, "Button that loads the custom match");
		}

		private void OnEnable()
		{
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded WrestlerMatchEditor!");
		}

		private void OnDisable()
		{
			Harmony.UnpatchSelf();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Unloaded WrestlerMatchEditor!");
		}

		private void Update()
		{
			//IL_0006: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKeyDown(loadMatchButton.Value) || NAEEIFNFBBO.CBMHGKFFHJE != 1)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Calendar")
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading custom match.");
				try
				{
					LoadCard();
					return;
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Error while loading custom match: ");
					((BaseUnityPlugin)this).Logger.LogError((object)ex);
					return;
				}
				finally
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Done loading custom match.");
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Didn't load, not in the calendar menu.");
		}

		public void LoadCard()
		{
			CardStruct cardStruct = new CardStruct();
			string[] array = File.ReadAllLines(Path.Combine(PluginPath, "CustomMatch.txt"));
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (text.Trim().Length == 0)
				{
					continue;
				}
				if (text.ToLower().StartsWith("date:"))
				{
					int result;
					if (text.Substring(5).Trim().ToLower() == "today")
					{
						cardStruct.date = Progress.date;
					}
					else if (text.Substring(5).Trim().ToLower() == "highlight")
					{
						cardStruct.date = Progress.focDate;
					}
					else if (int.TryParse(text.Substring(5).Trim().ToLower(), out result) && result >= 1 && result <= 48)
					{
						cardStruct.date = result;
					}
				}
				else if (text.ToLower().StartsWith("show_type:"))
				{
					cardStruct.type = int.Parse(text.Substring(10).Trim());
				}
				else if (text.ToLower().StartsWith("match_type:"))
				{
					cardStruct.match = int.Parse(text.Substring(11).Trim());
				}
				else if (text.ToLower().StartsWith("match_size:"))
				{
					cardStruct.size = int.Parse(text.Substring(11).Trim());
				}
				else if (text.ToLower().StartsWith("gimmick:"))
				{
					cardStruct.gimmick = int.Parse(text.Substring(8).Trim());
				}
				else if (text.ToLower().StartsWith("opponent:"))
				{
					cardStruct.opponent = int.Parse(text.Substring(9).Trim());
				}
			}
			if (cardStruct.type != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting show_type " + cardStruct.type));
				Progress.show[cardStruct.date] = cardStruct.type;
			}
			if (cardStruct.match != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting match_type " + cardStruct.match));
				Progress.match[cardStruct.date] = cardStruct.match;
			}
			if (cardStruct.size != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting match_size " + cardStruct.size));
				Progress.matchSize[cardStruct.date] = cardStruct.size;
			}
			if (cardStruct.gimmick != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting gimmick " + cardStruct.gimmick));
				Progress.gimmick[cardStruct.date] = cardStruct.gimmick;
			}
			if (cardStruct.opponent != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting opponent " + cardStruct.opponent));
				Progress.opponent[cardStruct.date] = cardStruct.opponent;
			}
		}
	}
}