Decompiled source of NoPoison v1.0.1

BepInEx\plugins\NoPoison.dll

Decompiled 2 weeks 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("NoPoison")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3e432ac1e23373713e2721a783cc0eff5d77eba6")]
[assembly: AssemblyProduct("NoPoison")]
[assembly: AssemblyTitle("NoPoison")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 NoPoison
{
	[BepInPlugin("matthb1.nopoison", "NoPoison", "1.0.1")]
	public class NoPoison : BaseUnityPlugin
	{
		public const string GUID = "matthb1.nopoison";

		public const string NAME = "NoPoison";

		public const string VERSION = "1.0.1";

		private void Awake()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"NoPoison 1.0.1 loaded — blocking Poison on local player.");
			new Harmony("matthb1.nopoison").PatchAll();
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer))
			{
				SEMan sEMan = ((Character)localPlayer).GetSEMan();
				if (sEMan != null && sEMan.HaveStatusEffect(SEMan.s_statusEffectPoison))
				{
					sEMan.RemoveStatusEffect(SEMan.s_statusEffectPoison, true);
				}
			}
		}
	}
	[HarmonyPatch(typeof(SEMan), "Internal_AddStatusEffect")]
	internal static class BlockPoisonPatch
	{
		private static bool Prefix(SEMan __instance, int nameHash)
		{
			if (nameHash != SEMan.s_statusEffectPoison)
			{
				return true;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return true;
			}
			if (__instance != ((Character)localPlayer).GetSEMan())
			{
				return true;
			}
			return false;
		}
	}
}