Decompiled source of SmallCheatDetector v1.0.2

SmallCheatDetector.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RadiationIsCool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationIsCool")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 PiggyAntiCheat
{
	[BepInPlugin("Piggy.SmallCheatDetector", "SmallCheatDetector", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Piggy.SmallCheatDetector";

		private const string modName = "SmallCheatDetector";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Piggy.SmallCheatDetector");

		private static Plugin Instance;

		public static bool setKorean;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		public static string PluginDirectory;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			mls = Logger.CreateLogSource("Piggy.SmallCheatDetector");
			mls.LogInfo((object)"Small Cheat Detector is loaded");
			setKorean = ((BaseUnityPlugin)this).Config.Bind<bool>("Translation", "SetKorean", false, "Set language to Korean.").Value;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
}
namespace PiggyAntiCheat.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		public static List<string> twoItemCheckedName = new List<string>();

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(GrabbableObject __instance, ref bool ___isPocketed, ref Item ___itemProperties, ref PlayerControllerB ___playerHeldBy)
		{
			CheckTwoHandedCheat(___itemProperties, ___playerHeldBy, ___isPocketed);
		}

		private static void CheckTwoHandedCheat(Item ___itemProperties, PlayerControllerB ___playerHeldBy, bool ___isPocketed)
		{
			if (!___isPocketed || !___itemProperties.twoHanded)
			{
				return;
			}
			foreach (string item in twoItemCheckedName)
			{
				if (item == ___playerHeldBy.playerUsername)
				{
					return;
				}
			}
			if (Plugin.setKorean)
			{
				HUDManager.Instance.DisplayTip("양 손 치트 감지!", "플레이어 " + ___playerHeldBy.playerUsername + " 이(가) 양 손 아이템을 인벤토리에 넣었습니다! 아이템 이름: " + ___itemProperties.itemName, false, false, "LC_Tip1");
			}
			else
			{
				HUDManager.Instance.DisplayTip("Detect Two-Handed cheat!", "Player " + ___playerHeldBy.playerUsername + " put both hand items in his pockets! Item name: " + ___itemProperties.itemName, false, false, "LC_Tip1");
			}
			twoItemCheckedName.Add(___playerHeldBy.playerUsername);
		}
	}
	[HarmonyPatch(typeof(ShipBuildModeManager))]
	internal class ShipBuildModeManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((ButtonControl)Keyboard.current.kKey).wasPressedThisFrame && GameNetworkManager.Instance.isHostingGame && !StartOfRound.Instance.localPlayerController.inTerminalMenu)
			{
				GameObject.Find("Terminal").GetComponent<AutoParentToShip>().positionOffset = new Vector3(6f, 1f, -9f);
				GameObject.Find("Terminal").GetComponent<AutoParentToShip>().rotationOffset = new Vector3(270f, 90f, -9f);
			}
		}
	}
}