Decompiled source of NoPenaltyReimagined v1.1.1

BepInEx/plugins/NoPenaltyReimagined.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks.Data;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoPenaltyReimagined")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Committing tax fraud in Lethal Company")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+a14045120348b2d421366ca8f9906b3c9f508989")]
[assembly: AssemblyProduct("NoPenaltyReimagined")]
[assembly: AssemblyTitle("NoPenaltyReimagined")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 NoPenaltyReimagined
{
	[HarmonyPatch]
	internal static class NoPenaltyPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void OnGameEnter(StartOfRound __instance)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Plugin.NoPenaltyEnabled = false;
			bool flag = ((NetworkBehaviour)__instance).NetworkManager.IsHost || ((NetworkBehaviour)__instance).NetworkManager.IsServer;
			Lobby? currentLobby = GameNetworkManager.Instance.currentLobby;
			if (currentLobby.HasValue)
			{
				Lobby valueOrDefault = currentLobby.GetValueOrDefault();
				if (flag)
				{
					Plugin.NoPenaltyEnabled = true;
					((Lobby)(ref valueOrDefault)).SetData("NoPenaltyPresent", "true");
				}
				else if (!(((Lobby)(ref valueOrDefault)).GetData("NoPenaltyPresent") != "true"))
				{
					Plugin.NoPenaltyEnabled = true;
				}
			}
			else
			{
				Plugin.NoPenaltyEnabled = flag;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> RemovePenalty(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: 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_0037: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			CodeMatcher obj = new CodeMatcher(instructions, generator).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(HUDManager), "ApplyPenalty", (Type[])null, (Type[])null), (string)null)
			}).Advance(-10);
			object operand = obj.Operand;
			return obj.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Plugin), "NoPenaltyEnabled")),
				new CodeInstruction(OpCodes.Brtrue, operand)
			}).InstructionEnumeration();
		}

		[HarmonyPatch(typeof(StartOfRound), "AllPlayersHaveRevivedClientRpc")]
		[HarmonyPostfix]
		private static void SyncTerminalCredits(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).NetworkManager.IsHost || ((NetworkBehaviour)__instance).NetworkManager.IsServer)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship);
			}
		}
	}
	[BepInPlugin("io.daxcess.nopenaltyreimagined", "NoPenaltyReimaged", "1.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "io.daxcess.nopenaltyreimagined";

		private const string PLUGIN_NAME = "NoPenaltyReimaged";

		private const string PLUGIN_VERSION = "1.1.1";

		public static bool NoPenaltyEnabled { get; internal set; }

		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Let's commit some tax fraud!");
		}
	}
}