Decompiled source of BookerCardEditor v1.0.2

plugins/BookerCardEditor.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
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("BookerCardEditor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BookerCardEditor")]
[assembly: AssemblyTitle("BookerCardEditor")]
[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 BookerCardEditor
{
	[BepInPlugin("GeeEm.WrestlingEmpire.BookerCardEditor", "BookerCardEditor", "1.0.2")]
	[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 rivalFed { get; set; }

			public bool resetCard { get; set; }

			public int attendance { get; set; }

			public int territory { get; set; }

			public CardStruct()
			{
				date = Progress.date;
				type = -1;
				size = -1;
				rivalFed = -1;
				resetCard = false;
				attendance = -1;
				territory = -1;
			}
		}

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

		public const string PluginName = "BookerCardEditor";

		public const string PluginVer = "1.0.2";

		internal static ManualLogSource Log;

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

		internal static string PluginPath;

		public static ConfigEntry<KeyCode> loadCardButton;

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

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

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

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKeyDown(loadCardButton.Value))
			{
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Load custom card button has been pressed");
			if (NAEEIFNFBBO.CBMHGKFFHJE == 2)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "Calendar")
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading custom card.");
					try
					{
						LoadCard();
						return;
					}
					catch (Exception ex)
					{
						((BaseUnityPlugin)this).Logger.LogError((object)"Error while loading custom card: ");
						((BaseUnityPlugin)this).Logger.LogError((object)ex);
						return;
					}
					finally
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Done loading custom card.");
					}
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Didn't load, not in the calendar menu.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Didn't load, not in the booker mode.");
			}
		}

		public void LoadCard()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Expected O, but got Unknown
			CardStruct cardStruct = new CardStruct();
			List<Segment> list = new List<Segment>();
			Segment val = new Segment();
			string[] array = File.ReadAllLines(Path.Combine(PluginPath, "CustomCard.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("card_type:"))
				{
					cardStruct.type = int.Parse(text.Substring(10).Trim());
				}
				else if (text.ToLower().StartsWith("rival_fed:"))
				{
					cardStruct.rivalFed = int.Parse(text.Substring(10).Trim());
				}
				else if (text.ToLower().StartsWith("card_size:"))
				{
					cardStruct.size = int.Parse(text.Substring(10).Trim());
				}
				else if (text.ToLower().StartsWith("reset_card:"))
				{
					bool.TryParse(text.Substring(11).Trim(), out var result2);
					cardStruct.resetCard = result2;
				}
				else if (text.ToLower().StartsWith("attendance:"))
				{
					cardStruct.attendance = int.Parse(text.Substring(11).Trim());
				}
				else if (text.ToLower().StartsWith("territory:"))
				{
					cardStruct.territory = int.Parse(text.Substring(10).Trim());
				}
				else if (text.ToLower().StartsWith("match_id:"))
				{
					val = new Segment();
					val.id = int.Parse(text.Substring(9).Trim());
				}
				else if (text.ToLower().StartsWith("match_name:"))
				{
					val.match = text.Substring(11).Trim();
				}
				else if (text.ToLower().StartsWith("left_name:"))
				{
					val.leftName = text.Substring(10).Trim();
				}
				else if (text.ToLower().StartsWith("right_name:"))
				{
					val.rightName = text.Substring(11).Trim();
				}
				else if (text.ToLower().StartsWith("left_id:"))
				{
					val.leftChar = int.Parse(text.Substring(8).Trim());
				}
				else if (text.ToLower().StartsWith("right_id:"))
				{
					val.rightChar = int.Parse(text.Substring(9).Trim());
				}
				else if (text.ToLower().StartsWith("match_end"))
				{
					list.Add(val);
				}
			}
			if (Progress.card[cardStruct.date] == null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Card is null, so reloading it");
				Progress.PDBLBLFNDHE(cardStruct.date);
			}
			if (cardStruct.rivalFed != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting rival_fed " + cardStruct.rivalFed));
				Progress.rivalFed = cardStruct.rivalFed;
			}
			if (cardStruct.type != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting card_type " + cardStruct.type));
				if (cardStruct.type == 4)
				{
					Progress.card[cardStruct.date].PIMGMPBCODM(cardStruct.date, 6);
					Progress.MBGDIFJMIHA(cardStruct.date);
				}
				else
				{
					Progress.show[cardStruct.date] = cardStruct.type;
				}
			}
			if (cardStruct.resetCard)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"resetting the card");
				World.KKJICBHPPEL();
				World.NIKGKKEJCFL(0, cardStruct.date, 1);
				World.CIEFJFNEEFJ();
				Progress.card[cardStruct.date].PIMGMPBCODM(cardStruct.date, Progress.card[cardStruct.date].size);
			}
			if (cardStruct.size != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting card_size " + cardStruct.size));
				List<Segment> list2 = new List<Segment>();
				int num = ((Progress.card[cardStruct.date].size < cardStruct.size) ? Progress.card[cardStruct.date].size : cardStruct.size);
				for (int j = 1; j <= num; j++)
				{
					list2.Add(Progress.card[cardStruct.date].segment[j]);
				}
				Progress.card[cardStruct.date].PIMGMPBCODM(cardStruct.date, cardStruct.size);
				foreach (Segment item in list2)
				{
					Progress.card[cardStruct.date].segment[item.id] = item;
				}
			}
			if (cardStruct.attendance != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting attendance " + cardStruct.attendance));
				Progress.attendance[cardStruct.date] = cardStruct.attendance;
			}
			if (cardStruct.territory != -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("setting territory " + cardStruct.territory));
				Progress.territory[cardStruct.date] = cardStruct.territory;
			}
			foreach (Segment item2 in list)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"setting match segment: ");
				((BaseUnityPlugin)this).Logger.LogInfo((object)("match_id " + item2.id));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("match \"" + item2.match + "\""));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("left_name \"" + item2.leftName + "\""));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("right_name \"" + item2.rightName + "\""));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("left_char " + item2.leftChar));
				((BaseUnityPlugin)this).Logger.LogInfo((object)("right_char " + item2.rightChar));
				Progress.card[cardStruct.date].segment[item2.id] = item2;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"=====================================");
			}
		}
	}
}