Decompiled source of VariableSlowMotion v1.1.1

VariableSlowMotion.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HBMF.ModMenu;
using HarmonyLib;
using Il2Cpp;
using Il2CppDG.Tweening;
using Il2CppDG.Tweening.Core;
using Il2CppDG.Tweening.Plugins.Options;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
using VariableSlowMotion;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "VariableSlowMotion", "1.1.1", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("VariableSlowMotion")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VariableSlowMotion")]
[assembly: AssemblyTitle("VariableSlowMotion")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VariableSlowMotion;

[HarmonyPatch]
public class Mod : MelonMod
{
	[CompilerGenerated]
	private sealed class <Done>d__11 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Done>d__11(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = new WaitForDisabled();
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				disabling = false;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static SlowMotion slowMotion;

	private static TimeManager timeManager;

	private static float defaultScale;

	private static FMODEventWithParameterPlayer sound;

	private static MelonPreferences_Entry<bool> enabled;

	private static bool disabling;

	private static bool getTween;

	private static TweenerCore<float, float, FloatOptions> tweener;

	public override void OnInitializeMelon()
	{
		enabled = MelonPreferences.CreateCategory("VariableSlowMotion").CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		Menu.CreateCategory("VARIABLE SLOW MOTION").CreateBool("ENABLE", enabled.Value, (Action<bool>)delegate(bool value)
		{
			enabled.Value = value;
		});
	}

	[HarmonyPatch(typeof(TweenManager), "SetUpdateType")]
	[HarmonyPostfix]
	public static void GetTween(Tween t)
	{
		if (getTween)
		{
			tweener = ((Il2CppObjectBase)t).Cast<TweenerCore<float, float, FloatOptions>>();
		}
	}

	[HarmonyPatch(typeof(TimeManager), "SwitchSlowMotionState")]
	[HarmonyPrefix]
	public static bool Patch()
	{
		if (enabled.Value)
		{
			if (!TimeManager._slowMoStatus)
			{
				if (!timeManager._isSlowMoInTransition)
				{
					timeManager._slowedTimeScale = 0.5f;
					getTween = true;
					timeManager.EnableSlowMotion();
					getTween = false;
				}
				else if (!disabling && timeManager._slowedTimeScale != 0.125f)
				{
					TimeManager obj = timeManager;
					obj._slowedTimeScale /= 2f;
					tweener.ChangeEndValue(timeManager._slowedTimeScale, -1f, false);
					sound.Play(0);
				}
			}
			else if (!timeManager._isSlowMoInTransition)
			{
				timeManager.DisableSlowMotion();
				disabling = true;
				MelonCoroutines.Start(Done());
			}
			return false;
		}
		timeManager._slowedTimeScale = defaultScale;
		return true;
	}

	[IteratorStateMachine(typeof(<Done>d__11))]
	private static IEnumerator Done()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Done>d__11(0);
	}

	[HarmonyPatch(typeof(SlowMotion), "Awake")]
	[HarmonyPostfix]
	public static void GetScripts(SlowMotion __instance)
	{
		slowMotion = __instance;
		timeManager = ((Component)__instance).GetComponent<TimeManager>();
		defaultScale = timeManager._slowedTimeScale;
		sound = ((Component)__instance).GetComponent<FMODEventWithParameterPlayer>();
	}
}
[RegisterTypeInIl2Cpp]
public class WaitForDisabled : CustomYieldInstruction
{
	public override bool keepWaiting => TimeManager._slowMoStatus;

	public WaitForDisabled(IntPtr ptr)
		: base(ptr)
	{
	}

	public WaitForDisabled()
		: base(ClassInjector.DerivedConstructorPointer<WaitForDisabled>())
	{
		ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
	}
}