Decompiled source of SkidPwner v1.0.1

SkidPwner.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalFix;
using Microsoft.CodeAnalysis;
using SkidPwner;
using Unity.Netcode;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SkidPwner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SkidPwner")]
[assembly: AssemblyTitle("SkidPwner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SkidPwner
{
	[BepInPlugin("dev.timmywastor.skidpwner", "SkidPwner", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "dev.timmywastor.skidpwner";

		public const string ModName = "SkidPwner";

		public const string ModVersion = "1.0.0";

		public static Harmony Harmony = new Harmony("dev.timmywastor.skidpwner");

		public static ManualLogSource LfLogger;

		public static string LfFolder;

		private void Awake()
		{
			LfFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			LfLogger = ((BaseUnityPlugin)this).Logger;
			SkidPwner.BasePatch();
		}
	}
	internal class SkidPwner
	{
		public static GameObject CurrentCanvas;

		public static void BasePatch()
		{
			Plugin.Harmony.PatchAll(typeof(Patches));
		}
	}
}
namespace LethalFix
{
	internal class Patches
	{
		[HarmonyPatch(typeof(ShipBuildModeManager), "PlaceShipObjectServerRpc")]
		[HarmonyPrefix]
		private static bool CheckBeforePlacing(ShipBuildModeManager __instance, Vector3 newPosition, Vector3 newRotation, NetworkObjectReference objectRef, int playerWhoMoved)
		{
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(ShipBuildModeManager), "StoreObjectServerRpc")]
		[HarmonyPrefix]
		private static bool CheckBeforeStoring(ShipBuildModeManager __instance, NetworkObjectReference objectRef, int playerWhoStored)
		{
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(StartOfRound), "ChangeLevelServerRpc")]
		[HarmonyPrefix]
		private static bool CheckBeforeChangingLevel(StartOfRound __instance, int levelID, int newGroupCreditsAmount)
		{
			if (levelID > StartOfRound.Instance.levels.Length || levelID < 0 || levelID == 11)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PlaceObjectServerRpc")]
		[HarmonyPrefix]
		private static bool Place()
		{
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Terminal), "BuyItemsServerRpc")]
		[HarmonyPrefix]
		private static bool BuyItems()
		{
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Terminal), "SyncGroupCreditsServerRpc")]
		[HarmonyPrefix]
		private static bool SyncCredits()
		{
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(StartOfRound), "BuyShipUnlockableServerRpc")]
		[HarmonyPrefix]
		private static bool BuyUnlockable()
		{
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(StartOfRound), "__rpc_handler_1089447320")]
		[HarmonyPrefix]
		private static bool NoStartShip(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			Plugin.LfLogger.LogInfo((object)"Someone tried to start the ship lmao");
			return false;
		}

		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		public static void GrabObjectClientRpc(PlayerControllerB instance, bool grabValidated, NetworkObjectReference grabbedObject)
		{
			throw new NotImplementedException("Stub");
		}

		[HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1554282707")]
		[HarmonyPrefix]
		private static bool NoGrab(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			NetworkManager networkManager = target.NetworkManager;
			if (rpcParams.Server.Receive.SenderClientId == 0)
			{
				return true;
			}
			if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
			{
				return false;
			}
			if (!GameNetworkManager.Instance.gameHasStarted)
			{
				NetworkObjectReference grabbedObject = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref grabbedObject, default(ForNetworkSerializable));
				GrabObjectClientRpc((PlayerControllerB)target, grabValidated: false, grabbedObject);
				return false;
			}
			return true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SkidPwner";

		public const string PLUGIN_NAME = "SkidPwner";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}