Decompiled source of RNGMines v1.0.3

BepInEx/Plugins/RNGMines.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using RNGMines.Patches;
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("RNGMines")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RNGMines")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("511f161e-8140-42f2-843d-030217a082d5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RNGMines
{
	[BepInPlugin("f0ur3y3s.RNGMine", "RNGMine", "1.0.0")]
	public class RNGMineBase : BaseUnityPlugin
	{
		private const string modGUID = "f0ur3y3s.RNGMine";

		private const string modName = "RNGMine";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("f0ur3y3s.RNGMine");

		private static RNGMineBase Instance;

		private static ManualLogSource logger;

		internal static ManualLogSource GetLogger()
		{
			return logger;
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("RNGMine");
			string text = "\r\n                                              \r\n                                              \r\n                                ██    ██      \r\n                    ██████      ██  ██        \r\n                  ██      ██                  \r\n                ██          ████░░    ████    \r\n                ██                            \r\n              ██████            ██  ██        \r\n              ██████            ██    ██      \r\n          ██████████████                      \r\n        ██████░░░░░░░░▓▓██                    \r\n      ██████░░░░░░░░  ▓▓▓▓██                  \r\n      ██████▓▓▓▓▓▓▓▓    ▓▓██                  \r\n    ████████▓▓▓▓▓▓▓▓▓▓  ▓▓▓▓██                \r\n    ████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██                \r\n    ████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██                \r\n      ████████▓▓▓▓▓▓▓▓▓▓▓▓██                  \r\n      ████████████▓▓▓▓▓▓████                  \r\n        ██████████████████                    \r\n          ██████████████                      \r\n              ██████                          \r\n";
			logger.LogWarning((object)text);
			logger.LogInfo((object)" RNGMine Loaded!");
			logger.LogInfo((object)"Patching RNGMineBase");
			harmony.PatchAll(typeof(RNGMineBase));
			logger.LogInfo((object)"Patching PlayerItemSlots");
			harmony.PatchAll(typeof(MinePatch));
		}
	}
}
namespace RNGMines.Patches
{
	internal class MinePatch
	{
		private static bool HasLineOfSight(Vector3 source, Vector3 target, LayerMask obstructionLayer, int distanceRange = 30)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target - source;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > (float)distanceRange)
			{
				return false;
			}
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(source, ((Vector3)(ref val)).normalized);
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, magnitude, LayerMask.op_Implicit(obstructionLayer)))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Landmine), "Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(Landmine __instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB componentInChildren = ((Component)GameNetworkManager.Instance.localPlayerController).GetComponentInChildren<PlayerControllerB>();
			if (!((Object)(object)componentInChildren == (Object)null) && !__instance.hasExploded && HasLineOfSight(((Component)componentInChildren).transform.position, ((Component)__instance).transform.position, LayerMask.op_Implicit(StartOfRound.Instance.collidersAndRoomMaskAndDefault), 15))
			{
				int num = Random.Range(0, 10000);
				if (num == 666)
				{
					RNGMineBase.GetLogger().LogInfo((object)"RNJesus has forsaken you, triggering mine");
					((object)__instance).GetType().GetMethod("TriggerMineOnLocalClientByExiting", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null);
				}
			}
		}
	}
}