Decompiled source of LCDumMod v0.0.4

LCDumMod.dll

Decompiled 11 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("LCDumMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LCDumMod")]
[assembly: AssemblyTitle("LCDumMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCDumMod
{
	public class DumConfig
	{
		public static List<CauseOfDeath> dumWaysToDie = new List<CauseOfDeath>
		{
			(CauseOfDeath)1,
			(CauseOfDeath)9,
			(CauseOfDeath)2,
			(CauseOfDeath)11,
			(CauseOfDeath)5
		};
	}
	internal class DumLogger
	{
		internal static ManualLogSource logSource;

		public static void Initialize()
		{
			logSource = Logger.CreateLogSource("Syny.LCDumMod");
		}

		public static void Log(object message)
		{
			logSource.LogInfo(message);
		}

		public static void LogError(object message)
		{
			logSource.LogError(message);
		}

		public static void LogWarning(object message)
		{
			logSource.LogWarning(message);
		}
	}
	internal class DumMessageService
	{
		public static void SendDeathMessage(string playerName, CauseOfDeath causeOfDeath, string additionalInfo = "")
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected I4, but got Unknown
			DumLogger.Initialize();
			string text = "";
			switch (causeOfDeath - 1)
			{
			case 0:
				text = " got bonked.";
				break;
			case 8:
				text = " wanted to swim but forgot their floatie.";
				break;
			case 1:
				text = " has fallen and can't get back up.";
				break;
			case 10:
				text = " died looking for honey. That's gotta sting.";
				break;
			case 4:
				text = " disappeared into a puddle of mud, never to be seen again.";
				break;
			case 2:
				if (additionalInfo != null)
				{
					if (additionalInfo == "lightning")
					{
						text = " got smited by Zeus.";
					}
					else if (additionalInfo == "mine")
					{
						text = " should have brought their mine-detector.";
					}
				}
				break;
			case 6:
				if (additionalInfo != null)
				{
					if (additionalInfo == "turret")
					{
						text = " got riddled with bullets.";
					}
					else if (additionalInfo == "friendlyfire")
					{
						text = "'s friend found a shotgun.";
					}
				}
				break;
			default:
				text = " has met their maker.";
				break;
			}
			HUDManager.Instance.DisplayTip("DUMMY ALERT!", playerName + text, true, false, "LC_DeathInfo");
		}
	}
	internal class PluginInfo
	{
		public const string PLUGIN_GUID = "Syny.LCDumMod";

		public const string PLUGIN_NAME = "LCDumMod";

		public const string PLUGIN_VERSION = "0.0.4";
	}
	[BepInPlugin("Syny.LCDumMod", "LCDumMod", "0.0.4")]
	public class DumModBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Syny.LCDumMod");

		private static bool initialized;

		private static DumModBase Instance { get; set; }

		private void Awake()
		{
			if (!initialized)
			{
				initialized = true;
				Instance = this;
				harmony.PatchAll();
				DumLogger.Initialize();
				DumLogger.Log("LCDum Mod loaded successfully!");
			}
		}
	}
}
namespace LCDumMod.Patches
{
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatcher
	{
		[HarmonyPostfix]
		[HarmonyPatch("SpawnExplosion")]
		private static void SpawnExplosion(Vector3 explosionPosition, float killRange = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(explosionPosition, 6f, 2621448, (QueryTriggerInteraction)2);
			PlayerControllerB val = null;
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if ((num > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) || ((Component)array[i]).gameObject.layer != 3)
				{
					continue;
				}
				val = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)val != (Object)null && num < killRange)
				{
					if (killRange == 2.4f)
					{
						DumMessageService.SendDeathMessage(val.playerUsername, (CauseOfDeath)3, "lightning");
					}
					else if (killRange == 5.7f)
					{
						DumMessageService.SendDeathMessage(val.playerUsername, (CauseOfDeath)3, "mine");
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatcher
	{
		public bool dumSticker = false;

		[HarmonyPostfix]
		[HarmonyPatch("KillPlayerClientRpc")]
		private static void KillPlayerClientRpc(PlayerControllerB __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (DumConfig.dumWaysToDie.Contains(__instance.causeOfDeath) && ((int)__instance.causeOfDeath != 5 || __instance.isSinking))
			{
				DumMessageService.SendDeathMessage(__instance.playerUsername, __instance.causeOfDeath);
			}
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class ShotgunItemPatcher
	{
		[HarmonyPostfix]
		[HarmonyPatch("ShootGun")]
		public static void ShootGun(ShotgunItem __instance)
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!((Object)(object)localPlayerController == (Object)null) && localPlayerController.isPlayerDead && !((GrabbableObject)__instance).isHeldByEnemy)
			{
				DumMessageService.SendDeathMessage(localPlayerController.playerUsername, (CauseOfDeath)7, "friendlyfire");
			}
		}
	}
	[HarmonyPatch]
	internal class StartOfRoundPatcher
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")]
		private static void ReviveDeadPlayers(StartOfRound __instance)
		{
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatcher
	{
		private static bool playerDeadLastFrame;

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		public static void Update(Turret __instance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			if ((Object)(object)__instance.CheckForPlayersInLineOfSight(3f, false) == (Object)(object)GameNetworkManager.Instance.localPlayerController && ((int)__instance.turretMode == 2 || (int)__instance.turretMode == 3) && GameNetworkManager.Instance.localPlayerController.isPlayerDead && !playerDeadLastFrame)
			{
				playerDeadLastFrame = true;
				DumMessageService.SendDeathMessage(GameNetworkManager.Instance.localPlayerController.playerUsername, (CauseOfDeath)7, "turret");
			}
		}
	}
}