Decompiled source of RumbleEntranceRandomize v1.0.1

plugins/RumbleEntranceRandomize.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;

[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("RumbleEntranceRandomize")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RumbleEntranceRandomize")]
[assembly: AssemblyTitle("RumbleEntranceRandomize")]
[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 RumbleEntranceRandomize
{
	[BepInPlugin("GeeEm.WrestlingEmpire.RumbleEntranceRandomize", "RumbleEntranceRandomize", "1.0.1")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "GeeEm.WrestlingEmpire.RumbleEntranceRandomize";

		public const string PluginName = "RumbleEntranceRandomize";

		public const string PluginVer = "1.0.1";

		internal static ManualLogSource Log;

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

		internal static string PluginPath;

		public static ConfigEntry<bool> RandomizeInBookerExhibition;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			RandomizeInBookerExhibition = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Randomize In Booker and Exhibition", false, "Enable this if you want to also randomize booker and exhibition matches");
		}

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

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

		[HarmonyPatch(typeof(FFCEGMEAIBP), "OOMNLEIFFHM")]
		[HarmonyPostfix]
		private static void FFCEGMEAIBP_OOMNLEIFFHM_Postfix()
		{
			if (NAEEIFNFBBO.CBMHGKFFHJE == 1 && FFCEGMEAIBP.OLJFOJOLLOM < 0)
			{
				Random rng = new Random();
				rng.ShuffleCharacters();
				FFCEGMEAIBP.NJPKCMBLMLG = 0;
			}
			if (RandomizeInBookerExhibition.Value && (NAEEIFNFBBO.CBMHGKFFHJE == 0 || NAEEIFNFBBO.CBMHGKFFHJE == 2) && FFCEGMEAIBP.OLJFOJOLLOM < 0)
			{
				Random rng2 = new Random();
				rng2.ShuffleCharacters();
			}
		}
	}
	internal static class RandomExtensions
	{
		public static void ShuffleCharacters(this Random rng)
		{
			int num = FFCEGMEAIBP.EHIDHAPMAKG + 1;
			while (num > 2)
			{
				int num2;
				for (num2 = rng.Next(num--); num2 == 0; num2 = rng.Next(num))
				{
				}
				FFCEGMEAIBP.DKBKBEHNCEN(num, num2);
			}
			for (int i = 1; i <= FFCEGMEAIBP.EHIDHAPMAKG; i++)
			{
				if (FFCEGMEAIBP.NMMABDGIJNC[i] == Characters.wrestler)
				{
					Plugin.Log.LogInfo((object)(Characters.c[FFCEGMEAIBP.NMMABDGIJNC[i]].name + " new position is " + i + " (not counting surprise entrants)"));
					if (i > 2)
					{
						Plugin.Log.LogInfo((object)("Keep an eye for " + Characters.c[FFCEGMEAIBP.NMMABDGIJNC[i - 1]].name + ", you might go out after them."));
					}
					break;
				}
			}
		}
	}
}