Decompiled source of DoubleTapPierce v0.1.2

DoubleTapPierce.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using EntityStates.Commando.CommandoWeapon;
using HG.Reflection;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[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 Prototype
{
	[BepInPlugin("prototype.commando.pierce", "DoubleTapPierce", "0.1.2")]
	public class DoubleTapPierce : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass3_0
		{
			public BulletAttack attack;

			internal void <Transpile>b__2(BulletAttack _, ref BulletHit _, DamageInfo _)
			{
				BulletAttack obj = attack;
				obj.procCoefficient /= 2f;
				<Transpile>g__roll|3_0(attack);
			}
		}

		[CompilerGenerated]
		private sealed class <Transpile>d__3 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> IL;

			public IEnumerable<CodeInstruction> <>3__IL;

			private MethodInfo <method>5__2;

			private IEnumerator<CodeInstruction> <>7__wrap2;

			private CodeInstruction <instruction>5__4;

			CodeInstruction IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Transpile>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 2u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<method>5__2 = null;
				<>7__wrap2 = null;
				<instruction>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<method>5__2 = typeof(BulletAttack).GetMethod("Fire", Array.Empty<Type>());
						<>7__wrap2 = IL.GetEnumerator();
						<>1__state = -3;
						goto IL_0116;
					case 1:
						<>1__state = -3;
						<>2__current = Transpilers.EmitDelegate<Action<BulletAttack>>((Action<BulletAttack>)delegate(BulletAttack attack)
						{
							//IL_003b: Unknown result type (might be due to invalid IL or missing references)
							//IL_0045: Expected O, but got Unknown
							//IL_0045: Unknown result type (might be due to invalid IL or missing references)
							//IL_004f: Expected O, but got Unknown
							<>c__DisplayClass3_0 CS$<>8__locals0 = new <>c__DisplayClass3_0();
							CS$<>8__locals0.attack = attack;
							CS$<>8__locals0.attack.radius = 1f;
							<Transpile>g__roll|3_0(CS$<>8__locals0.attack);
							BulletAttack attack2 = CS$<>8__locals0.attack;
							attack2.modifyOutgoingDamageCallback = (ModifyOutgoingDamageCallback)Delegate.Combine((Delegate?)(object)attack2.modifyOutgoingDamageCallback, (Delegate?)(ModifyOutgoingDamageCallback)delegate
							{
								BulletAttack attack3 = CS$<>8__locals0.attack;
								attack3.procCoefficient /= 2f;
								<Transpile>g__roll|3_0(CS$<>8__locals0.attack);
							});
						});
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -3;
						goto IL_00f0;
					case 3:
						{
							<>1__state = -3;
							<instruction>5__4 = null;
							goto IL_0116;
						}
						IL_00f0:
						<>2__current = <instruction>5__4;
						<>1__state = 3;
						return true;
						IL_0116:
						if (<>7__wrap2.MoveNext())
						{
							<instruction>5__4 = <>7__wrap2.Current;
							if (CodeInstructionExtensions.Calls(<instruction>5__4, <method>5__2))
							{
								<>2__current = new CodeInstruction(OpCodes.Dup, (object)null);
								<>1__state = 1;
								return true;
							}
							goto IL_00f0;
						}
						<>m__Finally1();
						<>7__wrap2 = null;
						return false;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap2 != null)
				{
					<>7__wrap2.Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<Transpile>d__3 <Transpile>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Transpile>d__ = this;
				}
				else
				{
					<Transpile>d__ = new <Transpile>d__3(0);
				}
				<Transpile>d__.IL = <>3__IL;
				return <Transpile>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		public const string version = "0.1.2";

		public const string identifier = "prototype.commando.pierce";

		protected void Awake()
		{
			Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
		}

		[IteratorStateMachine(typeof(<Transpile>d__3))]
		[HarmonyPatch(typeof(FirePistol2), "FireBullet")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> IL)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Transpile>d__3(-2)
			{
				<>3__IL = IL
			};
		}

		[SystemInitializer(new Type[] { typeof(BodyCatalog) })]
		private static void Initialize()
		{
			get("CommandoBody").levelDamage = get("ToolbotBody").levelDamage;
			static CharacterBody get(string identifier)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return BodyCatalog.GetBodyPrefabBodyComponent(BodyCatalog.FindBodyIndex(identifier));
			}
		}

		[CompilerGenerated]
		internal static void <Transpile>g__roll|3_0(BulletAttack bullet)
		{
			//IL_001f: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			bullet.stopperMask = (Util.CheckRoll(50f, 0f, (CharacterMaster)null) ? ((LayerIndex)(ref LayerIndex.world)).mask : BulletAttack.defaultStopperMask);
		}
	}
}