Decompiled source of NightVision v1.1.0

NGA.SwapNVGs.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sodalite;
using Sodalite.Api;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("NGA.SwapNVGs")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace NGA
{
	[BepInPlugin("NGA.SwapNVGs", "SwapNVGs", "0.1.0")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInProcess("h3vr.exe")]
	public class SwapNVGs : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FVRWristMenu2))]
		[HarmonyPatch("Awake")]
		private class WristMenuAwakeHook
		{
			private static void Postfix(FVRWristMenu2 __instance)
			{
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Expected O, but got Unknown
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Expected O, but got Unknown
				if ((Object)(object)__instance == (Object)null)
				{
					Logger.LogMessage((object)"FVRWristMenu2 is null!?");
				}
				bool flag = false;
				string text = "NVG (Toggle)";
				foreach (WristMenuButton button in WristMenuAPI.Buttons)
				{
					Logger.LogMessage((object)("CC " + button.Text));
					if (button.Text == text)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					WristMenuAPI.Buttons.Add(new WristMenuButton(text, int.MaxValue, new ButtonClickEvent(SpawnBadBoys)));
				}
			}

			private static void SpawnBadBoys(object sender, ButtonClickEventArgs args)
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Invalid comparison between Unknown and I4
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Expected O, but got Unknown
				GameObject val = GameObject.Find("Fotel(Clone)");
				if (Object.op_Implicit((Object)(object)val))
				{
					Logger.LogMessage((object)"Found some head NVG!");
					Object.Destroy((Object)(object)val);
					return;
				}
				FVRPlayerBody val2 = Object.FindObjectOfType<FVRPlayerBody>();
				ItemSpawnerV2 val3 = new ItemSpawnerV2();
				ItemSpawnerID spawnerID = IM.GetSpawnerID("NGA_Fotel");
				AnvilManager.Run(val3.SpawnItemsToRayPoint(spawnerID, ((Component)val2.Head).transform.position));
				Object.Destroy((Object)(object)val3);
				GameObject val4 = GameObject.Find("Fotel(Clone)");
				if (!Object.op_Implicit((Object)(object)val4))
				{
					return;
				}
				float value = config_spotlight_angle.Value;
				Light componentInChildren = val4.GetComponentInChildren<Light>();
				if ((Object)(object)componentInChildren != (Object)null && (int)componentInChildren.type == 0)
				{
					((Behaviour)componentInChildren).enabled = config_spotlight_enabled.Value;
					componentInChildren.spotAngle = value;
				}
				CapsuleCollider component = val4.GetComponent<CapsuleCollider>();
				if ((Object)(object)component != (Object)null)
				{
					float value2 = config_trigger_collider_radius.Value;
					component.radius = value2;
				}
				MaterialPropertyBlock val5 = new MaterialPropertyBlock();
				val5.SetFloat("_Hue", config_nvg_hue.Value);
				val5.SetFloat("_OutlineWidth", config_nvg_outline_width.Value);
				val5.SetFloat("_OutlineBrightness", config_nvg_outline_brightness.Value);
				val5.SetFloat("_Brightness", config_nvg_brightness.Value);
				val5.SetFloat("_BlendBlackColor", config_nvg_color_blend.Value);
				val5.SetFloat("_RenderRange", config_nvg_render_range.Value);
				Transform val6 = val4.transform.Find("Geo");
				if (Object.op_Implicit((Object)(object)val6))
				{
					MeshRenderer component2 = ((Component)val6).GetComponent<MeshRenderer>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						((Renderer)component2).SetPropertyBlock(val5);
					}
				}
			}
		}

		private static ConfigEntry<float> config_trigger_collider_radius;

		private static ConfigEntry<float> config_spotlight_angle;

		private static ConfigEntry<bool> config_spotlight_enabled;

		private static ConfigEntry<float> config_nvg_hue;

		private static ConfigEntry<float> config_nvg_brightness;

		private static ConfigEntry<float> config_nvg_color_blend;

		private static ConfigEntry<float> config_nvg_outline_brightness;

		private static ConfigEntry<float> config_nvg_outline_width;

		private static ConfigEntry<float> config_nvg_render_range;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("NGA.SwapNVGs");
			Logger.LogMessage((object)"New harmony");
			SetUpConfigFields();
			Logger.LogMessage((object)"Setted the fields");
			val.PatchAll();
			Logger.LogMessage((object)"Hello, world! Sent from NGA.SwapNVGs 0.0.1");
		}

		private void SetUpConfigFields()
		{
			config_trigger_collider_radius = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "Radius of Enable/Disable triggerbox", 0.18f, "Recommend 0.11 for smaller option. Original is 0.18.  Requires Toggling from Wrist Menu to take effect.");
			config_spotlight_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Head-Mounted Light", "Light Enabled", true, "Turns the spotlight on/off. Requires Toggling from Wrist Menu to take effect.");
			config_spotlight_angle = ((BaseUnityPlugin)this).Config.Bind<float>("Head-Mounted Light", "Light Radius", 40f, "How wide or concentrated the spotlight is. Recommend 80 for larger. Requires Toggling from Wrist Menu to take effect.");
			config_nvg_hue = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Effect Properties", "Color Hue", 120f, "White phosphor is 180. Classic green is 120. Obvious color changes very 60. Max: 360. Min: 0.");
			config_nvg_outline_width = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Effect Properties", "Outline Width", 0.25f, "Max: 1. Min: 0.");
			config_nvg_outline_brightness = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Effect Properties", "Outline Brightness", 4f, "Max: 8. Min: 0.");
			config_nvg_brightness = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Effect Properties", "Brightness", 0.25f, "Max: 4. Min: 0.");
			config_nvg_color_blend = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Effect Properties", "Blend Black Color", 0.2f, "Kinda makes it darker, not sure exactly. Max: 0.9. Min: 0.");
			config_nvg_render_range = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Effect Properties", "Render Range", 1f, "Not sure exactly. Max: 5. Min: 0.");
		}
	}
}

NightVision.dll

Decompiled 4 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OpenScripts2;
using OtherLoader;
using UnityEngine;
using UnityEngine.UI;

[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]
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public class DeferredNightVisionEffect : MonoBehaviour
{
	[SerializeField]
	[Tooltip("The main color of the NV effect")]
	public Color m_NVColor = new Color(0f, 1f, 0.1724138f, 0f);

	[SerializeField]
	[Tooltip("The color that the NV effect will 'bleach' towards (white = default)")]
	public Color m_TargetBleachColor = new Color(1f, 1f, 1f, 0f);

	[Range(0f, 0.1f)]
	[Tooltip("How much base lighting does the NV effect pick up")]
	public float m_baseLightingContribution = 0.025f;

	[Range(0f, 128f)]
	[Tooltip("The higher this value, the more bright areas will get 'bleached out'")]
	public float m_LightSensitivityMultiplier = 100f;

	private Material m_Material;

	private Shader m_Shader;

	[Tooltip("Do we want to apply a vignette to the edges of the screen?")]
	public bool useVignetting = true;

	public Shader NightVisionShader => m_Shader;

	private void DestroyMaterial(Material mat)
	{
		if (Object.op_Implicit((Object)(object)mat))
		{
			Object.DestroyImmediate((Object)(object)mat);
			mat = null;
		}
	}

	private void CreateMaterials()
	{
		if ((Object)(object)m_Shader == (Object)null)
		{
			m_Shader = Shader.Find("Custom/DeferredNightVisionShader");
		}
		if ((Object)(object)m_Material == (Object)null && (Object)(object)m_Shader != (Object)null && m_Shader.isSupported)
		{
			m_Material = CreateMaterial(m_Shader);
		}
	}

	private Material CreateMaterial(Shader shader)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)shader))
		{
			return null;
		}
		Material val = new Material(shader);
		((Object)val).hideFlags = (HideFlags)61;
		return val;
	}

	private void OnDisable()
	{
		DestroyMaterial(m_Material);
		m_Material = null;
		m_Shader = null;
	}

	[ContextMenu("UpdateShaderValues")]
	public void UpdateShaderValues()
	{
		//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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)m_Material == (Object)null))
		{
			m_Material.SetVector("_NVColor", Color.op_Implicit(m_NVColor));
			m_Material.SetVector("_TargetWhiteColor", Color.op_Implicit(m_TargetBleachColor));
			m_Material.SetFloat("_BaseLightingContribution", m_baseLightingContribution);
			m_Material.SetFloat("_LightSensitivityMultiplier", m_LightSensitivityMultiplier);
			m_Material.shaderKeywords = null;
			if (useVignetting)
			{
				Shader.EnableKeyword("USE_VIGNETTE");
			}
			else
			{
				Shader.DisableKeyword("USE_VIGNETTE");
			}
		}
	}

	private void OnEnable()
	{
		CreateMaterials();
		UpdateShaderValues();
	}

	public void ReloadShaders()
	{
		OnDisable();
	}

	private void OnRenderImage(RenderTexture source, RenderTexture destination)
	{
		UpdateShaderValues();
		CreateMaterials();
		Graphics.Blit((Texture)(object)source, destination, m_Material);
	}
}
namespace NGA
{
	[ExecuteInEditMode]
	[RequireComponent(typeof(Camera))]
	public class DeferredNightVisionEffect2 : MonoBehaviour
	{
		[SerializeField]
		[Tooltip("The main color of the NV effect")]
		public Color m_NVColor = new Color(0f, 1f, 0.1724138f, 0f);

		[SerializeField]
		[Tooltip("The color that the NV effect will 'bleach' towards (white = default)")]
		public Color m_TargetBleachColor = new Color(1f, 1f, 1f, 0f);

		[Range(0f, 0.1f)]
		[Tooltip("How much base lighting does the NV effect pick up")]
		public float m_baseLightingContribution = 0.025f;

		[Range(0f, 128f)]
		[Tooltip("The higher this value, the more bright areas will get 'bleached out'")]
		public float m_LightSensitivityMultiplier = 100f;

		private Material m_Material;

		private Shader m_Shader;

		[Tooltip("Do we want to apply a vignette to the edges of the screen?")]
		public bool useVignetting = true;

		public Shader NightVisionShader => m_Shader;

		private void DestroyMaterial(Material mat)
		{
			if (Object.op_Implicit((Object)(object)mat))
			{
				Object.DestroyImmediate((Object)(object)mat);
				mat = null;
			}
		}

		private void CreateMaterials()
		{
			if ((Object)(object)m_Shader == (Object)null)
			{
				m_Shader = Shader.Find("Custom/DeferredNightVisionShader");
			}
			if ((Object)(object)m_Material == (Object)null && (Object)(object)m_Shader != (Object)null && m_Shader.isSupported)
			{
				m_Material = CreateMaterial(m_Shader);
			}
		}

		private Material CreateMaterial(Shader shader)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)shader))
			{
				return null;
			}
			Material val = new Material(shader);
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		private void OnDisable()
		{
			DestroyMaterial(m_Material);
			m_Material = null;
			m_Shader = null;
		}

		[ContextMenu("UpdateShaderValues")]
		public void UpdateShaderValues()
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_Material == (Object)null))
			{
				m_Material.SetVector("_NVColor", Color.op_Implicit(m_NVColor));
				m_Material.SetVector("_TargetWhiteColor", Color.op_Implicit(m_TargetBleachColor));
				m_Material.SetFloat("_BaseLightingContribution", m_baseLightingContribution);
				m_Material.SetFloat("_LightSensitivityMultiplier", m_LightSensitivityMultiplier);
				m_Material.shaderKeywords = null;
				if (useVignetting)
				{
					Shader.EnableKeyword("USE_VIGNETTE");
				}
				else
				{
					Shader.DisableKeyword("USE_VIGNETTE");
				}
			}
		}

		private void OnEnable()
		{
			CreateMaterials();
			UpdateShaderValues();
		}

		public void ReloadShaders()
		{
			OnDisable();
		}

		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			UpdateShaderValues();
			CreateMaterials();
			Graphics.Blit((Texture)(object)source, destination, m_Material);
		}
	}
}
namespace NGA.NightVision
{
	[BepInPlugin("NGA.NightVision", "NightVision", "0.1.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class NightVisionPlugin : 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(), "NGA.NightVision");
			OtherLoader.RegisterDirectLoad(BasePath, "NGA.NightVision", "", "", "fotel", "");
		}
	}
}
namespace NGA
{
	public class HeadTracked : MonoBehaviour
	{
		public bool isTriggerPressed = false;

		public Transform marriedObj = null;

		public FVRPhysicalObject ThisObj = null;

		public void FixedUpdate()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)marriedObj == (Object)null)
			{
				FVRPlayerBody val = Object.FindObjectOfType<FVRPlayerBody>();
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.Head))
				{
					marriedObj = val.Head;
				}
			}
			if ((Object)(object)marriedObj != (Object)null)
			{
				((Component)ThisObj).transform.position = ((Component)marriedObj).transform.position;
				((Component)ThisObj).transform.rotation = ((Component)marriedObj).transform.rotation;
			}
		}

		private void OnTriggerStay(Collider other)
		{
			FVRViveHand component = ((Component)other).GetComponent<FVRViveHand>();
			if ((Object)(object)component != (Object)null && component.Input.TriggerDown && !isTriggerPressed)
			{
				isTriggerPressed = true;
				Transform val = ((Component)this).transform.Find("Geo");
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(!((Component)val).gameObject.activeSelf);
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			FVRViveHand component = ((Component)other).GetComponent<FVRViveHand>();
			if ((Object)(object)component != (Object)null)
			{
				Debug.Log((object)("Exited trigger zone with FVRViveHand: " + ((Object)component).name));
				isTriggerPressed = false;
			}
		}
	}
	public class InputManipulator : FVRFireArmAttachmentInterface
	{
		public enum EDegreesOfFreedom
		{
			Linear,
			Planar,
			Spacial
		}

		[Serializable]
		public class MovementMode
		{
			public string ModeText;

			public EDegreesOfFreedom DegreesOfFreedom;

			public Axis LimitingAxis;
		}

		[Header("Moving FireArm Attachment Interface Config")]
		[Tooltip("One degree means linear movement, two degrees means movement on a plane, three degrees free spacial movement.")]
		public EDegreesOfFreedom DegreesOfFreedom;

		public Axis LimitingAxis;

		public Vector2 XLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity);

		public Vector2 YLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity);

		public Vector2 ZLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity);

		public bool OverridesDisableOnHoverOfMount;

		[Tooltip("Something placed on this mount will disabled the hover on disable piece again.")]
		public FVRFireArmAttachmentMount OverrideDisableOverrideMount;

		[Tooltip("This transforms position will be vaulted as well")]
		public Transform SecondaryPiece;

		public bool CanRotate;

		public float RotationStep = 45f;

		public bool CanSwitchModes;

		public Text ModeDisplay;

		public MovementMode[] MovementModes;

		private int _currentMode;

		private Vector3 _lastPos;

		private Vector3 _lastHandPos;

		private Vector3 _startPos;

		private Vector3 _lowerLimit;

		private Vector3 _upperLimit;

		[HideInInspector]
		public GameObject DisableOnHover;

		[HideInInspector]
		public GameObject EnableOnHover;

		public const string POSITION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Position";

		public const string ROTATION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Rotation";

		public const string SECONDARY_POSITION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Secondary Position";

		public InputManipulator()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0066: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00c2: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			MovementMode[] array = new MovementMode[4];
			MovementMode val = new MovementMode();
			val.ModeText = "All";
			val.DegreesOfFreedom = (EDegreesOfFreedom)2;
			val.LimitingAxis = (Axis)0;
			array[0] = val;
			val = new MovementMode();
			val.ModeText = "X Limited";
			val.DegreesOfFreedom = (EDegreesOfFreedom)1;
			val.LimitingAxis = (Axis)0;
			array[1] = val;
			val = new MovementMode();
			val.ModeText = "Y Limited";
			val.DegreesOfFreedom = (EDegreesOfFreedom)1;
			val.LimitingAxis = (Axis)1;
			array[2] = val;
			val = new MovementMode();
			val.ModeText = "Z Limited";
			val.DegreesOfFreedom = (EDegreesOfFreedom)1;
			val.LimitingAxis = (Axis)2;
			array[3] = val;
			MovementModes = (MovementMode[])(object)array;
			((FVRFireArmAttachmentInterface)this)..ctor();
		}

		public override void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			((FVRFireArmAttachmentInterface)this).Awake();
			_lowerLimit = new Vector3(XLimits.x, YLimits.x, ZLimits.x);
			_upperLimit = new Vector3(XLimits.y, YLimits.y, ZLimits.y);
			_startPos = ((Component)((AnvilAsset)((FVRPhysicalObject)base.Attachment).ObjectWrapper).GetGameObject().GetComponent<FVRFireArmAttachment>().AttachmentInterface).transform.localPosition;
			if ((Object)(object)ModeDisplay != (Object)null)
			{
				ModeDisplay.text = MovementModes[_currentMode].ModeText;
			}
		}

		public override void OnAttach()
		{
			((FVRFireArmAttachmentInterface)this).OnAttach();
			if (OverridesDisableOnHoverOfMount && base.Attachment.curMount.HasHoverDisablePiece)
			{
				FVRPhysicalObject myObject = base.Attachment.curMount.MyObject;
				CustomOpenScripts2Attachment val = (CustomOpenScripts2Attachment)(object)((myObject is CustomOpenScripts2Attachment) ? myObject : null);
				if ((Object)(object)val != (Object)null)
				{
					FVRFireArmAttachmentInterface attachmentInterface = ((FVRFireArmAttachment)val).AttachmentInterface;
					MovingFireArmAttachmentInterface val2 = (MovingFireArmAttachmentInterface)(object)((attachmentInterface is MovingFireArmAttachmentInterface) ? attachmentInterface : null);
					if ((Object)(object)val2 != (Object)null)
					{
						DisableOnHover = val2.DisableOnHover;
						val2.DisableOnHover = null;
						GameObject disableOnHover = DisableOnHover;
						if (!((Object)(object)disableOnHover == (Object)null))
						{
							disableOnHover.SetActive(true);
						}
						goto IL_00e1;
					}
				}
				DisableOnHover = base.Attachment.curMount.DisableOnHover;
				base.Attachment.curMount.DisableOnHover = null;
				GameObject disableOnHover2 = DisableOnHover;
				if ((Object)(object)disableOnHover2 != (Object)null)
				{
					disableOnHover2.SetActive(true);
				}
			}
			goto IL_00e1;
			IL_00e1:
			if (!OverridesDisableOnHoverOfMount || !base.Attachment.curMount.HasHoverEnablePiece)
			{
				return;
			}
			FVRPhysicalObject myObject2 = base.Attachment.curMount.MyObject;
			CustomOpenScripts2Attachment val3 = (CustomOpenScripts2Attachment)(object)((myObject2 is CustomOpenScripts2Attachment) ? myObject2 : null);
			if ((Object)(object)val3 != (Object)null)
			{
				FVRFireArmAttachmentInterface attachmentInterface2 = ((FVRFireArmAttachment)val3).AttachmentInterface;
				MovingFireArmAttachmentInterface val4 = (MovingFireArmAttachmentInterface)(object)((attachmentInterface2 is MovingFireArmAttachmentInterface) ? attachmentInterface2 : null);
				if ((Object)(object)val4 != (Object)null)
				{
					EnableOnHover = val4.EnableOnHover;
					val4.EnableOnHover = null;
					GameObject enableOnHover = EnableOnHover;
					if (!((Object)(object)enableOnHover == (Object)null))
					{
						enableOnHover.SetActive(false);
					}
					return;
				}
			}
			EnableOnHover = base.Attachment.curMount.EnableOnHover;
			base.Attachment.curMount.EnableOnHover = null;
			GameObject enableOnHover2 = EnableOnHover;
			if (!((Object)(object)enableOnHover2 == (Object)null))
			{
				enableOnHover2.SetActive(false);
			}
		}

		public override void OnDetach()
		{
			FVRPhysicalObject myObject = base.Attachment.curMount.MyObject;
			CustomOpenScripts2Attachment val = (CustomOpenScripts2Attachment)(object)((myObject is CustomOpenScripts2Attachment) ? myObject : null);
			if ((Object)(object)val != (Object)null)
			{
				FVRFireArmAttachmentInterface attachmentInterface = ((FVRFireArmAttachment)val).AttachmentInterface;
				MovingFireArmAttachmentInterface val2 = (MovingFireArmAttachmentInterface)(object)((attachmentInterface is MovingFireArmAttachmentInterface) ? attachmentInterface : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.DisableOnHover = DisableOnHover;
					val2.EnableOnHover = EnableOnHover;
					goto IL_0087;
				}
			}
			base.Attachment.curMount.DisableOnHover = DisableOnHover;
			base.Attachment.curMount.EnableOnHover = EnableOnHover;
			goto IL_0087;
			IL_0087:
			DisableOnHover = null;
			EnableOnHover = null;
			((FVRFireArmAttachmentInterface)this).OnDetach();
		}

		public override void FVRUpdate()
		{
			((FVRInteractiveObject)this).FVRUpdate();
			if (!OverridesDisableOnHoverOfMount || !((Object)(object)OverrideDisableOverrideMount != (Object)null))
			{
				return;
			}
			if (OverrideDisableOverrideMount.HasAttachmentsOnIt())
			{
				GameObject disableOnHover = DisableOnHover;
				if ((Object)(object)disableOnHover != (Object)null)
				{
					disableOnHover.SetActive(false);
				}
			}
			else
			{
				GameObject disableOnHover2 = DisableOnHover;
				if ((Object)(object)disableOnHover2 != (Object)null)
				{
					disableOnHover2.SetActive(true);
				}
			}
			if (OverrideDisableOverrideMount.HasAttachmentsOnIt())
			{
				GameObject enableOnHover = EnableOnHover;
				if (!((Object)(object)enableOnHover == (Object)null))
				{
					enableOnHover.SetActive(true);
				}
			}
			else
			{
				GameObject enableOnHover2 = EnableOnHover;
				if (!((Object)(object)enableOnHover2 == (Object)null))
				{
					enableOnHover2.SetActive(false);
				}
			}
		}

		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)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).BeginInteraction(hand);
			_lastPos = ((Component)this).transform.position;
			_lastHandPos = hand.Input.FilteredPos;
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0099: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Invalid comparison between Unknown and I4
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			((FVRFireArmAttachmentInterface)this).UpdateInteraction(hand);
			Vector3 zero = Vector3.zero;
			((Vector3)(ref zero))..ctor((float)(((int)LimitingAxis == 0) ? 1 : 0), (float)(((int)LimitingAxis == 1) ? 1 : 0), (float)(((int)LimitingAxis == 2) ? 1 : 0));
			if (hand.Input.TriggerFloat > 0f)
			{
				Vector3 val = (hand.Input.FilteredPos - _lastHandPos) * hand.Input.TriggerFloat;
				Vector3 val2 = (((Component)this).transform.position - _lastPos) * hand.Input.TriggerFloat;
				Vector3 newPosRaw = ((Component)this).transform.position + val - val2;
				EDegreesOfFreedom degreesOfFreedom = DegreesOfFreedom;
				if ((int)degreesOfFreedom != 0)
				{
					if ((int)degreesOfFreedom != 1)
					{
						if ((int)degreesOfFreedom == 2)
						{
							ThreeDegreesOfFreedom(newPosRaw);
						}
					}
					else
					{
						TwoDegreesOfFreedom(newPosRaw);
					}
				}
				else
				{
					OneDegreeOfFreedom(newPosRaw);
				}
			}
			else if (OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.up))
			{
				((Component)this).transform.localPosition = _startPos;
			}
			else if (CanRotate && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.left))
			{
				Console.WriteLine("Rotation Axis: " + zero);
				((Component)this).transform.Rotate(zero * RotationStep);
			}
			else if (CanRotate && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.right))
			{
				Console.WriteLine("Rotation Axis: " + zero);
				((Component)this).transform.Rotate(-zero * RotationStep);
			}
			else if (CanSwitchModes && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.down))
			{
				SwitchMode();
			}
			_lastPos = ((Component)this).transform.position;
			_lastHandPos = hand.Input.FilteredPos;
		}

		private void OneDegreeOfFreedom(Vector3 newPosRaw)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_000e: 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)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition;
			if (CanSwitchModes)
			{
				Vector3 val = UnityEngineExtensions.ApproximateInfiniteComponent(UnityEngineExtensions.GetCombinedAxisVector(_lowerLimit, LimitingAxis, ((Component)this).transform.localPosition), 100f);
				Vector3 val2 = UnityEngineExtensions.ApproximateInfiniteComponent(UnityEngineExtensions.GetCombinedAxisVector(_upperLimit, LimitingAxis, ((Component)this).transform.localPosition), 100f);
				localPosition = ((FVRInteractiveObject)this).GetClosestValidPoint(val, val2, ((Component)this).transform.parent.InverseTransformPoint(newPosRaw));
			}
			else
			{
				localPosition = UnityEngineExtensions.Clamp(UnityEngineExtensions.GetAxisVector(((Component)this).transform.parent.InverseTransformPoint(newPosRaw), LimitingAxis), _lowerLimit, _upperLimit);
			}
			((Component)this).transform.localPosition = localPosition;
		}

		private void TwoDegreesOfFreedom(Vector3 newPosRaw)
		{
			//IL_0047: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((!CanSwitchModes) ? UnityEngineExtensions.RemoveAxisValue(((Component)this).transform.parent.InverseTransformPoint(newPosRaw), LimitingAxis) : UnityEngineExtensions.ProjectOnPlaneThroughPoint(newPosRaw, ((Component)this).transform.position, UnityEngineExtensions.GetLocalDirAxis(((Component)this).transform.parent, LimitingAxis)));
			Vector3 val2 = UnityEngineExtensions.Clamp(((Component)this).transform.parent.InverseTransformPoint(val), _lowerLimit, _upperLimit);
			((Component)this).transform.localPosition = UnityEngineExtensions.ModifyAxisValue(val2, LimitingAxis, UnityEngineExtensions.GetAxisValue(_startPos, LimitingAxis));
		}

		private void ThreeDegreesOfFreedom(Vector3 newPosRaw)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localPosition = UnityEngineExtensions.Clamp(((Component)this).transform.parent.InverseTransformPoint(newPosRaw), _lowerLimit, _upperLimit);
		}

		[ContextMenu("Copy existing Interface's values")]
		public void CopyAttachment()
		{
			FVRFireArmAttachmentInterface[] components = ((Component)this).GetComponents<FVRFireArmAttachmentInterface>();
			FVRFireArmAttachmentInterface val = components.Single((FVRFireArmAttachmentInterface c) => (Object)(object)c != (Object)(object)this);
			val.Attachment.AttachmentInterface = (FVRFireArmAttachmentInterface)(object)this;
			UniversalCopy.CopyComponent<FVRFireArmAttachmentInterface>((Component)(object)this, val);
		}

		private void SwitchMode()
		{
			//IL_0056: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			_currentMode = (_currentMode + 1) % MovementModes.Length;
			if ((Object)(object)ModeDisplay != (Object)null)
			{
				ModeDisplay.text = MovementModes[_currentMode].ModeText;
			}
			DegreesOfFreedom = MovementModes[_currentMode].DegreesOfFreedom;
			LimitingAxis = MovementModes[_currentMode].LimitingAxis;
		}
	}
	public class RailEnumerator : MonoBehaviour
	{
		public bool executedUpdate = false;

		public int enumToSet = 159;

		private void Start()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			FVRFireArmAttachment component = ((Component)this).GetComponent<FVRFireArmAttachment>();
			component.Type = (FVRFireArmAttachementMountType)enumToSet;
		}

		private void Update()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected I4, but got Unknown
			if (!executedUpdate)
			{
				FVRFireArmAttachment component = ((Component)this).GetComponent<FVRFireArmAttachment>();
				Debug.Log((object)string.Concat("Mount type ", component.Type, " int ", (int)component.Type));
				executedUpdate = true;
			}
		}
	}
}