Decompiled source of EquipmentInWater v0.2.0

EquipmentInWater.dll

Decompiled 5 days ago
using System;
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;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("EquipmentInWater")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Use your equipment while in the water.")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+2dbba3538022f74aefc2ae6f6251a1078aac7969")]
[assembly: AssemblyProduct("EquipmentInWater")]
[assembly: AssemblyTitle("EquipmentInWater")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 EquipmentInWater
{
	[BepInPlugin("javidahmed64592.equipmentinwater", "Equipment In Water", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class EquipmentInWaterPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "javidahmed64592.equipmentinwater";

		public const string PluginName = "Equipment In Water";

		public const string PluginVersion = "0.2.0";

		private Harmony _harmony;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("javidahmed64592.equipmentinwater");
			_harmony.PatchAll();
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class SwimmingCheck
	{
		private static readonly MethodInfo IsSwimming = AccessTools.Method(typeof(Character), "IsSwimming", (Type[])null, (Type[])null);

		public static IEnumerable<CodeInstruction> RemoveCheck(IEnumerable<CodeInstruction> instructions, string method)
		{
			int replaced = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, IsSwimming))
				{
					replaced++;
					yield return new CodeInstruction(OpCodes.Pop, (object)null)
					{
						labels = instruction.labels
					};
					yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
				}
				else
				{
					yield return instruction;
				}
			}
			if (replaced == 0)
			{
				EquipmentInWaterPlugin.Log.LogWarning((object)(method + " has no swimming check to remove: the game may have changed, so this part of the mod does nothing."));
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "UpdateEquipment")]
	internal static class UpdateEquipmentPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return SwimmingCheck.RemoveCheck(instructions, "Humanoid.UpdateEquipment");
		}
	}
	[HarmonyPatch(typeof(Humanoid), "EquipItem")]
	internal static class EquipItemPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return SwimmingCheck.RemoveCheck(instructions, "Humanoid.EquipItem");
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	internal static class PlayerUpdatePatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return SwimmingCheck.RemoveCheck(instructions, "Player.Update");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}