Decompiled source of AntroSlowPractice v2.0.0

Antro.SlowPractice.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.IL2CPP;
using Microsoft.CodeAnalysis;
using SteamworksNative;
using UnhollowerRuntimeLib;
using UnityEngine;

[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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.SlowPractice")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.SlowPractice")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Antro.SlowPractice")]
[assembly: AssemblyTitle("Antro.SlowPractice")]
[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 Antro.SlowPractice
{
	[BepInPlugin("Antro.SlowPractice", "Antro Slow Practice", "2.0.0.0")]
	public class SlowPracticePlugin : BasePlugin
	{
		public override void Load()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ClassInjector.RegisterTypeInIl2Cpp<SlowPracticeUI>();
			GameObject val = new GameObject("AntroSlowPractice_UI");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<SlowPracticeUI>();
			((BasePlugin)this).Log.LogInfo((object)"Antro Slow Practice v2.0.0.0 (Tuned Force).");
		}
	}
	public class SlowPracticeUI : MonoBehaviour
	{
		private bool _isOpen = false;

		private Rect _windowRect = new Rect(20f, 20f, 250f, 180f);

		private string _speedInput = "1.0";

		private const float BASE_BOOST = 6.2f;

		public SlowPracticeUI(IntPtr ptr)
			: base(ptr)
		{
		}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)


		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)92) && AmIHost())
			{
				_isOpen = !_isOpen;
				if (_isOpen)
				{
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
				}
				else if (IsIngame())
				{
					Cursor.lockState = (CursorLockMode)1;
					Cursor.visible = false;
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if (Time.timeScale >= 0.99f || (Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance == (Object)null || (Object)(object)MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance == (Object)null)
			{
				return;
			}
			ulong steamID = MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_0.m_SteamID;
			if (!MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(steamID))
			{
				return;
			}
			MonoBehaviourPublicCSstReshTrheObplBojuUnique val = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[steamID];
			if ((Object)(object)val != (Object)null && !val.dead)
			{
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddForce(Vector3.up * 6.2f * Time.fixedDeltaTime, (ForceMode)2);
				}
			}
		}

		private void OnGUI()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if (_isOpen && AmIHost())
			{
				GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.95f);
				GUI.contentColor = Color.white;
				_windowRect = GUI.Window(8888, _windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "Slow Practice v2.0.0.0");
			}
		}

		private void DrawWindow(int id)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			GUILayout.Label("Time Scale:", Array.Empty<GUILayoutOption>());
			_speedInput = GUILayout.TextField(_speedInput, Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			if (Time.timeScale < 0.99f)
			{
				GUILayout.Label($"<color=green>Assist: ON (Force {6.2f})</color>", Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label("<color=grey>Assist: OFF</color>", Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(5f);
			GUI.backgroundColor = Color.cyan;
			if (GUILayout.Button("APPLY TIME", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				ApplySpeed();
			}
			GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f);
			GUILayout.Space(3f);
			if (GUILayout.Button("Reset", Array.Empty<GUILayoutOption>()))
			{
				_speedInput = "1.0";
				ApplySpeed();
			}
			GUILayout.EndVertical();
		}

		private void ApplySpeed()
		{
			string s = _speedInput.Replace(',', '.');
			if (float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				if (result < 0.05f)
				{
					result = 0.05f;
				}
				Time.timeScale = result;
				Time.fixedDeltaTime = 0.02f * result;
			}
		}

		private bool AmIHost()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance == (Object)null)
			{
				return false;
			}
			try
			{
				return MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_0.m_SteamID == SteamMatchmaking.GetLobbyOwner(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.currentLobby).m_SteamID;
			}
			catch
			{
				return false;
			}
		}

		private bool IsIngame()
		{
			return (Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance != (Object)null && MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.Count > 0;
		}
	}
}