Decompiled source of HoldPlatingRework v1.0.0

HoldPlatingPatch.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HoldingPlatePatch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HoldingPlatePatch")]
[assembly: AssemblyTitle("HoldingPlatePatch")]
[assembly: AssemblyVersion("1.0.0.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 HoldPlatingPatch
{
	[MycoMod(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("myco.minicannon.holdplating", "MiniCannon Hold Plating", "1.0.0")]
	public class HoldPlatingPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("myco.minicannon.holdplating").PatchAll();
		}
	}
	[HarmonyPatch(typeof(MiniCannon))]
	public static class MiniCannonHoldPlatingPatch
	{
		private static readonly FieldInfo playerField = typeof(Gun).GetField("player", BindingFlags.Instance | BindingFlags.NonPublic);

		private static bool IsHoldingFire()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			PlayerActions player = PlayerInput.Controls.Player;
			return ((PlayerActions)(ref player)).Fire.IsPressed();
		}

		[HarmonyPatch("OnActiveUpdate")]
		[HarmonyPostfix]
		private static void OnActiveUpdate_Postfix(MiniCannon __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if (!((Gun)__instance).Active || playerField == null)
			{
				return;
			}
			Player val = (Player)playerField.GetValue(__instance);
			if (!((Object)(object)val == (Object)null))
			{
				if (IsHoldingFire() && __instance.MiniCannonData.firingDamageResist > 0f)
				{
					val.UpdateStackDisplay((object)typeof(UpgradeProperty_MiniCannon_DamageResist), TextBlocks.GetString("FiringResist", 0), UpgradeProperty_MiniCannon_DamageResist.Icon, 1, 0.25f);
				}
				else
				{
					val.RemoveStackDisplay((object)typeof(UpgradeProperty_MiniCannon_DamageResist));
				}
			}
		}

		[HarmonyPatch("OnBeforeTakeDamage")]
		[HarmonyPrefix]
		private static void OnBeforeTakeDamage_Prefix(MiniCannon __instance, ref DamageData data, ref IDamageSource source)
		{
			if (!((Object)(object)__instance == (Object)null) && IsHoldingFire())
			{
				float firingDamageResist = __instance.MiniCannonData.firingDamageResist;
				if (!(firingDamageResist <= 0f))
				{
					data.damage *= firingDamageResist;
					data.effectAmount *= firingDamageResist;
				}
			}
		}
	}
}