Decompiled source of SpectatorMode v1.0.0

SpectatorMode.dll

Decompiled 7 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 BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("SpectatorMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("If you are the host and you press 1 while in a game, you enter spectator mode.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SpectatorMode")]
[assembly: AssemblyTitle("SpectatorMode")]
[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 SpectatorMode
{
	[BepInPlugin("com.000diggity000.SpectatorMode", "SpectatorMode", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public bool godmode = false;

		public GameObject player;

		public Vec2 oldPos;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SpectatorMode is loaded!");
			Harmony val = new Harmony("com.Diggity.SpectatorMode");
			MethodBase methodBase = AccessTools.Method(typeof(PlayerHandler), "HasAliveTeammate", (Type[])null, (Type[])null);
			val.Patch(methodBase, new HarmonyMethod(AccessTools.Method(typeof(myPatches), "HasAliveTeammate", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			if (((ButtonControl)Keyboard.current[(Key)41]).wasPressedThisFrame)
			{
				SlimeController[] array = Object.FindObjectsOfType<SlimeController>();
				foreach (SlimeController val in array)
				{
					if (val.playerNumber == 1)
					{
						player = ((Component)val).gameObject;
					}
				}
				if (godmode)
				{
					((Behaviour)player.GetComponent<SlimeController>()).enabled = true;
					((Behaviour)player.GetComponent<PlayerPhysics>()).enabled = true;
					((Behaviour)player.GetComponent<DPhysicsBox>()).enabled = true;
					((Behaviour)player.GetComponent<PlayerBody>()).enabled = true;
					((Behaviour)player.GetComponent<DestroyIfOutsideSceneBounds>()).enabled = true;
					((Behaviour)player.GetComponent<SlimeTrailHandler>()).enabled = true;
					player.GetComponent<FixTransform>().position = oldPos;
					((Behaviour)Object.FindObjectOfType<PlayerAverageCamera>()).enabled = true;
					godmode = false;
					return;
				}
				oldPos = player.GetComponent<FixTransform>().position;
				Object.FindObjectOfType<PlayerAverageCamera>().cameraSpeed = 9999f;
				player.GetComponent<FixTransform>().position = new Vec2((Fix)0L, (Fix)5.5);
				Object.FindObjectOfType<PlayerAverageCamera>().cameraSpeed = 1.5f;
				((Behaviour)player.GetComponent<SlimeController>()).enabled = false;
				((Behaviour)player.GetComponent<PlayerPhysics>()).enabled = false;
				((Behaviour)player.GetComponent<DPhysicsBox>()).enabled = false;
				((Behaviour)player.GetComponent<PlayerBody>()).enabled = false;
				((Behaviour)player.GetComponent<DestroyIfOutsideSceneBounds>()).enabled = false;
				((Behaviour)player.GetComponent<SlimeTrailHandler>()).enabled = false;
				((Behaviour)Object.FindObjectOfType<PlayerAverageCamera>()).enabled = false;
				player.GetComponent<FixTransform>().position = oldPos;
				godmode = true;
			}
			if (godmode)
			{
				if (((ButtonControl)Keyboard.current[(Key)37]).isPressed)
				{
					ref Fix y = ref player.GetComponent<FixTransform>().position.y;
					y += (Fix)1L;
					((Component)Object.FindObjectOfType<Camera>()).transform.position = Vector2.op_Implicit(new Vector2(0f, ((Component)Object.FindObjectOfType<Camera>()).transform.position.y + 1f));
				}
				if (((ButtonControl)Keyboard.current[(Key)33]).isPressed)
				{
					ref Fix y2 = ref player.GetComponent<FixTransform>().position.y;
					y2 -= (Fix)1L;
					((Component)Object.FindObjectOfType<Camera>()).transform.position = Vector2.op_Implicit(new Vector2(0f, ((Component)Object.FindObjectOfType<Camera>()).transform.position.y - 1f));
				}
				if (((ButtonControl)Keyboard.current[(Key)18]).isPressed)
				{
					ref Fix x = ref player.GetComponent<FixTransform>().position.x;
					x += (Fix)1L;
					((Component)Object.FindObjectOfType<Camera>()).transform.position = Vector2.op_Implicit(new Vector2(((Component)Object.FindObjectOfType<Camera>()).transform.position.x + 1f, 0f));
				}
				if (((ButtonControl)Keyboard.current[(Key)15]).isPressed)
				{
					ref Fix x2 = ref player.GetComponent<FixTransform>().position.x;
					x2 -= (Fix)1L;
					((Component)Object.FindObjectOfType<Camera>()).transform.position = Vector2.op_Implicit(new Vector2(((Component)Object.FindObjectOfType<Camera>()).transform.position.x - 1f, 0f));
				}
			}
		}
	}
	public class myPatches
	{
		public static bool HasAliveTeammate(int playerId, ref bool __result)
		{
			__result = true;
			return false;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SpectatorMode";

		public const string PLUGIN_NAME = "SpectatorMode";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}