Decompiled source of FireArmPhobia v0.0.1

FireArmPhobia.dll

Decompiled 2 days ago
using System;
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 Sodalite;
using Sodalite.Api;
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 JerryEffect
{
	public class ShaderApplier : MonoBehaviour
	{
		public VRFrostedGlassEffect Effect;

		public Shader Shader;

		public float BlurInt = 0f;

		public float MaskInt = 0f;

		public float BlurMul = 0.5f;

		public float MaskMul = 0.1f;

		public float MaxDist = 10f;

		public float Suppress = 0f;

		public float MaxSuppress = 5f;

		public float SuppressRef = 5f;

		public float SuppressMul = 0.25f;

		public float cd = 0f;

		public float cdref = 2.5f;

		public float SuppressReduceMul = 0.25f;

		public GrenadeExplosion GE;

		public ExplosionSound ES;

		private void Start()
		{
			GE.m_hasExploded = true;
			Effect = ((Component)GM.CurrentMovementManager.Head).gameObject.AddComponent<VRFrostedGlassEffect>();
			Effect.blurShader = Shader;
			Effect.SA = this;
		}

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
		}

		private void Update()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.transform.position = ((Component)GM.CurrentMovementManager.Head).gameObject.transform.position;
			if ((Object)(object)Effect != (Object)null)
			{
				Effect.blurStrength = BlurInt;
				Effect.maskPower = MaskInt;
			}
			if (BlurInt > 25f)
			{
				BlurInt = 25f;
			}
			if (MaskInt > 5f)
			{
				MaskInt = 5f;
			}
			BlurInt = Mathf.Lerp(BlurInt, 0f, Time.deltaTime * 0.25f);
			MaskInt = Mathf.Lerp(MaskInt, 0f, Time.deltaTime * 0.25f);
			if (cd > 0f)
			{
				cd -= Time.deltaTime;
			}
			if (cd < 0f)
			{
				cd = 0f;
			}
			if (cd <= 0f)
			{
				Suppress = Mathf.Lerp(Suppress, 0f, Time.deltaTime * SuppressReduceMul);
			}
			if (Suppress > MaxSuppress)
			{
				Suppress = MaxSuppress;
			}
		}

		private void OnShotFired(FVRFireArm firearm)
		{
			//IL_002e: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			GE.m_hasExploded = false;
			GE.Explode();
			ES.Explode();
			if (!(Vector3.Distance(((Component)firearm).gameObject.transform.position, ((Component)GM.CurrentMovementManager.Head).gameObject.transform.position) <= 10f))
			{
				return;
			}
			if (BlurInt > SuppressRef)
			{
				if (!firearm.m_isSuppressed)
				{
					Suppress += Mathf.Abs(1f - Mathf.Abs(100f - firearm.AudioClipSet.Loudness_Primary) / 100f) * SuppressMul;
				}
				if (firearm.m_isSuppressed)
				{
					Suppress += Mathf.Abs(1f - Mathf.Abs(100f - firearm.AudioClipSet.Loudness_Primary) / 100f) * SuppressMul;
				}
			}
			cd = cdref;
			if (!firearm.m_isSuppressed)
			{
				BlurInt += Mathf.Abs(1f - Mathf.Abs(100f - firearm.AudioClipSet.Loudness_Primary) / 100f) * (MaxDist - Vector3.Distance(((Component)firearm).gameObject.transform.position, ((Component)GM.CurrentMovementManager.Head).gameObject.transform.position)) * BlurMul;
				MaskInt += Mathf.Abs(1f - Mathf.Abs(100f - firearm.AudioClipSet.Loudness_Primary) / 100f) * (MaxDist - Vector3.Distance(((Component)firearm).gameObject.transform.position, ((Component)GM.CurrentMovementManager.Head).gameObject.transform.position)) * MaskMul;
			}
			if (firearm.m_isSuppressed)
			{
				BlurInt += Mathf.Abs(1f - Mathf.Abs(100f - firearm.AudioClipSet.Loudness_Primary) / 100f) * (MaxDist - Vector3.Distance(((Component)firearm).gameObject.transform.position, ((Component)GM.CurrentMovementManager.Head).gameObject.transform.position)) * BlurMul;
				MaskInt += Mathf.Abs(1f - Mathf.Abs(100f - firearm.AudioClipSet.Loudness_Primary) / 100f) * (MaxDist - Vector3.Distance(((Component)firearm).gameObject.transform.position, ((Component)GM.CurrentMovementManager.Head).gameObject.transform.position)) * MaskMul;
			}
		}

		private void OnDestroy()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
		}
	}
}
namespace JerryBlur
{
	[BepInPlugin("JerryDLL.JerryBlur", "JB", "1.0.0")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInProcess("h3vr.exe")]
	public class SpawnFrostGlassObj : BaseUnityPlugin
	{
		[NonSerialized]
		public GameObject Reflect;

		public static bool SpawnTheReflect = false;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogMessage((object)"New harmony");
			Logger.LogMessage((object)"Setted the fields");
			Harmony.CreateAndPatchAll(typeof(SpawnFrostGlassObj), (string)null);
			Logger.LogMessage((object)"Loaded sf System");
		}

		[HarmonyPatch(typeof(FVRWristMenu2), "Awake")]
		[HarmonyPostfix]
		public static void SFWMAH(FVRWristMenu2 __instance)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			if ((Object)(object)__instance == (Object)null)
			{
				Logger.LogMessage((object)"No FVRWristMenu2");
			}
			bool flag = false;
			string text = "FireArm Phobia?";
			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, new ButtonClickEvent(SpawnRTR)));
			}
		}

		private static void SpawnRTR(object sender, ButtonClickEventArgs args)
		{
			SpawnTheReflect = !SpawnTheReflect;
		}

		public void FixedUpdate()
		{
			//IL_0046: 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_0064: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (SpawnTheReflect)
			{
				if ((Object)(object)Reflect == (Object)null)
				{
					ItemSpawnerID spawnerID = IM.GetSpawnerID("FireArmPhobia");
					FVRObject mainObject = spawnerID.MainObject;
					Reflect = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)GM.CurrentMovementManager).gameObject.transform.position + ((Component)GM.CurrentMovementManager).gameObject.transform.forward * 0.5f, new Quaternion(0f, GM.CurrentMovementManager.Head.rotation.y + 180f, 0f, 1f));
					Logger.LogMessage((object)"FireArm Phobia Deployed.");
				}
			}
			else if (!SpawnTheReflect && (Object)(object)Reflect != (Object)null)
			{
				Object.Destroy((Object)(object)Reflect.gameObject);
			}
		}
	}
}
namespace JerryEffect
{
	[ExecuteInEditMode]
	public class VRFrostedGlassEffect : MonoBehaviour
	{
		public Shader blurShader;

		[Range(0f, 25f)]
		public float blurStrength = 0f;

		[Range(0f, 4f)]
		public int iterations = 2;

		[Tooltip("遮罩纹理:白色=全模糊,黑色=不模糊,灰色=半透模糊")]
		public Texture2D maskTexture;

		[Range(0f, 5f)]
		public float maskPower = 0f;

		public ShaderApplier SA;

		private Material _material;

		private Material material
		{
			get
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				if ((Object)(object)_material == (Object)null)
				{
					_material = new Material(blurShader);
					((Object)_material).hideFlags = (HideFlags)61;
				}
				return _material;
			}
		}

		private void OnRenderImage(RenderTexture src, RenderTexture dst)
		{
			//IL_00bb: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_012d: 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)
			if ((Object)(object)material == (Object)null || (Object)(object)blurShader == (Object)null)
			{
				Graphics.Blit((Texture)(object)src, dst);
				return;
			}
			material.SetFloat("_BlurStrength", blurStrength);
			material.SetFloat("_MaskPower", maskPower);
			if ((Object)(object)maskTexture == (Object)null)
			{
				material.EnableKeyword("USE_RADIAL_MASK");
			}
			else
			{
				material.SetTexture("_MaskTex", (Texture)(object)maskTexture);
				material.DisableKeyword("USE_RADIAL_MASK");
			}
			int width = ((Texture)src).width;
			int height = ((Texture)src).height;
			VRTextureUsage vrUsage = src.vrUsage;
			RenderTexture val = RenderTexture.GetTemporary(width, height, 0, src.format, (RenderTextureReadWrite)0, 1, vrUsage);
			RenderTexture val2 = RenderTexture.GetTemporary(width, height, 0, src.format, (RenderTextureReadWrite)0, 1, vrUsage);
			material.SetVector("_Direction", Vector4.op_Implicit(new Vector2(1f, 0f)));
			Graphics.Blit((Texture)(object)src, val, material, 0);
			material.SetVector("_Direction", Vector4.op_Implicit(new Vector2(0f, 1f)));
			for (int i = 0; i < iterations; i++)
			{
				Graphics.Blit((Texture)(object)val, val2, material, 0);
				RenderTexture val3 = val;
				val = val2;
				val2 = val3;
			}
			material.SetTexture("_BlurredTex", (Texture)(object)val);
			Graphics.Blit((Texture)(object)src, dst, material, 1);
			RenderTexture.ReleaseTemporary(val);
			RenderTexture.ReleaseTemporary(val2);
		}

		private void Update()
		{
			if ((Object)(object)SA == (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)_material != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)_material);
			}
		}
	}
}
namespace JerryAr.FireArmPhobia
{
	[BepInPlugin("JerryAr.FireArmPhobia", "FireArmPhobia", "0.0.1")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class FireArmPhobiaPlugin : 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.FireArmPhobia");
			OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.FireArmPhobia", "", "", "firearmphobia", "");
		}
	}
}
public class SnapToPoint : MonoBehaviour
{
	public GameObject Obj;

	public GameObject Targ;

	private void Start()
	{
	}

	private void Update()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		Obj.transform.position = Targ.transform.position;
		Obj.transform.rotation = Targ.transform.rotation;
	}
}