Decompiled source of Fireproof v1.0.2

BepInEx\plugins\Fireproof.dll

Decompiled 2 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 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("Fireproof")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+05c19454b525338b3923466c254d54b08e7a8b24")]
[assembly: AssemblyProduct("Fireproof")]
[assembly: AssemblyTitle("Fireproof")]
[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 Fireproof
{
	[BepInPlugin("matthb1.fireproof", "Fireproof", "1.0.2")]
	public class Fireproof : BaseUnityPlugin
	{
		public const string GUID = "matthb1.fireproof";

		public const string NAME = "Fireproof";

		public const string VERSION = "1.0.2";

		private void Awake()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Fireproof 1.0.2 loaded - blocking fire, lava, and Burning on local player.");
			new Harmony("matthb1.fireproof").PatchAll();
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return;
			}
			SEMan sEMan = ((Character)localPlayer).GetSEMan();
			if (sEMan != null)
			{
				if (sEMan.HaveStatusEffect(SEMan.s_statusEffectBurning))
				{
					sEMan.RemoveStatusEffect(SEMan.s_statusEffectBurning, true);
				}
				if (sEMan.HaveStatusEffect(SEMan.s_statusEffectSmoked))
				{
					sEMan.RemoveStatusEffect(SEMan.s_statusEffectSmoked, true);
				}
			}
		}
	}
	[HarmonyPatch(typeof(SEMan), "Internal_AddStatusEffect")]
	internal static class BlockBurningPatch
	{
		private static bool Prefix(SEMan __instance, int nameHash)
		{
			if (nameHash != SEMan.s_statusEffectBurning && nameHash != SEMan.s_statusEffectSmoked)
			{
				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;
		}
	}
	[HarmonyPatch(typeof(Character), "ApplyDamage")]
	internal static class BlockFireApplyDamagePatch
	{
		private static bool Prefix(Character __instance, HitData hit)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || (Object)(object)__instance != (Object)(object)localPlayer || hit == null)
			{
				return true;
			}
			if ((int)hit.m_hitType == 5 || (int)hit.m_hitType == 20 || (int)hit.m_hitType == 9 || (int)hit.m_hitType == 21)
			{
				return false;
			}
			if ((Object)(object)hit.GetAttacker() == (Object)null && hit.m_damage.m_fire > 0f)
			{
				return false;
			}
			hit.m_damage.m_fire = 0f;
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "AddFireDamage")]
	internal static class BlockAddFireDamagePatch
	{
		private static bool Prefix(Character __instance)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || (Object)(object)__instance != (Object)(object)localPlayer)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Aoe), "OnHit")]
	internal static class BlockFireAoePatch
	{
		private static bool Prefix(Aoe __instance, Collider collider)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)collider == (Object)null)
			{
				return true;
			}
			if (__instance.m_damage.m_fire <= 0f)
			{
				return true;
			}
			GameObject val = Projectile.FindHitObject(collider);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return true;
			}
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer) && (Object)(object)(val.GetComponent<Character>() ?? val.GetComponentInParent<Character>()) == (Object)(object)localPlayer)
			{
				return false;
			}
			if (__instance.m_damage.m_chop > 0f && (Object)(object)val.GetComponent<WearNTear>() != (Object)null && (Object)(object)((Component)__instance).GetComponentInParent<Fireplace>() != (Object)null)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateLava")]
	internal static class BlockLavaUpdatePatch
	{
		private static bool Prefix(Character __instance, ref float ___m_lavaHeatLevel, ref float ___m_lavaProximity, ref float ___m_lavaHeightFactor)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || (Object)(object)__instance != (Object)(object)localPlayer)
			{
				return true;
			}
			___m_lavaHeatLevel = 0f;
			___m_lavaProximity = 0f;
			___m_lavaHeightFactor = 0f;
			return false;
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateAshlandsWater")]
	internal static class BlockAshlandsWaterPatch
	{
		private static bool Prefix(Character __instance)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || (Object)(object)__instance != (Object)(object)localPlayer)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateHeatDamage")]
	internal static class BlockHeatDamagePatch
	{
		private static bool Prefix(Character __instance)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || (Object)(object)__instance != (Object)(object)localPlayer)
			{
				return true;
			}
			return false;
		}
	}
}