Decompiled source of NimbusGunFix v1.0.0

Mods/NimbusGunFix.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using MelonLoader;
using NimbusGunFix;
using SLZ.Props;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NimbusGunFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("NimbusGunFix")]
[assembly: AssemblyCopyright("Created by Adi")]
[assembly: AssemblyTrademark(null)]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: MelonInfo(typeof(global::NimbusGunFix.NimbusGunFix), "NimbusGunFix", "1.0.0", "Adi", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NimbusGunFix;

public static class BuildInfo
{
	public const string Name = "NimbusGunFix";

	public const string Author = "Adi";

	public const string Company = null;

	public const string Version = "1.0.0";

	public const string DownloadLink = null;
}
public class NimbusGunFix : MelonMod
{
	[HarmonyPatch(typeof(FlyingGun), "OnTriggerGripUpdate")]
	public static class NimbusGunPatch
	{
		public static bool Prefix(FlyingGun __instance)
		{
			if (enabled && __instance._host.HandCount() > 0 && (Object)(object)__instance._host._hands[0].manager == (Object)(object)Player.rigManager)
			{
				return canCall;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(FlyingGun), "OnTriggerHandAttached")]
	public static class NimbusGunAttachPatch
	{
		public static void Postfix(FlyingGun __instance)
		{
			if (__instance._host.HandCount() > 0 && (Object)(object)__instance._host._hands[0].manager == (Object)(object)Player.rigManager)
			{
				nimbusGun = __instance;
			}
		}
	}

	public static bool enabled = true;

	public static bool canCall = false;

	public static FlyingGun nimbusGun;

	public static float lastNoClipToggle = 0f;

	public override void OnInitializeMelon()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		MenuManager.CreateCategory("NimbusGunFix", Color.white).CreateBoolElement("Enabled", Color.white, enabled, (Action<bool>)delegate(bool value)
		{
			enabled = value;
		});
		Hooking.OnLevelInitialized += delegate
		{
			nimbusGun = null;
		};
	}

	public override void OnFixedUpdate()
	{
		if (!enabled)
		{
			return;
		}
		canCall = true;
		if ((Object)(object)nimbusGun != (Object)null && nimbusGun._host.HandCount() > 0)
		{
			bool noClipping = nimbusGun._noClipping;
			nimbusGun.OnTriggerGripUpdate(nimbusGun._host._hands[0]);
			if (noClipping != nimbusGun._noClipping)
			{
				if (Time.fixedUnscaledTime - lastNoClipToggle < Time.deltaTime)
				{
					if (nimbusGun._noClipping)
					{
						nimbusGun.DisableNoClip(nimbusGun._host._hands[0]);
					}
					else
					{
						nimbusGun.EnableNoClip();
					}
				}
				else
				{
					lastNoClipToggle = Time.fixedUnscaledTime;
				}
			}
		}
		canCall = false;
	}
}