Decompiled source of MoreVibrations v1.0.0

MoreVibrations.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HBMF.GameResources;
using HBMF.ModMenu;
using HarmonyLib;
using Il2CppInteractionSystem;
using Il2CppInterop.Runtime.Attributes;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using MoreVibrations;
using UnityEngine;

[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), "MoreVibrations", "1.0.0", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MoreVibrations")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreVibrations")]
[assembly: AssemblyTitle("MoreVibrations")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreVibrations;

[HarmonyPatch]
public class Mod : MelonMod
{
	internal static MelonPreferences_Entry<bool> enabled;

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

	[HarmonyPatch(typeof(Grabbable), "AttemptGrab", new Type[]
	{
		typeof(AbstractGrabber),
		typeof(AbstractGrabPoint),
		typeof(GrabType),
		typeof(ConfigurableJoint)
	})]
	[HarmonyPostfix]
	public static void GrabPatch(Grabbable __instance)
	{
		if ((Object)(object)((Component)__instance).GetComponentInChildren<PierceAttacher>() != (Object)null && (Object)(object)((Component)__instance).GetComponent<StabVibrations>() == (Object)null)
		{
			((Component)__instance).gameObject.AddComponent<StabVibrations>();
		}
	}
}
[RegisterTypeInIl2Cpp]
public class StabVibrations : MonoBehaviour
{
	private int state = 0;

	private Vector3 lastPosition = Vector3.zero;

	public StabVibrations(IntPtr ptr)
		: base(ptr)
	{
	}//IL_0008: Unknown result type (might be due to invalid IL or missing references)
	//IL_000d: Unknown result type (might be due to invalid IL or missing references)


	internal void Start()
	{
		foreach (PierceAttacher componentsInChild in ((Component)this).GetComponentsInChildren<PierceAttacher>())
		{
			object start = null;
			((Attacher)componentsInChild).OnObjectAttached += Action<Attachment>.op_Implicit((Action<Attachment>)delegate
			{
				start = MelonCoroutines.Start(DelayedStart());
			});
			((Attacher)componentsInChild).OnObjectDetached += Action<Attachment>.op_Implicit((Action<Attachment>)delegate
			{
				MelonCoroutines.Stop(start);
				state = 0;
			});
		}
	}

	internal void FixedUpdate()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		if (Mod.enabled.Value && state > 0)
		{
			float num = 2f;
			if (state == 2)
			{
				Vector3 val = ((Component)this).transform.position - lastPosition;
				num = ((Vector3)(ref val)).magnitude * 50f;
				lastPosition = ((Component)this).transform.position;
			}
			if (((AbstractGrabber)GameResources.LeftGrabber).CurrentGrab != null && (Object)(object)((Component)((AbstractGrabber)GameResources.LeftGrabber).CurrentGrab.Grabbable).gameObject == (Object)(object)((Component)this).gameObject)
			{
				GameResources.InputManager.LeftController.Vibrate(num, 0.1f, 1f);
			}
			if (((AbstractGrabber)GameResources.RightGrabber).CurrentGrab != null && (Object)(object)((Component)((AbstractGrabber)GameResources.RightGrabber).CurrentGrab.Grabbable).gameObject == (Object)(object)((Component)this).gameObject)
			{
				GameResources.InputManager.RightController.Vibrate(num, 0.1f, 1f);
			}
		}
	}

	[HideFromIl2Cpp]
	private IEnumerator DelayedStart()
	{
		lastPosition = ((Component)this).transform.position;
		state = 1;
		yield return (object)new WaitForSecondsRealtime(0.2f);
		state = 2;
	}
}