Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Anticheese v1.1.0
plugins/lc_anticheese/lc_anticheese.dll
Decompiled 2 years agousing 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 GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; 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("lc_anticheese")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("stop pulling that stupid lever")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+83c07e3019a4d80ec3f023f505d99824cdecaa09")] [assembly: AssemblyProduct("lc_anticheese")] [assembly: AssemblyTitle("lc_anticheese")] [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 lc_anticheese { [BepInPlugin("net.usbwire.usb.lc_anticheese", "lc_anticheese", "1.1.0")] public class Plugin : BaseUnityPlugin { public const string GUID = "net.usbwire.usb.lc_anticheese"; public const string NAME = "lc_anticheese"; internal static ManualLogSource mls; private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) mls = ((BaseUnityPlugin)this).Logger; mls.LogInfo((object)"Plugin net.usbwire.usb.lc_anticheese is loaded!"); new Harmony("net.usbwire.usb.lc_anticheese").PatchAll(Assembly.GetExecutingAssembly()); } public static void SendWarning(string text) { mls.LogWarning((object)text); HUDManager.Instance.AddToErrorLog(text, 0); HUDManager.Instance.AddChatMessage(text, "Lever"); } } public static class PluginInfo { public const string PLUGIN_GUID = "lc_anticheese"; public const string PLUGIN_NAME = "lc_anticheese"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace lc_anticheese.Patches { [HarmonyPatch] internal class LeverPatch { [HarmonyPatch(typeof(StartMatchLever), "__rpc_handler_2406447821")] [HarmonyPrefix] private static bool PlayLeverPullEffectsServerRpcHandlerPatch(__RpcParams rpcParams) { return false; } [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_1089447320")] [HarmonyPrefix] private static bool StartGameServerRpcHandlerPatch(StartOfRound __instance, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong senderClientId = rpcParams.Server.Receive.SenderClientId; if (senderClientId == GameNetworkManager.Instance.localPlayerController.actualClientId) { return true; } PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (val2.actualClientId == senderClientId) { val = val2; break; } } if ((Object)(object)val != (Object)null) { Plugin.SendWarning(val.playerUsername + " (" + val.playerSteamId + ") attempted to land the ship early!"); } else { Plugin.SendWarning("A unknown player attempted to land the ship early!"); } return false; } [HarmonyPatch(typeof(StartOfRound), "StartGameServerRpc")] [HarmonyPrefix] private static bool StartGameServerRpcPatch(StartOfRound __instance) { Object.FindObjectOfType<StartMatchLever>().PlayLeverPullEffectsClientRpc(true); return true; } [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_2028434619")] [HarmonyPrefix] private static bool EndGameServerRpcHandlerPatch(__RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong senderClientId = rpcParams.Server.Receive.SenderClientId; if (senderClientId == GameNetworkManager.Instance.localPlayerController.actualClientId) { return true; } PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (val2.actualClientId == senderClientId) { val = val2; break; } } if (ShouldEndGame(val)) { EndGameAction(val); return true; } if ((Object)(object)val != (Object)null) { Plugin.SendWarning(val.playerUsername + " (" + val.playerSteamId + ") attempted to start the ship early!"); } else { Plugin.SendWarning("A unknown player attempted to start the ship early!"); } Object.FindObjectOfType<StartMatchLever>().triggerScript.interactable = true; return false; } [HarmonyPatch(typeof(StartOfRound), "EndGameServerRpc")] [HarmonyPrefix] private static bool EndGameServerRpcPatch(StartOfRound __instance) { Object.FindObjectOfType<StartMatchLever>().PlayLeverPullEffectsClientRpc(false); return true; } private static void EndGameAction(PlayerControllerB player) { if ((Object)(object)player != (Object)null) { Plugin.SendWarning(player.playerUsername + " (" + player.playerSteamId + ") started the ship!"); } else { Plugin.SendWarning("A unknown player started the ship early!"); } } private static bool ShouldEndGame(PlayerControllerB playerPulled) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (localPlayerController.actualClientId == playerPulled.actualClientId) { return true; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)playerPulled == (Object)null || !playerPulled.isPlayerControlled) { Plugin.SendWarning("Player is not valid!"); return false; } if (!playerPulled.isInHangarShipRoom || playerPulled.isPlayerDead) { Plugin.SendWarning("Player attemped to start ship while not in the ship? Potentially cheating? - " + playerPulled.playerUsername + " (" + playerPulled.playerSteamId + ")"); return false; } if (!localPlayerController.isPlayerDead && ((Object)instance.currentLevel).name == "CompanyBuildingLevel") { Plugin.SendWarning("Player attemped to start ship while selling quota and host is not dead."); return false; } if (!localPlayerController.isPlayerDead && !IsNearShip(localPlayerController)) { Plugin.SendWarning("Host is not dead and is not nearby ship."); return false; } int num = 0; int num2 = 0; for (int i = 0; i < instance.allPlayerScripts.Length; i++) { PlayerControllerB val = instance.allPlayerScripts[i]; if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && val.isPlayerControlled) { num2++; if (!val.isPlayerDead && !IsNearShip(val)) { num++; } } } if ((float)(num / num2) <= 0.25f) { return true; } Plugin.SendWarning($"Too many missing players! Players: #{num}/${num2}"); return false; } private static bool IsNearShip(PlayerControllerB player) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = StartOfRound.Instance.shipBounds.bounds; return Vector3.Distance(((Bounds)(ref bounds)).center, ((Component)player.gameplayCamera).transform.position) <= 12f; } } [HarmonyPatch] internal class VotePatch { [HarmonyPatch(typeof(TimeOfDay), "__rpc_handler_543987598")] [HarmonyPrefix] private static bool SetShipLeaveEarlyServerRpcHandlerPatch(__RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong senderClientId = rpcParams.Server.Receive.SenderClientId; if (senderClientId == GameNetworkManager.Instance.localPlayerController.actualClientId) { return true; } PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (val2.actualClientId == senderClientId) { val = val2; break; } } Plugin.SendWarning(val.playerUsername + " (" + val.playerSteamId + ") attempted to vote to leave early!"); return false; } [HarmonyPatch(typeof(TimeOfDay), "SetShipLeaveEarlyServerRpc")] [HarmonyPrefix] private static bool SetShipLeaveEarlyServerRpcPatch(TimeOfDay __instance) { if (!((NetworkBehaviour)__instance).IsServer) { return true; } __instance.SetShipLeaveEarlyClientRpc(__instance.normalizedTimeOfDay + 0.1f, 1); return false; } } }