Decompiled source of Radiation Leak v1.0.1

RadiationLeak.dll

Decompiled 3 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RadiationLeak")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationLeak")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6fcf72b2-ea07-4479-80e7-1e60efce0a52")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RadiationLeak
{
	[BepInPlugin("com.actus.lethalcompany.radiationLeak", "Radiation Leak", "1.0.1")]
	public class RadiationLeakBase : BaseUnityPlugin
	{
		private const string modGUID = "com.actus.lethalcompany.radiationLeak";

		private const string modName = "Radiation Leak";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("com.actus.lethalcompany.radiationLeak");

		internal static RadiationLeakBase Instance;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
		}
	}
}
namespace RadiationLeak.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal class RadiationLeakPatch
	{
		private static float damageCoolDown = 20f;

		private static LungProp apparatus;

		[HarmonyPostfix]
		public static void DamagePlayerWhenHoldingApparatus(ref PlayerControllerB __instance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			bool flag = __instance.currentlyHeldObjectServer is LungProp;
			apparatus = (LungProp)((!flag) ? ((object)apparatus) : ((object)(LungProp)__instance.currentlyHeldObjectServer));
			if ((Object)(object)apparatus != (Object)null && flag)
			{
				if (damageCoolDown > 0f)
				{
					damageCoolDown -= Time.deltaTime;
				}
				else
				{
					if (__instance.health <= 20)
					{
						__instance.DamagePlayer(100, true, true, (CauseOfDeath)3, 0, false, default(Vector3));
					}
					else
					{
						__instance.DamagePlayer(10, true, true, (CauseOfDeath)3, 0, false, default(Vector3));
					}
					damageCoolDown = 20f;
				}
			}
			if ((Object)(object)apparatus != (Object)null && !flag && ((GrabbableObject)apparatus).hasHitGround && !((GrabbableObject)apparatus).isInShipRoom)
			{
				if (Random.Range(1, 101) <= 5)
				{
					Landmine.SpawnExplosion(((GrabbableObject)apparatus).GetItemFloorPosition(default(Vector3)), true, 1f, 10f, 50, 0f, (GameObject)null, false);
					DestroyApparatusObject();
				}
				apparatus = null;
			}
		}

		private static void DestroyApparatusObject()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			MeshRenderer component = ((Component)apparatus).GetComponent<MeshRenderer>();
			Collider component2 = ((Component)apparatus).GetComponent<Collider>();
			MeshRenderer[] componentsInChildren = ((Component)apparatus).GetComponentsInChildren<MeshRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				((Renderer)component).enabled = false;
			}
			if ((Object)(object)component2 != (Object)null)
			{
				component2.enabled = false;
			}
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val in array)
			{
				((Renderer)val).enabled = false;
			}
			Object.Destroy((Object)apparatus);
		}
	}
}