Decompiled source of Toggle Penalty v1.0.0

LethalMod1.dll

Decompiled 5 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalMod1.Patches;
using TMPro;
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("LethalMod1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalMod1")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b8c61cc3-bc3d-42f0-8763-8e68b5ad453a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalMod1
{
	[BepInPlugin("eemster.mod1", "mod1", "1.0.0.0")]
	public class LethalModBase : BaseUnityPlugin
	{
		private const string modGUID = "eemster.mod1";

		private const string modName = "mod1";

		private const string modVersion = "1.0.0.0";

		public bool penaltyDisabled = false;

		private readonly Harmony harmony = new Harmony("eemster.mod1");

		public static LethalModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("eemster.mod1");
			mls.LogInfo((object)"PENALTY TOGGLE MOD HAS INITIALIZED");
			harmony.PatchAll(typeof(LethalModBase));
			harmony.PatchAll(typeof(HUDManagerPatch));
		}

		private void Update()
		{
			if (UnityInput.Current.GetKeyDown((KeyCode)282))
			{
				if (!penaltyDisabled)
				{
					penaltyDisabled = true;
					Instance.mls.LogInfo((object)"No Penalty");
					string item = "<color=#FF00FF>PenaltyToggle</color>: <color=#FFFF00>Penalty Disabled</color>";
					HUDManager.Instance.ChatMessageHistory.Add(item);
				}
				else
				{
					penaltyDisabled = false;
					Instance.mls.LogInfo((object)"Yes Penalty");
					string item2 = "<color=#FF00FF>PenaltyToggle</color>: <color=#FFFF00>Penalty Enabled</color>";
					HUDManager.Instance.ChatMessageHistory.Add(item2);
				}
				UpdateChatText();
			}
		}

		private static void UpdateChatText()
		{
			List<string> chatMessageHistory = HUDManager.Instance.ChatMessageHistory;
			if (chatMessageHistory.Count() > 3)
			{
				HUDManager.Instance.ChatMessageHistory.Clear();
			}
			((TMP_Text)HUDManager.Instance.chatText).text = string.Join("\n", chatMessageHistory);
		}
	}
}
namespace LethalMod1.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDManagerPatch
	{
		private bool penaltyDisabled = false;

		[HarmonyPatch("ApplyPenalty")]
		[HarmonyPrefix]
		private static void noPenaltyPatch(ref int playersDead, ref int bodiesInsured)
		{
			if (LethalModBase.Instance.penaltyDisabled)
			{
				playersDead = 0;
				bodiesInsured = 0;
				LethalModBase.Instance.mls.LogInfo((object)"No Penalty");
			}
		}
	}
}