Decompiled source of ClearStovepipeWithMag v0.0.2

CatalpaBow.ClearStovepipeWithMag.dll

Decompiled 2 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.Logging;
using ClearStovepipeWithMag.src.Patches;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Stovepipe;
using Stovepipe.StovepipePatches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("CatalpaBow")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Clear stovepipe with magazine")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+670888cc1481a53f3c13e08613e4916e9f9baf0d")]
[assembly: AssemblyProduct("CatalpaBow.ClearStovepipeWithMag")]
[assembly: AssemblyTitle("ClearStovepipeWithMag")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.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 ClearStovepipeWithMag.src.Patches
{
	public class StovepipeBasePatches
	{
		[HarmonyPatch(typeof(StovepipeBase), "StartStovepipe")]
		[HarmonyPostfix]
		private static void AddClearncerComponent(StovepipeData data)
		{
			GameObject gameObject = ((Component)((Component)data.ejectedRound).transform.parent).gameObject;
			gameObject.AddComponent<ClearStovepipeWithMag>().Intialize(data, gameObject.GetComponent<Rigidbody>());
		}
	}
	public class ClearStovepipeWithMag : MonoBehaviour
	{
		public StovepipeData data;

		public Rigidbody wepRb;

		public void Intialize(StovepipeData _data, Rigidbody _wepRb)
		{
			data = _data;
			wepRb = _wepRb;
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			ContactPoint[] contacts = collision.contacts;
			int num = 0;
			if (num < contacts.Length)
			{
				ContactPoint val = contacts[num];
				bool num2 = Object.op_Implicit((Object)(object)((Component)((ContactPoint)(ref val)).thisCollider).GetComponentInParent<FVRFireArmRound>());
				bool flag = Object.op_Implicit((Object)(object)((Component)((ContactPoint)(ref val)).otherCollider.attachedRigidbody).GetComponent<FVRFireArmMagazine>());
				if (!(num2 && flag))
				{
					return;
				}
				StovepipeBase.UnStovepipe(data, true, wepRb);
			}
			Object.Destroy((Object)(object)this);
		}
	}
}
namespace CatalpaBow
{
	[BepInPlugin("CatalpaBow.ClearStovePipeWithMag", "ClearStovepipeWithMag", "0.0.2")]
	[BepInProcess("h3vr.exe")]
	public class ClearStovepipeWithMag : BaseUnityPlugin
	{
		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(StovepipeBasePatches), (string)null);
		}
	}
}