Decompiled source of TrueDeathPealty v1.0.0

TrueDeathPenalty.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("TrueDeathPenalty")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrueDeathPenalty")]
[assembly: AssemblyTitle("TrueDeathPenalty")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 TrueDeathPenalty
{
	[BepInPlugin("Lexderi.TrueDeathPenalty", "True Death Penalty", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string pluginGuid = "Lexderi.TrueDeathPenalty";

		private const string pluginName = "True Death Penalty";

		private const string pluginVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Lexderi.TrueDeathPenalty");

		public static ManualLogSource LogSource => ((BaseUnityPlugin)Instance).Logger;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Lexderi.TrueDeathPenalty is loaded!");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"There should not be two instances of mod Lexderi.TrueDeathPenalty");
			}
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TrueDeathPenalty";

		public const string PLUGIN_NAME = "TrueDeathPenalty";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TrueDeathPenalty.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDManagerPatch
	{
		private static int prevGroupCredits;

		[HarmonyPatch("ApplyPenalty")]
		[HarmonyPrefix]
		public static void SavePreviousGroupCredits(Terminal ___terminalScript)
		{
			prevGroupCredits = ___terminalScript.groupCredits;
		}

		[HarmonyPatch("ApplyPenalty")]
		[HarmonyPostfix]
		public static void AdjustPenaltyTextPatch(int playersDead, int bodiesInsured, EndOfGameStatUIElements ___statsUIElements, Terminal ___terminalScript)
		{
			int num = (int)Math.Round((1f - (float)___terminalScript.groupCredits / (float)prevGroupCredits) * 100f);
			((TMP_Text)___statsUIElements.penaltyAddition).text = $"{playersDead} casualties: -{num}%\n({bodiesInsured} bodies recovered)";
		}
	}
}