Decompiled source of UniShield v1.0.0

UniShield.dll

Decompiled a day 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]
public class AdvanceLaserSightComponent : LaserLightAttachment
{
	public Transform KnobMesh;

	public Vector3 RotationAxis = Vector3.up;

	public List<float> CustomRotationAngles;

	public GameObject ControlledGameObject;

	public bool[] GameObjectEnableFlags;

	public AudioEvent SettingSwapSound;

	private int previousSettingsIndex = -1;

	private void Start()
	{
		UpdateKnobRotationAndGameObject();
	}

	private void Update()
	{
		UpdateKnobRotationAndGameObject();
	}

	private void UpdateKnobRotationAndGameObject()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)KnobMesh != (Object)null && base.Settings.Count > 0 && CustomRotationAngles.Count == base.Settings.Count && GameObjectEnableFlags.Length == base.Settings.Count)
		{
			float num = CustomRotationAngles[base.SettingsIndex];
			KnobMesh.localEulerAngles = RotationAxis * num;
			UpdateControlledGameObject(base.SettingsIndex);
			if (base.SettingsIndex != previousSettingsIndex)
			{
				PlaySettingSwapSound();
				previousSettingsIndex = base.SettingsIndex;
			}
		}
	}

	private void UpdateControlledGameObject(int settingIndex)
	{
		if ((Object)(object)ControlledGameObject != (Object)null)
		{
			ControlledGameObject.SetActive(GameObjectEnableFlags[settingIndex]);
		}
	}

	private void PlaySettingSwapSound()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (SettingSwapSound != null && SettingSwapSound.Clips.Count > 0)
		{
			AudioClip val = SettingSwapSound.Clips[Random.Range(0, SettingSwapSound.Clips.Count)];
			AudioSource.PlayClipAtPoint(val, ((Component)this).transform.position, Random.Range(SettingSwapSound.VolumeRange.x, SettingSwapSound.VolumeRange.y));
		}
	}
}
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 JerryComponent
{
	public class WristAttaching : MonoBehaviour
	{
		public FVRPhysicalObject mainObj;

		public FVRInteractiveObject grabInterface;

		public GameObject phys;

		public Collider mainCol;

		public Rigidbody mainRig;

		public bool LeftOn = false;

		public bool RightOn = false;

		public GameObject posLeft;

		public GameObject posRight;

		public GameObject WatchGeo;

		public GameObject posMiddle;

		private void FixedUpdate()
		{
			//IL_0044: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			if (((FVRInteractiveObject)mainObj).m_isHeld)
			{
				if ((Object)(object)((FVRInteractiveObject)mainObj).m_hand == (Object)(object)GM.CurrentMovementManager.Hands[0])
				{
					if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[1].PalmTransform.position) < 0.1f)
					{
						LeftOn = false;
						RightOn = true;
					}
					else if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[1].PalmTransform.position) >= 0.1f)
					{
						LeftOn = false;
						RightOn = false;
					}
				}
				if ((Object)(object)((FVRInteractiveObject)mainObj).m_hand == (Object)(object)GM.CurrentMovementManager.Hands[1])
				{
					if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[0].PalmTransform.position) < 0.1f)
					{
						LeftOn = true;
						RightOn = false;
					}
					else if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[0].PalmTransform.position) >= 0.1f)
					{
						LeftOn = false;
						RightOn = false;
					}
				}
			}
			if ((!RightOn && !LeftOn) || ((FVRInteractiveObject)mainObj).m_isHeld)
			{
				WatchGeo.transform.localPosition = posMiddle.transform.localPosition;
				WatchGeo.transform.localRotation = posMiddle.transform.localRotation;
				mainRig.isKinematic = false;
				mainCol.enabled = true;
				phys.SetActive(true);
			}
			if (grabInterface.m_isHeld)
			{
				WatchGeo.transform.localPosition = posMiddle.transform.localPosition;
				WatchGeo.transform.localRotation = posMiddle.transform.localRotation;
				mainRig.isKinematic = false;
				mainCol.enabled = true;
				FVRViveHand hand = grabInterface.m_hand;
				grabInterface.ForceBreakInteraction();
				((FVRInteractiveObject)mainObj).BeginInteraction(hand);
				hand.ForceSetInteractable((FVRInteractiveObject)(object)mainObj);
				phys.SetActive(true);
				((Component)grabInterface).gameObject.SetActive(false);
			}
		}

		private void Update()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			if (LeftOn && !RightOn && !((FVRInteractiveObject)mainObj).m_isHeld)
			{
				((Component)mainObj).gameObject.transform.position = ((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.position;
				((Component)mainObj).gameObject.transform.rotation = ((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.rotation;
				WatchGeo.transform.localPosition = posLeft.transform.localPosition;
				WatchGeo.transform.localRotation = posLeft.transform.localRotation;
				mainRig.isKinematic = true;
				mainCol.enabled = false;
				phys.SetActive(false);
				((Component)grabInterface).gameObject.SetActive(true);
			}
			if (RightOn && !LeftOn && !((FVRInteractiveObject)mainObj).m_isHeld)
			{
				((Component)mainObj).gameObject.transform.position = ((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.position;
				((Component)mainObj).gameObject.transform.rotation = ((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.rotation;
				WatchGeo.transform.localPosition = posRight.transform.localPosition;
				WatchGeo.transform.localRotation = posRight.transform.localRotation;
				mainRig.isKinematic = true;
				mainCol.enabled = false;
				phys.SetActive(false);
				((Component)grabInterface).gameObject.SetActive(true);
			}
		}
	}
}
namespace Volks.UniShield
{
	[BepInPlugin("Volks.UniShield", "UniShield", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class UniShieldPlugin : 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.UniShield");
			OtherLoader.RegisterDirectLoad(BasePath, "Volks.UniShield", "", "", "unishield", "");
		}
	}
}
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;
		}
	}
}