Decompiled source of Glack11SMG v1.0.0

Glack11SMG.dll

Decompiled 3 months 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]
namespace Volks.Glack11SMG;

[BepInPlugin("Volks.Glack11SMG", "Glack11SMG", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class Glack11SMGPlugin : 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.Glack11SMG");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.Glack11SMG", "", "", "glack11smg", "");
	}
}
public class MagPush : FVRInteractiveObject
{
	public Transform StartPoint;

	public Transform EndPoint;

	public FVRFireArm FireArm;

	public FVRFireArmReloadTriggerWell ReloadTriggerWell;

	private FVRFireArmMagazine magazine;

	private bool isAttached = false;

	private bool isLoaded = false;

	private Vector3 _lastHandPos;

	private void Update()
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (!isAttached)
		{
			if ((Object)(object)ReloadTriggerWell.FireArm.Magazine != (Object)null && Vector3.Distance(((Component)ReloadTriggerWell.FireArm.Magazine).transform.position, StartPoint.position) < 0.1f)
			{
				magazine = ReloadTriggerWell.FireArm.Magazine;
				isAttached = true;
				FireArm.PlayAudioEvent((FirearmAudioEventType)20, 1f);
				FireArm.Magazine = null;
			}
		}
		else if (!isLoaded)
		{
			Vector3 val = EndPoint.position - StartPoint.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num = 0.1f * Time.deltaTime;
			((Component)magazine).transform.position = Vector3.MoveTowards(((Component)magazine).transform.position, EndPoint.position, num);
			if (Vector3.Distance(((Component)magazine).transform.position, EndPoint.position) < 0.1f)
			{
				isLoaded = true;
				FireArm.PlayAudioEvent((FirearmAudioEventType)21, 1f);
				FireArm.Magazine = magazine;
			}
		}
	}

	public override void BeginInteraction(FVRViveHand hand)
	{
		//IL_000f: 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)
		((FVRInteractiveObject)this).BeginInteraction(hand);
		_lastHandPos = ((HandInput)(ref hand.Input)).Pos;
	}

	public override void UpdateInteraction(FVRViveHand hand)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: 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_0047: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).UpdateInteraction(hand);
		if (isAttached && !isLoaded)
		{
			Vector3 val = ((HandInput)(ref hand.Input)).Pos - _lastHandPos;
			Vector3 val2 = ((Component)magazine).transform.position + val;
			float num = Mathf.Clamp(val2.x, StartPoint.position.x, EndPoint.position.x);
			float num2 = Mathf.Clamp(val2.y, StartPoint.position.y, EndPoint.position.y);
			float num3 = Mathf.Clamp(val2.z, StartPoint.position.z, EndPoint.position.z);
			((Component)magazine).transform.position = new Vector3(num, num2, num3);
			_lastHandPos = ((HandInput)(ref hand.Input)).Pos;
			if (Vector3.Distance(((Component)magazine).transform.position, EndPoint.position) < 0.1f)
			{
				isLoaded = true;
				FireArm.PlayAudioEvent((FirearmAudioEventType)21, 1f);
				FireArm.Magazine = magazine;
			}
		}
	}

	public override void EndInteraction(FVRViveHand hand)
	{
		((FVRInteractiveObject)this).EndInteraction(hand);
	}

	private void OnEnable()
	{
		FireArm.Magazine = null;
	}

	public bool IsFirearmReady()
	{
		return isLoaded && FireArm.IsLoaded();
	}

	public bool NeedsMagazinePush()
	{
		return isAttached && !isLoaded;
	}
}