Decompiled source of KS23LeverAction v1.0.0

KS23LeverAction.dll

Decompiled 3 weeks ago
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class DiceFaceDetector : MonoBehaviour
{
	public ParticleSystem effect;

	public Transform faceOneMarker;

	public float checkThreshold = 0.9f;

	public float cooldownTime = 2f;

	private float lastTriggerTime = 0f;

	private void Update()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)faceOneMarker == (Object)null) && !(Time.time - lastTriggerTime < cooldownTime) && Vector3.Dot(faceOneMarker.up, Vector3.up) > checkThreshold)
		{
			TriggerEffect();
		}
	}

	private void TriggerEffect()
	{
		if ((Object)(object)effect != (Object)null)
		{
			effect.Play();
			lastTriggerTime = Time.time;
		}
	}
}
namespace VolksScript
{
	public class LeverActionLoadingGateX : MonoBehaviour
	{
		public Transform LoadingGateObject;

		public Vector2 LoadingGateRotRange;

		private float curRot;

		private float tarRot;

		public float Range = 0.02f;

		private void Update()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			float num = 1f;
			if (!((Object)(object)GM.CurrentMovementManager != (Object)null))
			{
				return;
			}
			for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++)
			{
				if ((Object)(object)GM.CurrentMovementManager.Hands[i] != (Object)null && (Object)(object)GM.CurrentMovementManager.Hands[i].CurrentInteractable != (Object)null && GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmRound)
				{
					float num2 = Vector3.Distance(((Component)GM.CurrentMovementManager.Hands[i].CurrentInteractable).transform.position, ((Component)this).transform.position);
					if (num2 < num)
					{
						num = num2;
						flag = true;
					}
				}
			}
			if (flag)
			{
				if (num <= Range)
				{
					tarRot = (Range - num) / Range;
				}
				else
				{
					tarRot = 0f;
				}
			}
			else
			{
				tarRot = 0f;
			}
			if (tarRot != curRot)
			{
				curRot = tarRot;
				LoadingGateObject.localEulerAngles = new Vector3(Mathf.Lerp(LoadingGateRotRange.x, LoadingGateRotRange.y, curRot * 2f), 0f, 0f);
			}
		}
	}
}
namespace Volks.KS23LeverAction
{
	[BepInPlugin("Volks.KS23LeverAction", "KS23LeverAction", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class KS23LeverActionPlugin : BaseUnityPlugin
	{
		private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			LoadAssets();
		}

		private void LoadAssets()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.KS23LeverAction");
			OtherLoader.RegisterDirectLoad(BasePath, "Volks.KS23LeverAction", "", "", "ks23leveraction", "");
		}
	}
}
internal class AutoReleaseOnMagLoad : MonoBehaviour
{
	private FVRFireArm weapon;

	private Handgun handgun;

	private bool wasLoaded;

	public void Start()
	{
		weapon = ((Component)this).GetComponent<FVRFireArm>();
		if (!((Object)(object)weapon == (Object)null) && weapon is Handgun)
		{
			ref Handgun reference = ref handgun;
			FVRFireArm obj = weapon;
			reference = (Handgun)(object)((obj is Handgun) ? obj : null);
		}
	}

	public void FixedUpdate()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Invalid comparison between Unknown and I4
		if ((Object)(object)handgun != (Object)null)
		{
			if ((Object)(object)weapon.Magazine != (Object)null)
			{
				if (weapon.Magazine.HasARound())
				{
					if ((int)handgun.Slide.CurPos >= 2 && !wasLoaded)
					{
						handgun.Slide.ImpartFiringImpulse();
						wasLoaded = true;
					}
				}
				else
				{
					wasLoaded = false;
				}
			}
			else
			{
				wasLoaded = false;
			}
		}
		else
		{
			wasLoaded = false;
		}
	}
}