Decompiled source of WheelOfDoom v1.0.0

Wheel of Doom.dll

Decompiled 4 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using Wheel_of_Doom.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Wheel of Doom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wheel of Doom")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c013ece9-27d9-43df-b219-05d474df630e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Wheel_of_Doom
{
	[BepInPlugin("Fadey.WheelOfDoom", "Wheel of Doom", "1.0.0.0")]
	public class WheelOfDoom : BaseUnityPlugin
	{
		private const string modGUID = "Fadey.WheelOfDoom";

		private const string modName = "Wheel of Doom";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Fadey.WheelOfDoom");

		private static WheelOfDoom instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Fadey.WheelOfDoom");
			mls.LogInfo((object)"The wheel of doom is summoned");
			harmony.PatchAll(typeof(WheelOfDoom));
			harmony.PatchAll(typeof(WheelOfDoomPatch));
		}
	}
}
namespace Wheel_of_Doom.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class WheelOfDoomPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void TeleportTriggerPatch()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			if (!((ButtonControl)Keyboard.current.f2Key).isPressed)
			{
				return;
			}
			PlayerControllerB val = null;
			GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects;
			Vector3 position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
			GameObject[] array = allPlayerObjects;
			foreach (GameObject val2 in array)
			{
				PlayerControllerB component = val2.GetComponent<PlayerControllerB>();
				if ((Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					val = component;
					break;
				}
			}
			if ((Object)(object)val != (Object)null && ItemIsKey(val))
			{
				if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>()))
				{
					Object.FindObjectOfType<AudioReverbPresets>().audioPresets[2].ChangeAudioReverbForPlayer(val);
				}
				val.isInElevator = false;
				val.isInHangarShipRoom = false;
				val.isInsideFactory = true;
				val.averageVelocity = 0f;
				val.velocityLastFrame = Vector3.zero;
				val.TeleportPlayer(position, false, 0f, false, true);
				val.beamOutParticle.Play();
				if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				}
			}
		}

		public static bool ItemIsKey(PlayerControllerB playerController)
		{
			KeyItem currentlySelectedKey = GetCurrentlySelectedKey(playerController);
			if (Object.op_Implicit((Object)(object)currentlySelectedKey))
			{
				((GrabbableObject)currentlySelectedKey).DestroyObjectInHand(playerController);
				return true;
			}
			return false;
		}

		public static KeyItem GetCurrentlySelectedKey(PlayerControllerB playerController)
		{
			GrabbableObject obj = ((playerController != null) ? playerController.ItemSlots[playerController.currentItemSlot] : null);
			return (KeyItem)(object)((obj is KeyItem) ? obj : null);
		}
	}
}