Decompiled source of AutoRemoveDeathPin v1.1.2

AutoRemoveDeathPin.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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: AssemblyCompany("AutoRemoveDeathPin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+af9a28036f67f23f80d5c45d4cf5f1fa32e30e21")]
[assembly: AssemblyProduct("AutoRemoveDeathPin")]
[assembly: AssemblyTitle("AutoRemoveDeathPin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 AutoRemoveDeathPin
{
	[BepInPlugin("yudi7ll.autoremovedeathpin", "AutoRemoveDeathPin", "1.1.2")]
	public class AutoRemoveDeathPin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(TombStone), "GiveBoost")]
		private class Tombstone_GiveBoost_Patch
		{
			private static void Postfix(TombStone __instance)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Minimap.instance.RemovePin(((Component)__instance).transform.position, 1.5f);
			}
		}

		[HarmonyPatch(typeof(Player), "OnDeath")]
		private class Player_OnDeath_Patch
		{
			private static void Prefix(Player __instance, ref bool __state)
			{
				if (((Humanoid)__instance).m_inventory.NrOfItems() == 0)
				{
					__state = true;
				}
			}

			private static void Postfix(Player __instance, ref bool __state)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Invalid comparison between Unknown and I4
				if (!__state)
				{
					return;
				}
				List<PinData> pins = Minimap.instance.m_pins;
				for (int num = pins.Count - 1; num >= 0; num--)
				{
					PinData val = pins[num];
					if ((int)val.m_type == 4)
					{
						Minimap.instance.RemovePin(val);
						__state = false;
						break;
					}
				}
			}
		}

		private const string Guid = "yudi7ll.autoremovedeathpin";

		private const string Name = "AutoRemoveDeathPin";

		private const string Version = "1.1.2";

		private static ManualLogSource logger = Logger.CreateLogSource("AutoRemoveDeathPin");

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				logger.LogInfo((object)"Dedicated server detected. Mod disabled.");
			}
			else
			{
				_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "yudi7ll.autoremovedeathpin");
			}
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}