Decompiled source of HSProdukt VHS 2 v1.1.0

HSProdukt_VHS_2.dll

Decompiled 4 months ago
using System.Collections.Generic;
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 cityrobo.HSProdukt_VHS_2;

[BepInPlugin("cityrobo.HSProdukt_VHS_2", "HSProdukt_VHS_2", "1.1.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class HSProdukt_VHS_2Plugin : 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()
	{
		OtherLoader.RegisterDirectLoad(BasePath, "cityrobo.HSProdukt_VHS_2", "", "", "vhs_2", "");
	}
}
public class VHS_BG_TubeFlap : MonoBehaviour
{
	public AttachableFirearmPhysicalObject PhysicalObject;

	public AttachableBreakActions GL;

	public Transform FlapProxy;

	public Vector2 MovementRange = new Vector2(0f, 45f);

	public bool IsPressed = false;

	public float RotationSpeed = 180f;

	private static Dictionary<AttachableBreakActions, VHS_BG_TubeFlap> _existingVHS_BGTubeFlap;

	private Quaternion _FlapTargetRotation;

	static VHS_BG_TubeFlap()
	{
		_existingVHS_BGTubeFlap = new Dictionary<AttachableBreakActions, VHS_BG_TubeFlap>();
		Harmony.CreateAndPatchAll(typeof(VHS_BG_TubeFlap), (string)null);
	}

	public void Awake()
	{
		_existingVHS_BGTubeFlap.Add(GL, this);
	}

	public void OnDestroy()
	{
		_existingVHS_BGTubeFlap.Remove(GL);
	}

	public void Update()
	{
		MoveFlap();
	}

	[HarmonyPatch(typeof(AttachableBreakActions), "ProcessInput")]
	[HarmonyPrefix]
	public static void LauncherFirePatch(AttachableBreakActions __instance, FVRViveHand hand, bool fromInterface, FVRInteractiveObject o)
	{
		if (!_existingVHS_BGTubeFlap.TryGetValue(__instance, out var value))
		{
			return;
		}
		if (hand.IsInStreamlinedMode)
		{
			if (hand.Input.BYButtonPressed)
			{
				value.IsPressed = true;
			}
			else
			{
				value.IsPressed = false;
			}
		}
		else if (hand.Input.TouchpadPressed && hand.Input.TouchpadWestPressed)
		{
			value.IsPressed = true;
		}
		else
		{
			value.IsPressed = false;
		}
	}

	public void MoveFlap()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		if (IsPressed)
		{
			_FlapTargetRotation = Quaternion.Euler(MovementRange.y, 0f, 0f);
		}
		else
		{
			_FlapTargetRotation = Quaternion.Euler(MovementRange.x, 0f, 0f);
		}
		if (FlapProxy.localRotation != _FlapTargetRotation)
		{
			FlapProxy.localRotation = Quaternion.RotateTowards(FlapProxy.localRotation, _FlapTargetRotation, RotationSpeed * Time.deltaTime);
		}
	}
}