Decompiled source of A Box of Gun Parts v1.2.1

A_Box_of_Gun_Parts.dll

Decompiled 8 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 JerryComponent
{
	public class EnableIfDisabled : MonoBehaviour
	{
		public FVRFireArmRound Bullet;

		public GameObject Obj;

		public GameObject Renderer;

		private void Start()
		{
		}

		private void Update()
		{
			if (Bullet.IsSpent)
			{
				Obj.SetActive(true);
			}
			if (Bullet.IsChambered)
			{
				Renderer.SetActive(true);
			}
			if (!Bullet.IsChambered)
			{
				Renderer.SetActive(false);
			}
		}
	}
}
[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 JerryAr.A_Box_of_Gun_Parts
{
	[BepInPlugin("JerryAr.A_Box_of_Gun_Parts", "A_Box_of_Gun_Parts", "1.2.1")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class A_Box_of_Gun_PartsPlugin : 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(), "JerryAr.A_Box_of_Gun_Parts");
			OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.A_Box_of_Gun_Parts", "", "", "aboxofgunparts", "");
		}
	}
}
namespace JerryComponent
{
	public class AutoGrabMagWell : MonoBehaviour
	{
		public GameObject rot;

		public FVRFireArm gun;

		public FVRFoldingStockYAxis fold;

		private GameObject _player = null;

		private FVRViveHand rightHand = null;

		private void Awake()
		{
			_player = ((Component)Object.FindObjectOfType<FVRPlayerBody>()).gameObject;
		}

		private void Start()
		{
			rightHand = ((Component)_player.transform.Find("Controller (right)")).GetComponent<FVRViveHand>();
		}

		private void Update()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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)
			if (Object.op_Implicit((Object)(object)gun.Magazine))
			{
				if (gun.Magazine.IsBeltBox && rightHand.Input.IsGrabbing && rot.transform.localEulerAngles.y < 45f)
				{
					rightHand.ForceSetInteractable((FVRInteractiveObject)(object)fold);
					((FVRInteractiveObject)fold).BeginInteraction(rightHand);
				}
				else if (gun.Magazine.IsBeltBox && !rightHand.Input.IsGrabbing && rot.transform.localEulerAngles.y < 45f)
				{
					gun.EjectMag(false);
				}
				else if (gun.Magazine.IsBeltBox && rot.transform.localEulerAngles.y != 45f)
				{
				}
			}
			else if (Object.op_Implicit((Object)(object)gun.Magazine))
			{
			}
		}
	}
	public class BeltChange : MonoBehaviour
	{
		public OpenBoltReceiver gun2;

		public FVRFirearmBeltDisplayData data1;

		public FVRFirearmBeltDisplayData data2;

		public GameObject rot;

		public Transform _Magpos;

		public Transform _Boxpos;

		private void Start()
		{
		}

		private void Update()
		{
			//IL_000c: 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_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)
			if (rot.transform.localEulerAngles.x < 45f)
			{
				((FVRFireArm)gun2).BeltDD = data1;
			}
			if (rot.transform.localEulerAngles.x >= 45f)
			{
				((FVRFireArm)gun2).BeltDD = data2;
			}
			((FVRFireArm)gun2).BeltBoxMountPos = _Boxpos;
			((FVRFireArm)gun2).MagazineMountPos = _Magpos;
		}
	}
	public class Control_Enable : MonoBehaviour
	{
		public GameObject objToRead;

		public GameObject objToAffect;

		private void Start()
		{
		}

		private void Update()
		{
			if (objToRead.activeInHierarchy)
			{
				objToAffect.SetActive(true);
			}
			else
			{
				objToAffect.SetActive(false);
			}
		}
	}
	public class MagMani : MonoBehaviour
	{
		public OpenBoltReceiver gun;

		public GameObject magmount;

		public GameObject well;

		public GameObject latch;

		public GameObject belt;

		public Collider col;

		public GameObject beltFollower;

		public Collider col2;

		private void Start()
		{
		}

		private void Update()
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_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)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((FVRFireArm)gun).Magazine))
			{
				if ((float)((FVRFireArm)gun).Magazine.m_numRounds == 0f)
				{
					col.enabled = true;
					if (magmount.transform.localEulerAngles.z < 5f)
					{
						((FVRFireArm)gun).EjectMag(true);
					}
					else if (!(magmount.transform.localEulerAngles.z >= 5f))
					{
					}
				}
				else if ((float)((FVRFireArm)gun).Magazine.m_numRounds > 0f && magmount.transform.localEulerAngles.z == 45f)
				{
					col.enabled = false;
				}
			}
			else if (!Object.op_Implicit((Object)(object)((FVRFireArm)gun).Magazine) && magmount.transform.localEulerAngles.z < 5f)
			{
				well.transform.localEulerAngles = new Vector3(0f, 0f, 20f);
				((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			}
			else if (Object.op_Implicit((Object)(object)((FVRFireArm)gun).Magazine) && magmount.transform.localEulerAngles.z < 5f)
			{
				well.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			}
			if (((FVRFireArm)gun).HasBelt)
			{
				belt.SetActive(true);
			}
			else if (!((FVRFireArm)gun).HasBelt)
			{
				belt.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)((FVRFireArm)gun).Magazine))
			{
				col2.enabled = false;
				beltFollower.transform.localPosition = ((Component)((FVRFireArm)gun).Magazine.Follower).transform.localPosition;
			}
			if (!Object.op_Implicit((Object)(object)((FVRFireArm)gun).Magazine))
			{
				col2.enabled = true;
				beltFollower.transform.localPosition = new Vector3(0f, 0f, 0f);
			}
		}
	}
}
public class MagPosChange : MonoBehaviour
{
	private void Start()
	{
	}

	private void Update()
	{
	}
}
namespace JerryComponent
{
	public class DisableInterfaceAndcolliders : MonoBehaviour
	{
		public Handgun gun;

		public GameObject safetyrot;

		public FVRFireArmAttachmentMount maglatch;

		public FVRFireArmAttachmentMount barrel;

		public FVRFireArmAttachmentMount spring;

		public FVRFireArmAttachmentMount slide;

		public FVRFireArmAttachmentMount trigger;

		public FVRFireArmAttachmentMount triggerguard;

		public FVRFireArmAttachmentMount safety;

		public FVRFireArmAttachmentMount lever;

		public FVRFireArmAttachmentMount hammer;

		public FVRFireArmAttachmentMount hammerstop;

		public FVRFireArmAttachmentMount sliderelease;

		public Collider safetycol;

		public Collider springcol;

		public Collider slidecol;

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			if (!maglatch.HasAttachmentsOnIt())
			{
				((FVRFireArm)gun).EjectMag(false);
			}
			else if (!maglatch.HasAttachmentsOnIt())
			{
			}
			if (barrel.HasAttachmentsOnIt())
			{
				springcol.enabled = true;
			}
			else if (!barrel.HasAttachmentsOnIt())
			{
				springcol.enabled = false;
			}
			if (barrel.HasAttachmentsOnIt() && spring.HasAttachmentsOnIt() && lever.HasAttachmentsOnIt() && hammer.HasAttachmentsOnIt() && hammerstop.HasAttachmentsOnIt() && sliderelease.HasAttachmentsOnIt())
			{
				slidecol.enabled = true;
			}
			else if (!barrel.HasAttachmentsOnIt() || !spring.HasAttachmentsOnIt() || !lever.HasAttachmentsOnIt() || !hammer.HasAttachmentsOnIt() || !hammerstop.HasAttachmentsOnIt() || !sliderelease.HasAttachmentsOnIt())
			{
				slidecol.enabled = false;
			}
			if (slide.HasAttachmentsOnIt())
			{
				safetycol.enabled = true;
			}
			else if (!slide.HasAttachmentsOnIt())
			{
				safetycol.enabled = false;
			}
			if (!slide.HasAttachmentsOnIt() || !trigger.HasAttachmentsOnIt() || !triggerguard.HasAttachmentsOnIt() || !safety.HasAttachmentsOnIt())
			{
				gun.m_isSafetyEngaged = true;
				safetyrot.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			}
			else if (slide.HasAttachmentsOnIt() && trigger.HasAttachmentsOnIt() && triggerguard.HasAttachmentsOnIt() && !safety.HasAttachmentsOnIt())
			{
			}
		}
	}
	public class SlideScope : MonoBehaviour
	{
		public GameObject SlideRot;

		public GameObject SlideRot2;

		public Camera Cam;

		public MeshRenderer Rend;

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			Cam.fieldOfView = SlideRot.transform.localEulerAngles.x;
			((Renderer)Rend).material.SetFloat("_RedDotSize", SlideRot2.transform.localEulerAngles.x * SlideRot2.transform.localEulerAngles.x * SlideRot2.transform.localEulerAngles.x);
		}
	}
}
public class SlideScopeH3 : MonoBehaviour
{
	private void Start()
	{
	}

	private void Update()
	{
	}
}
namespace JerryComponent
{
	public class control_component : MonoBehaviour
	{
		public GameObject Comp;

		public GameObject Comp2;

		public GameObject Rot;

		private void Start()
		{
		}

		private void Update()
		{
			//IL_000c: 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)
			if (Rot.transform.localEulerAngles.x >= 45f)
			{
				Comp.SetActive(false);
				Comp2.SetActive(true);
			}
			else
			{
				Comp.SetActive(true);
				Comp2.SetActive(false);
			}
		}
	}
}