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 AstaAntiCheat v1.0.4
Bepinex/Plugins/AstaAntiCheat.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using AntiCheat; using AntiCheat.Locale; using AntiCheat.Utils; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Netcode.Transports.Facepunch; using Newtonsoft.Json; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("P-Asta;chuxiaaaa")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("AstaAntiCheat, a fork of chuxiaaaa's AntiCheat for Lethal Company.")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+3ee5774cb32a59086f7318cd4180f05cabc00762")] [assembly: AssemblyProduct("AstaAntiCheat")] [assembly: AssemblyTitle("AstaAntiCheat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [BepInPlugin("AntiCheat", "AstaAntiCheat", "1.0.2")] public class AntiCheatPlugin : BaseUnityPlugin { internal static ManualLogSource Log = null; internal static LocalizationManager localizationManager = null; private static readonly Dictionary<string, float> _messageTimes = new Dictionary<string, float>(); private static readonly MethodInfo AddChatMessageMethod = AccessTools.DeclaredMethod(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); private static readonly MethodInfo AddTextMessageClientRpcMethod = AccessTools.DeclaredMethod(typeof(HUDManager), "AddTextMessageClientRpc", (Type[])null, (Type[])null); private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; localizationManager = new LocalizationManager(); PluginConfig.Init((BaseUnityPlugin)(object)this); Harmony val = new Harmony("AntiCheat"); val.PatchAll(Assembly.GetExecutingAssembly()); } public static void LogInfo(string info) { if ((!((Object)(object)StartOfRound.Instance != (Object)null) || ((NetworkBehaviour)StartOfRound.Instance).IsHost) && (PluginConfig.Log == null || PluginConfig.Log.Value)) { Log.LogInfo((object)info); File.AppendAllLines("AntiCheat.log", new string[1] { $"[{DateTime.Now:MM-dd HH:mm:ss:ff}] {info}" }); } } public static void LogInfo(PlayerControllerB player, string rpc, params object[] param) { LogInfo(string.Format("{0}({1}) -> {2};{3}", player.playerUsername, player.playerClientId, rpc, string.Join("|", param))); } public static void ShowMessage(string msg, string dedupeKey = null) { if ((Object)(object)HUDManager.Instance == (Object)null) { return; } string text = localizationManager.MessageFormat().Replace("{Prefix}", localizationManager.Prefix()).Replace("{msg}", msg); string key = dedupeKey ?? text; float realtimeSinceStartup = Time.realtimeSinceStartup; if (!_messageTimes.TryGetValue(key, out var value) || !(realtimeSinceStartup >= value) || !(realtimeSinceStartup - value < 10f)) { if (_messageTimes.Count >= 256) { _messageTimes.Clear(); } _messageTimes[key] = realtimeSinceStartup; LogInfo("Detection|" + text); switch (PluginConfig.DetectedMessageType.Value) { case PluginConfig.MessageType.PublicChat: AddTextMessageClientRpc(text); break; case PluginConfig.MessageType.HostChat: ShowMessageHostOnly(text); break; default: HUDManager.Instance.DisplayTip("AstaAntiCheat", text, true, false, "LC_Tip1"); break; } } } public static void ShowMessageHostOnly(string msg) { if (!((Object)(object)HUDManager.Instance == (Object)null)) { LogInfo("ShowMessageHostOnly -> " + msg); AddChatMessageMethod.Invoke(HUDManager.Instance, new object[4] { msg, "", -1, false }); } } internal static void ShowStaminaSuspicion(PlayerControllerB player) { if ((Object)(object)StartOfRound.Instance == (Object)null || !((NetworkBehaviour)StartOfRound.Instance).IsHost || (Object)(object)player == (Object)null || ((NetworkBehaviour)player).IsOwner || (Object)(object)HUDManager.Instance == (Object)null) { return; } StringBuilder stringBuilder = new StringBuilder(); string text = player.playerUsername ?? string.Empty; foreach (char c in text) { if (stringBuilder.Length >= 64) { break; } if (char.GetUnicodeCategory(c) != UnicodeCategory.Format) { stringBuilder.Append(char.IsControl(c) ? ' ' : (c switch { '>' => '›', '<' => '‹', _ => c, })); } } string newValue = localizationManager.Msg_GetString("StaminaSuspicion", new Dictionary<string, string> { { "{player}", stringBuilder.ToString() }, { "{id}", player.actualClientId.ToString() } }); ShowMessageHostOnly(localizationManager.MessageFormat().Replace("{Prefix}", localizationManager.Prefix()).Replace("{msg}", newValue)); } public static void AddTextMessageClientRpc(string showMessage) { if (!((Object)(object)HUDManager.Instance == (Object)null)) { AddTextMessageClientRpcMethod.Invoke(HUDManager.Instance, new object[1] { showMessage }); } } } internal static class LCMPluginInfo { public const string PLUGIN_GUID = "AntiCheat"; public const string PLUGIN_NAME = "AstaAntiCheat"; public const string PLUGIN_VERSION = "1.0.2"; } namespace AntiCheat { internal class FeatureConfig { public ConfigEntry<bool> EnableEntry { get; } public ConfigEntry<bool> KickEntry { get; } public bool Enable => EnableEntry.Value; public bool Value => EnableEntry.Value; public bool Kick => KickEntry?.Value ?? false; public FeatureConfig(ConfigFile config, string section, string enableDesc, bool defaultEnable = true, bool hasKick = true) { EnableEntry = config.Bind<bool>(section, "Enable", defaultEnable, enableDesc); if (hasKick) { KickEntry = config.Bind<bool>(section, "Kick", false, AntiCheatPlugin.localizationManager.Cfg_GetString("Kick")); } else { KickEntry = null; } } } internal static class PluginConfig { public enum MessageType { GUI, HostChat, PublicChat } public static FeatureConfig Shovel; public static FeatureConfig ShipBuild; public static FeatureConfig Landmine; public static FeatureConfig InfiniteAmmo; public static FeatureConfig Mask; public static FeatureConfig Gift; public static FeatureConfig Turret; public static FeatureConfig Invisibility; public static FeatureConfig KillEnemy; public static FeatureConfig SpawnWebTrap; public static FeatureConfig Map; public static FeatureConfig FreeBuy; public static FeatureConfig RemoteTerminal; public static FeatureConfig Nameless; public static FeatureConfig DespawnItem; public static FeatureConfig ChatReal; public static FeatureConfig ShipLight; public static FeatureConfig TerminalNoise; public static FeatureConfig ItemCooldown; public static FeatureConfig Health; public static FeatureConfig RPCReport; public static FeatureConfig Boss; public static FeatureConfig GrabObject; public static FeatureConfig Jetpack; public static FeatureConfig Enemy; public static FeatureConfig RpcValidation; public static ConfigEntry<bool> IgnoreClientConfig; public static ConfigEntry<string> Prefix; public static ConfigEntry<string> PlayerJoin; public static ConfigEntry<bool> Log; public static ConfigEntry<bool> OperationLog; public static ConfigEntry<bool> ShipConfig; public static ConfigEntry<int> ShipConfig2; public static ConfigEntry<string> ShipConfig3; public static ConfigEntry<int> ShipConfig4; public static ConfigEntry<bool> Ship_Kick; public static ConfigEntry<bool> ShipSetting_OnlyOneVote; public static ConfigEntry<bool> ShipSetting_ChangToFreeMoon; public static ConfigEntry<int> ShipLight_Cooldown; public static ConfigEntry<int> TerminalNoise_Cooldown; public static ConfigEntry<int> ChatReal_Cooldown; public static ConfigEntry<int> RPCReport_Delay; public static ConfigEntry<bool> RPCReport_Hit; public static ConfigEntry<bool> RPCReport_KillPlayer; public static ConfigEntry<bool> Shovel3; public static ConfigEntry<bool> GrabObject_SendLog; public static ConfigEntry<bool> GrabObject_MoreSlot; public static ConfigEntry<bool> GrabObject_TwoHand; public static ConfigEntry<bool> GrabObject_BeltBag; public static ConfigEntry<MessageType> DetectedMessageType; public static ConfigEntry<bool> StaminaObservation; public static ConfigEntry<bool> Shovel2 => Shovel.KickEntry; public static ConfigEntry<bool> ShipBuild2 => ShipBuild.KickEntry; public static ConfigEntry<bool> ItemCooldown2 => ItemCooldown.KickEntry; public static ConfigEntry<bool> DespawnItem2 => DespawnItem.KickEntry; public static ConfigEntry<bool> ChatReal2 => ChatReal.KickEntry; public static ConfigEntry<bool> Mask2 => Mask.KickEntry; public static ConfigEntry<bool> Gift2 => Gift.KickEntry; public static ConfigEntry<bool> Turret2 => Turret.KickEntry; public static ConfigEntry<bool> InfiniteAmmo2 => InfiniteAmmo.KickEntry; public static ConfigEntry<bool> Invisibility2 => Invisibility.KickEntry; public static ConfigEntry<bool> Boss2 => Boss.KickEntry; public static ConfigEntry<bool> Jetpack2 => Jetpack.KickEntry; public static ConfigEntry<bool> Landmine2 => Landmine.KickEntry; public static ConfigEntry<bool> SpawnWebTrap2 => SpawnWebTrap.KickEntry; public static ConfigEntry<bool> KillEnemy2 => KillEnemy.KickEntry; public static ConfigEntry<bool> Map2 => Map.KickEntry; public static ConfigEntry<bool> FreeBuy2 => FreeBuy.KickEntry; public static ConfigEntry<bool> FreeBuy_Kick => FreeBuy.KickEntry; public static ConfigEntry<bool> RemoteTerminal2 => RemoteTerminal.KickEntry; public static ConfigEntry<bool> Nameless2 => Nameless.KickEntry; public static ConfigEntry<bool> GrabObject_Kick => GrabObject.KickEntry; public static ConfigEntry<bool> Health_Recover => Health.EnableEntry; public static ConfigEntry<bool> Health_Kick => Health.KickEntry; public static ConfigEntry<bool> RPCReport_Kick => RPCReport.KickEntry; internal static void Init(BaseUnityPlugin plugin) { ConfigFile config = plugin.Config; LocalizationManager localizationManager = AntiCheatPlugin.localizationManager; IgnoreClientConfig = config.Bind<bool>("VersionSetting", "NetworkSetting", false, localizationManager.Cfg_GetString("NetworkSetting")); Prefix = config.Bind<string>("ServerNameSetting", "Prefix", "AC", localizationManager.Cfg_GetString("Prefix")); Log = config.Bind<bool>("LogSetting", "Log", true, localizationManager.Cfg_GetString("Log")); OperationLog = config.Bind<bool>("LogSetting", "OperationLog", true, localizationManager.Cfg_GetString("OperationLog")); ShipConfig = config.Bind<bool>("ShipSetting", "StartGameOnlyHost", true, localizationManager.Cfg_GetString("ShipSetting")); Ship_Kick = config.Bind<bool>("ShipSetting", "Kick", false, localizationManager.Cfg_GetString("ShipConfig5")); ShipConfig2 = config.Bind<int>("ShipSetting", "StartGamePlayerCount", 8, localizationManager.Cfg_GetString("ShipConfig2")); ShipConfig3 = config.Bind<string>("ShipSetting", "EndGamePlayerTime", "14:00", localizationManager.Cfg_GetString("ShipConfig3")); ShipConfig4 = config.Bind<int>("ShipSetting", "EndGamePlayerCount", 50, localizationManager.Cfg_GetString("ShipConfig4")); ShipSetting_OnlyOneVote = config.Bind<bool>("ShipSetting", "OnlyOneVote", true, localizationManager.Cfg_GetString("ShipConfig6")); ShipSetting_ChangToFreeMoon = config.Bind<bool>("ShipSetting", "ChangToFreeMoon", false, localizationManager.Cfg_GetString("ChangToFreeMoon")); ShipBuild = new FeatureConfig(config, "ShipBuildSetting", localizationManager.Cfg_GetString("ShipBuild")); ItemCooldown = new FeatureConfig(config, "ItemCooldownSetting", localizationManager.Cfg_GetString("ItemCooldown")); ShipLight = new FeatureConfig(config, "ShipLightSettings", localizationManager.Cfg_GetString("ShipLight"), defaultEnable: true, hasKick: false); TerminalNoise = new FeatureConfig(config, "TerminalNoiseSettings", localizationManager.Cfg_GetString("ShipTerminal"), defaultEnable: true, hasKick: false); DespawnItem = new FeatureConfig(config, "DespawnItemSettings", localizationManager.Cfg_GetString("DespawnItem")); ChatReal = new FeatureConfig(config, "ChatRealSettings", localizationManager.Cfg_GetString("ChatReal")); Mask = new FeatureConfig(config, "MaskSettings", localizationManager.Cfg_GetString("Mask")); Gift = new FeatureConfig(config, "GiftSettings", localizationManager.Cfg_GetString("Gift")); Turret = new FeatureConfig(config, "TurretSettings", localizationManager.Cfg_GetString("Turret")); InfiniteAmmo = new FeatureConfig(config, "InfiniteAmmoSettings", localizationManager.Cfg_GetString("InfiniteAmmo")); Invisibility = new FeatureConfig(config, "InvisibilitySettings", localizationManager.Cfg_GetString("Invisibility")); Boss = new FeatureConfig(config, "BossSetting", localizationManager.Cfg_GetString("Boss")); Jetpack = new FeatureConfig(config, "JetpackSetting", localizationManager.Cfg_GetString("Jetpack")); Landmine = new FeatureConfig(config, "LandmineSetting", localizationManager.Cfg_GetString("Landmine")); SpawnWebTrap = new FeatureConfig(config, "SpawnWebTrapSetting", localizationManager.Cfg_GetString("SpawnWebTrap")); Enemy = new FeatureConfig(config, "EnemySetting", localizationManager.Cfg_GetString("Enemy"), defaultEnable: true, hasKick: false); KillEnemy = new FeatureConfig(config, "KillEnemySetting", localizationManager.Cfg_GetString("KillEnemy")); Map = new FeatureConfig(config, "MapSetting", localizationManager.Cfg_GetString("Map")); FreeBuy = new FeatureConfig(config, "FreeBuySettings", localizationManager.Cfg_GetString("FreeBuy")); RemoteTerminal = new FeatureConfig(config, "RemoteTerminalSettings", localizationManager.Cfg_GetString("RemoteTerminal")); Nameless = new FeatureConfig(config, "NamelessSettings", localizationManager.Cfg_GetString("Nameless")); Health = new FeatureConfig(config, "HealthSetting", localizationManager.Cfg_GetString("Health_Recover")); RPCReport = new FeatureConfig(config, "RPCReportSetting", localizationManager.Cfg_GetString("RPCReport_Hit")); Shovel = new FeatureConfig(config, "ShovelSettings", localizationManager.Cfg_GetString("Shovel")); GrabObject = new FeatureConfig(config, "GrabObjectSetting", localizationManager.Cfg_GetString("GrabObject")); RpcValidation = new FeatureConfig(config, "RpcValidationSetting", localizationManager.Cfg_GetString("RpcValidation")); StaminaObservation = config.Bind<bool>("StaminaObservationSetting", "Enable", true, localizationManager.Cfg_GetString("StaminaObservation")); ShipLight_Cooldown = config.Bind<int>("ShipLightSettings", "Cooldown", 2000, localizationManager.Cfg_GetString("Cooldown")); TerminalNoise_Cooldown = config.Bind<int>("TerminalNoiseSettings", "Cooldown", 1000, localizationManager.Cfg_GetString("Cooldown")); ChatReal_Cooldown = config.Bind<int>("ChatRealSettings", "Cooldown", 100, localizationManager.Cfg_GetString("Cooldown")); RPCReport_Delay = config.Bind<int>("RPCReportSetting", "Delay", 1000, localizationManager.Cfg_GetString("RPCReport_Delay")); RPCReport_Hit = config.Bind<bool>("RPCReportSetting", "Hit", true, localizationManager.Cfg_GetString("RPCReport_Hit")); RPCReport_KillPlayer = config.Bind<bool>("RPCReportSetting", "KillPlayer", true, localizationManager.Cfg_GetString("RPCReport_KillPlayer")); DetectedMessageType = config.Bind<MessageType>("DetectedMessageType", "Type", MessageType.PublicChat, localizationManager.Cfg_GetString("DetectedMessageType")); PlayerJoin = config.Bind<string>("MsgSettings", "PlayerJoinShip", localizationManager.Msg_GetString("wlc_player"), localizationManager.Msg_GetString("wlc_player")); Shovel3 = config.Bind<bool>("ShovelSettings", "EmptyHand", false, localizationManager.Cfg_GetString("Shovel2")); GrabObject_SendLog = config.Bind<bool>("GrabObjectSetting", "SendLog", true, localizationManager.Cfg_GetString("GrabObject_SendLog")); GrabObject_MoreSlot = config.Bind<bool>("GrabObjectSetting", "MoreSlot", true, localizationManager.Cfg_GetString("GrabObject_MoreSlot")); GrabObject_TwoHand = config.Bind<bool>("GrabObjectSetting", "TwoHand", true, localizationManager.Cfg_GetString("GrabObject_TwoHand")); GrabObject_BeltBag = config.Bind<bool>("GrabObjectSetting", "BeltBag", true, localizationManager.Cfg_GetString("GrabObject_BeltBag")); CooldownManager.Reset(); RegisterCooldown("TerminalNoise", TerminalNoise.EnableEntry, TerminalNoise_Cooldown); RegisterCooldown("ShipLight", ShipLight.EnableEntry, ShipLight_Cooldown); RegisterCooldown("Chat", ChatReal.EnableEntry, ChatReal_Cooldown); AntiCheatPlugin.LogInfo(localizationManager.Log_GetString("load")); } private static void RegisterCooldown(string name, ConfigEntry<bool> enable, ConfigEntry<int> cooldownMs) { CooldownManager.RegisterCooldownGroup(name, () => enable.Value, () => (float)cooldownMs.Value / 1000f); } } } namespace AntiCheat.Utils { public static class CooldownManager { private struct CooldownData { public Func<bool> IsEnabled; public Func<float> GetCooldown; public List<ulong> CooldownList; } private static readonly Dictionary<string, CooldownData> cooldownGroups = new Dictionary<string, CooldownData>(); public static void Reset() { cooldownGroups.Clear(); } public static void RegisterCooldownGroup(string groupName, Func<bool> isEnabled, Func<float> getCooldown) { cooldownGroups.Add(groupName, new CooldownData { IsEnabled = isEnabled, GetCooldown = getCooldown, CooldownList = new List<ulong>() }); } public static IEnumerator HandleCooldown(string groupName, ulong playerId) { CooldownData data = cooldownGroups[groupName]; data.CooldownList.Add(playerId); yield return (object)new WaitForSeconds(data.GetCooldown()); data.CooldownList.Remove(playerId); } public static bool CheckCooldown(string groupName, PlayerControllerB player) { CooldownData cooldownData = cooldownGroups[groupName]; if (!cooldownData.IsEnabled() || cooldownData.GetCooldown() <= 0f) { return true; } if (cooldownData.CooldownList.Contains(player.playerSteamId)) { return false; } ((MonoBehaviour)player).StartCoroutine(HandleCooldown(groupName, player.playerSteamId)); return true; } } internal struct SprintObservation { internal double Time; internal double X; internal double Y; internal double Z; internal double SprintTime; internal double MovementSpeed; internal bool Eligible; internal bool Sprinting; internal bool PositionFresh; } internal sealed class SprintSuspicionTracker { private const double RestSeconds = 2.0; private const double MaximumSampleGap = 0.75; private const double EvidenceSeconds = 300.0; private const double NotificationCooldown = 120.0; private const double SprintMultiplier = 2.25; private readonly Queue<double> confirmedEpisodes = new Queue<double>(); private SprintObservation previous; private bool hasPrevious; private bool armed; private bool running; private bool pendingCandidate; private double restStarted = double.NaN; private double sprintStarted; private double sprintDistance; private double nextNotification = double.NegativeInfinity; internal bool Observe(SprintObservation sample) { double num = sample.SprintTime * 2.0; double num2 = num * sample.MovementSpeed * 2.25; if (!sample.Eligible || !Finite(sample.Time) || !Finite(sample.X) || !Finite(sample.Y) || !Finite(sample.Z) || !Finite(sample.SprintTime) || !Finite(sample.MovementSpeed) || sample.SprintTime <= 0.0 || sample.MovementSpeed <= 0.0 || !Finite(num) || !Finite(num2) || (sample.Sprinting && !sample.PositionFresh) || sample.Time < nextNotification) { ResetEvidence(); return false; } if (!hasPrevious) { previous = sample; hasPrevious = true; if (!sample.Sprinting) { restStarted = sample.Time; } return false; } double num3 = sample.Time - previous.Time; double num4 = sample.X - previous.X; double num5 = sample.Z - previous.Z; double num6 = Math.Sqrt(num4 * num4 + num5 * num5); double num7 = Math.Abs(sample.Y - previous.Y); double num8 = sample.MovementSpeed * 2.25 * num3; if (!Finite(num3) || num3 <= 0.0 || num3 > 0.75 || sample.SprintTime != previous.SprintTime || sample.MovementSpeed != previous.MovementSpeed || !Finite(num6) || !Finite(num7) || !Finite(num8) || num6 > Math.Max(5.0, num8 * 3.0) || num7 > Math.Max(2.0, num8)) { ResetEvidence(); return false; } previous = sample; while (confirmedEpisodes.Count > 0 && sample.Time - confirmedEpisodes.Peek() > 300.0) { confirmedEpisodes.Dequeue(); } if (!sample.Sprinting) { if (running) { running = false; armed = false; restStarted = sample.Time; } if (double.IsNaN(restStarted)) { restStarted = sample.Time; } if (sample.Time - restStarted < 2.0) { return false; } armed = true; if (!pendingCandidate) { return false; } pendingCandidate = false; confirmedEpisodes.Enqueue(sample.Time); if (confirmedEpisodes.Count < 3) { return false; } nextNotification = sample.Time + 120.0; ResetEvidence(); return true; } restStarted = double.NaN; if (!armed) { pendingCandidate = false; return false; } if (!running) { running = true; sprintStarted = sample.Time; sprintDistance = 0.0; return false; } sprintDistance += num6; if (!Finite(sprintDistance)) { ResetEvidence(); return false; } if (sample.Time - sprintStarted > num && sprintDistance > num2) { pendingCandidate = true; } return false; } internal void ResetEvidence() { confirmedEpisodes.Clear(); hasPrevious = (armed = (running = (pendingCandidate = false))); restStarted = double.NaN; sprintStarted = (sprintDistance = 0.0); } private static bool Finite(double value) { if (!double.IsNaN(value)) { return !double.IsInfinity(value); } return false; } } } namespace AntiCheat.Patches { [HarmonyPatch(typeof(HUDManager))] [HarmonyWrapSafe] public static class HUDManagerChatRealPatch { private const string RpcName = "HUDManager.AddPlayerChatMessageServerRpc"; [HarmonyPatch(typeof(HUDManager), "__rpc_handler_2930587515")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool AddPlayerChatMessageServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { bool enabled = RpcGuard.Enabled; if (!TryReadMessage(reader, out var message, out var playerId, out var reason)) { if (!enabled) { return false; } return RpcGuard.Reject(p, "HUDManager.AddPlayerChatMessageServerRpc", reason); } PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return false; } if (playerId < 0 || playerId >= array.Length) { if (!enabled) { return false; } return RpcGuard.Reject(p, "HUDManager.AddPlayerChatMessageServerRpc", "RpcInvalidIndex"); } PlayerControllerB val = array[playerId]; if ((Object)(object)val == (Object)null) { return false; } if (!enabled && !PluginConfig.ChatReal.Value) { return true; } if ((Object)(object)val != (Object)(object)p) { if (enabled) { return RpcGuard.Reject(p, "HUDManager.AddPlayerChatMessageServerRpc", "RpcChatIdentity", PluginConfig.ChatReal.Value && PluginConfig.ChatReal2.Value); } PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("ChatReal", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{player2}", val.playerUsername } })); if (PluginConfig.ChatReal2.Value) { PatchHelper.KickPlayer(p); } return false; } PatchHelper.LogInfo(p, "HUDManager.AddPlayerChatMessageServerRpc", "chatMessage:" + message); if (!PluginConfig.ChatReal.Value) { return true; } bool flag = CooldownManager.CheckCooldown("Chat", p); if (flag && PatchHelper.locale.current_language == "zh_CN") { AccessTools.DeclaredMethod(typeof(HUDManager), "AddPlayerChatMessageClientRpc", (Type[])null, (Type[])null).Invoke(HUDManager.Instance, new object[2] { message, playerId }); return false; } return flag; } if ((Object)(object)p == (Object)null) { return false; } return true; } private static bool TryReadMessage(FastBufferReader reader, out string message, out int playerId, out string reason) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) int position = ((FastBufferReader)(ref reader)).Position; message = null; playerId = -1; reason = "RpcMalformedPayload"; try { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); if (!flag) { reason = "RpcInvalidChat"; return false; } int position2 = ((FastBufferReader)(ref reader)).Position; uint num = default(uint); ((FastBufferReader)(ref reader)).ReadValueSafe<uint>(ref num, default(ForPrimitives)); if (num > 50) { reason = "RpcInvalidChat"; return false; } if ((long)num * 2L > ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position) { return false; } ((FastBufferReader)(ref reader)).Seek(position2); ((FastBufferReader)(ref reader)).ReadValueSafe(ref message, false); int position3 = ((FastBufferReader)(ref reader)).Position; byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferReader)(ref reader)).Seek(position3); int num2 = b & 7; if (num2 < 1 || num2 > 5 || !((FastBufferReader)(ref reader)).TryBeginRead(num2)) { return false; } ByteUnpacker.ReadValueBitPacked(reader, ref playerId); return true; } catch (Exception ex) when (ex is OverflowException || ex is ArgumentException || ex is InvalidOperationException) { return false; } finally { ((FastBufferReader)(ref reader)).Seek(position); } } } [HarmonyPatch(typeof(HUDManager))] [HarmonyWrapSafe] public static class HUDManagerMapPatch { [HarmonyPatch("__rpc_handler_2787681914")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool AddTextMessageServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string text = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false); } ((FastBufferReader)(ref reader)).Seek(0); PatchHelper.LogInfo(p, "HUDManager.AddTextMessageServerRpc", "chatMessage:" + text); if (text.Contains("<color") || text.Contains("<size")) { if (PluginConfig.Map.Value && text.Contains("<size=0>Tyzeron.Minimap")) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Map", new Dictionary<string, string> { { "{player}", p.playerUsername } })); if (PluginConfig.Map2.Value) { PatchHelper.KickPlayer(p); } } return false; } return text.StartsWith("[morecompanycosmetics]"); } if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(FacepunchTransport))] [HarmonyWrapSafe] public static class FacepunchTransportPatch { [HarmonyPatch("Steamworks.ISocketManager.OnConnecting")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool FacepunchTransportOnConnecting(ref Connection connection, ref ConnectionInfo info) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) NetIdentity identity = Traverse.Create((object)info).Field<NetIdentity>("identity").Value; if (StartOfRound.Instance.allPlayerScripts.Any((PlayerControllerB x) => x.isPlayerControlled && x.playerSteamId == ((NetIdentity)(ref identity)).SteamId.Value)) { PatchHelper.LogInfo("{steamId} repeatedly joins the game."); return false; } if (PatchHelper.ConnectionIdtoSteamIdMap.ContainsKey(((Connection)(ref connection)).Id)) { PatchHelper.ConnectionIdtoSteamIdMap[((Connection)(ref connection)).Id] = ((NetIdentity)(ref identity)).SteamId.Value; } else { PatchHelper.ConnectionIdtoSteamIdMap.Add(((Connection)(ref connection)).Id, ((NetIdentity)(ref identity)).SteamId.Value); } if (PluginConfig.OperationLog.Value) { LocalizationManager locale = PatchHelper.locale; Dictionary<string, string> dictionary = new Dictionary<string, string>(); Friend val = new Friend(SteamId.op_Implicit(PatchHelper.ConnectionIdtoSteamIdMap[((Connection)(ref connection)).Id])); dictionary.Add("{player}", ((Friend)(ref val)).Name); PatchHelper.ShowMessageHostOnly(locale.OperationLog_GetString("JoinLobby", dictionary)); } return true; } [HarmonyPatch("Steamworks.ISocketManager.OnDisconnected")] [HarmonyPrefix] [HarmonyWrapSafe] public static void FacepunchTransportOnDisconnected(ref Connection connection, ref ConnectionInfo info) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (singleton != null && singleton.IsListening) { NetIdentity value = Traverse.Create((object)info).Field<NetIdentity>("identity").Value; HUDManagerRoundSyncPatch.SyncAllPlayerLevelsServerRpcCalls.Remove(PatchHelper.ConnectionIdtoSteamIdMap[((Connection)(ref connection)).Id]); StartOfRoundPatch.SyncShipUnlockablesServerRpcCalls.Remove(PatchHelper.ConnectionIdtoSteamIdMap[((Connection)(ref connection)).Id]); StartOfRoundPatch.SyncAlreadyHeldObjectsServerRpcCalls.Remove(PatchHelper.ConnectionIdtoSteamIdMap[((Connection)(ref connection)).Id]); PatchHelper.ConnectionIdtoSteamIdMap.Remove(((Connection)(ref connection)).Id); } } } [HarmonyPatch(typeof(NetworkConfig))] [HarmonyWrapSafe] public static class NetworkConfigPatch { [HarmonyPatch("CompareConfig")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool NetworkConnectionManagerInitialize(ref bool __result) { if ((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost && PluginConfig.IgnoreClientConfig.Value) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(NetworkManager))] [HarmonyWrapSafe] public static class NetworkManagerPatch { [HarmonyPatch("Awake")] [HarmonyPrefix] [HarmonyWrapSafe] public static void NetworkManagerAwake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!GameNetworkManager.Instance.disableSteam) { PatchHelper.ConnectionIdtoSteamIdMap[0u] = SteamId.op_Implicit(SteamClient.SteamId); } } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyWrapSafe] public static class PlayerControllerConnectionPatch { [HarmonyPatch("__rpc_handler_2504133785")] [HarmonyPrefix] public static bool SendNewPlayerValuesServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0011: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006c: 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) if (!((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost || rpcParams.Server.Receive.SenderClientId == 0L) { return true; } ulong num = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); ulong num2 = PatchHelper.ConnectionIdtoSteamIdMap[PatchHelper.ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId)]; Friend val = default(Friend); ((Friend)(ref val))..ctor(SteamId.op_Implicit(num2)); if (num != num2) { NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId); AntiCheatPlugin.LogInfo($"Player {((Friend)(ref val)).Name}({num2}) spoofed SteamID({num}) while joining"); return false; } string showmsg = PluginConfig.PlayerJoin.Value.Replace("{player}", ((Friend)(ref val)).Name); PatchHelper.AddTextMessageClientRpc(showmsg); return true; } } [HarmonyPatch(typeof(StartOfRound))] [HarmonyWrapSafe] public static class StartOfRoundConnectionPatch { [HarmonyPatch("OnPlayerDC")] [HarmonyPostfix] [HarmonyWrapSafe] public static void OnPlayerDC(int playerObjectNumber, ulong clientId) { PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerObjectNumber].GetComponent<PlayerControllerB>(); component.playerSteamId = 0uL; } } [HarmonyPatch(typeof(EnemyAI))] [HarmonyWrapSafe] public static class EnemyAIControlPatch { [HarmonyPatch("__rpc_handler_2081148948")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool SwitchToBehaviourServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (PatchHelper.Check(rpcParams, out var p)) { int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); EnemyAI val = (EnemyAI)target; PatchHelper.LogInfo(p, "(" + val.enemyType.enemyName + ")EnemyAI.SwitchToBehaviourServerRpc", $"stateIndex:{num}"); if (PluginConfig.Enemy.Value) { JesterAI val2 = (JesterAI)(object)((val is JesterAI) ? val : null); if (val2 != null) { if (((EnemyAI)val2).currentBehaviourStateIndex == 0 && num == 1) { _ = (Object)(object)((EnemyAI)val2).targetPlayer != (Object)null; return true; } if (((EnemyAI)val2).currentBehaviourStateIndex == 1 && num == 2 && val2.popUpTimer <= 0f) { return true; } if (((EnemyAI)val2).currentBehaviourStateIndex == 2 && num == 0) { return true; } PatchHelper.LogInfo(p, "(" + val.enemyType.enemyName + ")EnemyAI.SwitchToBehaviourServerRpc", $"stateIndex:{num}", $"popUpTimer:{val2.popUpTimer}"); return true; } } } else if ((Object)(object)p == (Object)null) { return false; } return true; } public static bool UpdateEnemyPositionServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!PatchHelper.Check(rpcParams, out var p) && (Object)(object)p == (Object)null) { return false; } return true; } [HarmonyPatch("__rpc_handler_3079913705")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool UpdateEnemyRotationServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var _)) { _ = PluginConfig.Enemy.Value; return true; } return true; } [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3587030867")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool ChangeEnemyOwnerServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { if (PluginConfig.Enemy.Value) { int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); EnemyAI component = ((Component)target).GetComponent<EnemyAI>(); if (component is MouthDogAI || component is DressGirlAI) { return true; } float num2 = Vector3.Distance(((Component)p).transform.position, ((Component)component).transform.position); PatchHelper.LogInfo(p, "(" + component.enemyType.enemyName + ")EnemyAI.ChangeEnemyOwnerServerRpc", $"Distance:{num2}", $"CallClientId:{p.playerClientId}", $"OwnerClientId:{((NetworkBehaviour)component).OwnerClientId}", $"NewClientId:{num}"); return true; } } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(BeltBagItem))] [HarmonyWrapSafe] public static class BeltBagItemPatch { [HarmonyPatch("__rpc_handler_2988305002")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_2988305002(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) if (!PatchHelper.Check(rpcParams, out var p)) { return (Object)(object)p != (Object)null; } if (!PluginConfig.GrabObject.Value) { return true; } int position = ((FastBufferReader)(ref reader)).Position; NetworkObjectReference val = default(NetworkObjectReference); int num = default(int); try { ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref val, default(ForNetworkSerializable)); ByteUnpacker.ReadValueBitPacked(reader, ref num); } finally { ((FastBufferReader)(ref reader)).Seek(position); } int num2 = (int)p.playerClientId; if (num != num2) { ((BeltBagItem)target).CancelAddObjectToBagClientRpc(num2); return false; } NetworkObject val2 = default(NetworkObject); if (!((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) || (Object)(object)val2 == (Object)null) { return true; } GrabbableObject component = ((Component)val2).GetComponent<GrabbableObject>(); if ((Object)(object)component == (Object)null || component.isHeld || component.isHeldByEnemy || component.heldByPlayerOnServer) { return true; } if ((Object)(object)component.itemProperties == (Object)null) { ((BeltBagItem)target).CancelAddObjectToBagClientRpc(num2); return false; } if (!component.itemProperties.isScrap && component.itemProperties.itemId != 123984 && component.itemProperties.itemId != 819501) { return true; } if (PluginConfig.GrabObject_SendLog.Value) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("GrabObject_BeltBag", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{itemName}", component.itemProperties.itemName } })); } if (PluginConfig.GrabObject_BeltBag.Value) { ((BeltBagItem)target).CancelAddObjectToBagClientRpc(num2); return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyWrapSafe] public static class PlayerControllerGrabObjectPatch { private static readonly MethodInfo FirstEmptyItemSlotWithItem = AccessTools.Method(typeof(PlayerControllerB), "FirstEmptyItemSlot", new Type[1] { typeof(GrabbableObject) }, (Type[])null); private static readonly FieldInfo UtilitySlot = AccessTools.Field(typeof(PlayerControllerB), "ItemOnlySlot"); [HarmonyPatch("__rpc_handler_412259855")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool SwitchItemSlotsServerRpc(NetworkBehaviour target, FastBufferReader reader, __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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { return true; } if (PatchHelper.Check(rpcParams, out var p)) { if ((Object)(object)target == (Object)(object)p && PluginConfig.GrabObject.Value && PluginConfig.GrabObject_TwoHand.Value && IsHoldingTwoHandedItem(p)) { return false; } return true; } if ((Object)(object)p == (Object)null) { return false; } return true; } [HarmonyPatch("__rpc_handler_1554282707")] [HarmonyPrefix] [HarmonyWrapSafe] public unsafe static bool GrabObjectServerRpc(NetworkBehaviour target, FastBufferReader reader, __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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { return true; } if (PatchHelper.Check(rpcParams, out var p)) { if ((Object)(object)target == (Object)(object)p && PluginConfig.GrabObject.Value) { int position = ((FastBufferReader)(ref reader)).Position; NetworkObjectReference val = default(NetworkObjectReference); try { ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref val, default(ForNetworkSerializable)); } finally { ((FastBufferReader)(ref reader)).Seek(position); } NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null)) { GrabbableObject componentInChildren = ((Component)val2).GetComponentInChildren<GrabbableObject>(); if ((Object)(object)componentInChildren == (Object)null || componentInChildren.heldByPlayerOnServer) { return true; } if ((Object)(object)componentInChildren.itemProperties == (Object)null || p.ItemSlots == null) { p.GrabObjectClientRpc(false, val); return false; } bool flag = true; bool flag2 = false; bool flag3 = false; bool flag4 = true; bool flag5 = false; HashSet<GrabbableObject> hashSet = new HashSet<GrabbableObject>(); GrabbableObject[] itemSlots = p.ItemSlots; foreach (GrabbableObject val3 in itemSlots) { flag5 |= (Object)(object)val3 == (Object)(object)componentInChildren; if ((Object)(object)val3 == (Object)null) { flag = false; continue; } if (!IsOwnedInventoryItem(p, val3) || (Object)(object)val3 == (Object)(object)componentInChildren || !hashSet.Add(val3)) { flag4 = false; continue; } flag2 = flag2 || val3 is JetpackItem; flag3 |= val3.itemProperties.twoHanded && !(val3 is JetpackItem); } object? obj = UtilitySlot?.GetValue(p); GrabbableObject val4 = (GrabbableObject)((obj is GrabbableObject) ? obj : null); if (flag5 || (Object)(object)val4 == (Object)(object)componentInChildren) { p.GrabObjectClientRpc(false, val); return false; } if ((Object)(object)val4 != (Object)null && (!IsOwnedInventoryItem(p, val4) || (Object)(object)val4 == (Object)(object)componentInChildren || !hashSet.Add(val4))) { flag4 = false; } bool flag6 = flag; if (FirstEmptyItemSlotWithItem != null) { try { flag = (int)FirstEmptyItemSlotWithItem.Invoke(p, new object[1] { componentInChildren }) < 0; } catch (TargetInvocationException ex) { PatchHelper.LogInfo(p, "PlayerControllerB.GrabObjectServerRpc", "Slot lookup failed: " + ex.InnerException?.Message); p.GrabObjectClientRpc(false, val); return false; } } PatchHelper.LogInfo(p, "PlayerControllerB.GrabObjectServerRpc", "itemName:" + componentInChildren.itemProperties.itemName, $"full:{flag}", $"inventoryConsistent:{flag4}", $"slot:{p.currentItemSlot}", $"utilityOccupied:{(Object)(object)val4 != (Object)null}", $"Distance:{Vector3.Distance(((Component)p).transform.position, ((Component)componentInChildren).transform.position)}"); bool flag7 = false; string value = p.currentlyHeldObjectServer?.itemProperties?.itemName ?? "unknown"; bool flag8 = flag2 && componentInChildren.itemProperties.twoHanded && !flag3; bool flag9 = flag4 && (IsHoldingTwoHandedItem(p) || (componentInChildren.itemProperties.twoHanded && flag3)); bool flag10 = flag9 && PluginConfig.GrabObject_TwoHand.Value; if (flag9) { if (PluginConfig.GrabObject_SendLog.Value && !flag8) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("GrabObject_TwoHand", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{heldItemName}", value }, { "{itemName}", componentInChildren.itemProperties.itemName }, { "{hasTwoHand}", flag3.ToString() }, { "{jetpack}", flag2.ToString() } })); } if (flag10) { flag7 = true; } } bool flag11 = flag && flag6 && flag4 && !flag7; if (flag11 && PluginConfig.GrabObject_SendLog.Value) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("GrabObject_MoreSlot", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{itemName}", componentInChildren.itemProperties.itemName } })); } if (PluginConfig.GrabObject_MoreSlot.Value && !flag7) { flag7 = flag; } if (flag7) { p.GrabObjectClientRpc(false, val); if (PluginConfig.GrabObject_Kick.Value && (flag10 || flag11)) { PatchHelper.KickPlayer(p); } return false; } Vector3 val5 = (((Object)(object)((Component)p).transform.parent != (Object)null) ? ((Component)p).transform.parent.TransformPoint(p.serverPlayerPosition) : p.serverPlayerPosition); if (Vector3.Distance(((Component)componentInChildren).transform.position, val5) > 100f && Vector3.Distance(((Component)componentInChildren).transform.position, ((Component)p).transform.position) > 100f && !StartOfRound.Instance.shipIsLeaving && StartOfRound.Instance.shipHasLanded) { if (p.teleportedLastFrame) { return true; } if (PluginConfig.GrabObject_SendLog.Value) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("GrabObject", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{object_position}", ((object)((Component)componentInChildren).transform.position/*cast due to .constrained prefix*/).ToString() }, { "{player_position}", ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString() } })); } p.GrabObjectClientRpc(false, val); if (PluginConfig.GrabObject_Kick.Value) { PatchHelper.KickPlayer(p); } return false; } } } } else if ((Object)(object)p == (Object)null) { return false; } return true; } private static bool IsOwnedInventoryItem(PlayerControllerB player, GrabbableObject item) { if ((Object)(object)item != (Object)null && (Object)(object)item.itemProperties != (Object)null && item.heldByPlayerOnServer) { return (Object)(object)item.playerHeldBy == (Object)(object)player; } return false; } private static bool IsHoldingTwoHandedItem(PlayerControllerB player) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; if (!player.twoHanded || !IsOwnedInventoryItem(player, currentlyHeldObjectServer) || !currentlyHeldObjectServer.itemProperties.twoHanded) { return false; } if (player.currentItemSlot == 50) { object? obj = UtilitySlot?.GetValue(player); return (Object)((obj is GrabbableObject) ? obj : null) == (Object)(object)currentlyHeldObjectServer; } if (player.ItemSlots != null && player.currentItemSlot >= 0 && player.currentItemSlot < player.ItemSlots.Length) { return (Object)(object)player.ItemSlots[player.currentItemSlot] == (Object)(object)currentlyHeldObjectServer; } return false; } } [HarmonyPatch(typeof(GiftBoxItem))] [HarmonyWrapSafe] public static class GiftBoxItemPatch { [HarmonyPatch("__rpc_handler_2878544999")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_2878544999(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (PatchHelper.Check(rpcParams, out var p)) { if (PluginConfig.Gift.Value) { GiftBoxItem val = (GiftBoxItem)target; if ((bool)AccessTools.DeclaredField(typeof(GiftBoxItem), "hasUsedGift").GetValue(val)) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Gift", new Dictionary<string, string> { { "{player}", p.playerUsername } })); if (PluginConfig.Gift2.Value) { PatchHelper.KickPlayer(p); } return false; } ((MonoBehaviour)StartOfRound.Instance.localPlayerController).StartCoroutine(PatchHelper.DestroySelf(((Component)val).gameObject)); } } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(GrabbableObject))] [HarmonyWrapSafe] public static class GrabbableObjectItemUsePatch { [HarmonyPostfix] [HarmonyPatch(typeof(GiftBoxItem), "ItemActivate")] public static void ItemActivate(GiftBoxItem __instance) { if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { Object.Destroy((Object)(object)((Component)__instance).gameObject); } } [HarmonyPrefix] [HarmonyPatch("__rpc_handler_3484508350")] public static bool SyncBatteryServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown PatchHelper.Check(rpcParams, out var p); int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); GrabbableObject val = (GrabbableObject)target; if (val.itemProperties.requiresBattery) { AntiCheatPlugin.LogInfo(p, "(" + val.itemProperties.itemName + ")GrabbableObject.SyncBatteryServerRpc", $"num:{num}"); if (num > 100) { return false; } } return true; } } [HarmonyPatch(typeof(HauntedMaskItem))] [HarmonyWrapSafe] public static class HauntedMaskItemPatch { [HarmonyPatch("__rpc_handler_1065539967")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_1065539967(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { if (PluginConfig.Mask.Value) { if (PatchHelper.mjs.Contains(((Object)target).GetInstanceID())) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Mask", new Dictionary<string, string> { { "{player}", p.playerUsername } })); if (PluginConfig.Mask2.Value) { PatchHelper.KickPlayer(p); } return false; } PatchHelper.mjs.Add(((Object)target).GetInstanceID()); } } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(JetpackItem))] [HarmonyWrapSafe] public static class JetpackItemPatch { [HarmonyPatch("__rpc_handler_3663112878")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_3663112878(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (PatchHelper.Check(rpcParams, out var p)) { if (PluginConfig.Jetpack.Value) { JetpackItem val = (JetpackItem)target; if ((Object)(object)((GrabbableObject)val).playerHeldBy != (Object)null && ((GrabbableObject)val).playerHeldBy.playerClientId != p.playerClientId) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Jetpack", new Dictionary<string, string> { { "{player}", p.playerUsername } })); if (PluginConfig.Jetpack2.Value) { PatchHelper.KickPlayer(p); } return false; } if ((Object)(object)((GrabbableObject)val).playerHeldBy == (Object)null) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Jetpack", new Dictionary<string, string> { { "{player}", p.playerUsername } })); if (PluginConfig.Jetpack2.Value) { PatchHelper.KickPlayer(p); } return false; } return true; } } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyWrapSafe] public static class PlayerControllerItemUsePatch { [HarmonyPatch("__rpc_handler_1786952262")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool DespawnHeldObjectServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { if (PluginConfig.DespawnItem.Value) { PatchHelper.LogInfo(p, "PlayerControllerB.DespawnHeldObjectServerRpc", "itemName:" + p.currentlyHeldObjectServer.itemProperties.itemName); if ((Object)(object)p.currentlyHeldObjectServer != (Object)null && !(p.currentlyHeldObjectServer is GiftBoxItem) && !(p.currentlyHeldObjectServer is KeyItem)) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("DespawnItem", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{item}", p.currentlyHeldObjectServer.itemProperties.itemName } })); if (PluginConfig.DespawnItem2.Value) { PatchHelper.KickPlayer(p); } return false; } } } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(EnemyAI))] [HarmonyWrapSafe] public static class EnemyAIKillEnemyPatch { [HarmonyPatch("__rpc_handler_1810146992")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool KillEnemyServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: 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_0014: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { EnemyAI val = (EnemyAI)target; PatchHelper.LogInfo(p, "(" + val.enemyType.enemyName + ")EnemyAI.KillEnemyServerRpc", $"EnemyId:{((Object)val).GetInstanceID()}", $"HP:{val.enemyHP}"); if (PluginConfig.KillEnemy.Value) { foreach (PatchHelper.HitData item in PatchHelper.bypassKill) { if (item.EnemyInstanceId == ((Object)val).GetInstanceID() && !item.CalledClient.Contains(p.playerClientId)) { PatchHelper.LogInfo($"{((Object)val).GetInstanceID()} bypass|playerClientId:{p.playerClientId}"); item.CalledClient.Add(p.playerClientId); return true; } } if (val.enemyHP <= 0) { return true; } if (Vector3.Distance(((Component)p).transform.position, ((Component)val).transform.position) > 50f) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("KillEnemy", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{enemyName}", val.enemyType.enemyName }, { "{HP}", val.enemyHP.ToString() } })); if (PluginConfig.KillEnemy2.Value) { PatchHelper.KickPlayer(p); return false; } } } } return true; } [HarmonyPatch("KillEnemyOnOwnerClient")] [HarmonyPrefix] [HarmonyWrapSafe] public static void KillEnemyOnOwnerClient(EnemyAI __instance) { if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost && !PatchHelper.bypassKill.Exists((PatchHelper.HitData x) => x.EnemyInstanceId == ((Object)__instance).GetInstanceID())) { PatchHelper.LogInfo($"bypassKill -> {__instance.enemyType.enemyName}({((Object)__instance).GetInstanceID()})"); PatchHelper.bypassKill.Add(new PatchHelper.HitData { EnemyInstanceId = ((Object)__instance).GetInstanceID(), force = 0, CalledClient = new List<ulong>() }); } } [HarmonyPatch("KillEnemy")] [HarmonyPrefix] [HarmonyWrapSafe] public static void KillEnemy(EnemyAI __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost && __instance is ButlerEnemyAI) { LandminePatch.SpawnExplosion(((Component)__instance).transform.position + Vector3.up * 0.15f); } } } [HarmonyPatch(typeof(GameNetworkManager))] [HarmonyWrapSafe] public static class GameNetworkManagerLobbyMetadataPatch { [HarmonyPatch("StartHost")] [HarmonyPrefix] [HarmonyWrapSafe] public static void StartHost() { if (!string.IsNullOrWhiteSpace(PluginConfig.Prefix.Value)) { HostSettings lobbyHostSettings = GameNetworkManager.Instance.lobbyHostSettings; string text = lobbyHostSettings.lobbyName.Replace('【', '[').Replace('】', ']').Replace('[', '[') .Replace(']', ']'); List<string> list = new List<string>(); Match match = Regex.Match(text, "^\\[(.*?)\\]"); if (match.Success) { string value = match.Groups[1].Value; list.AddRange(value.Split('/')); text = text.Remove(0, match.Groups[0].Value.Length).TrimStart(); } if (!list.Any((string x) => x == PluginConfig.Prefix.Value)) { list.Add(PluginConfig.Prefix.Value); } lobbyHostSettings.lobbyName = "[" + string.Join("/", list) + "] " + text; } } } [HarmonyPatch(typeof(DoorLock))] [HarmonyWrapSafe] public static class DoorLockPatch { [HarmonyPatch("__rpc_handler_184554516")] [HarmonyPrefix] public static bool UnlockDoorServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { AntiCheatPlugin.LogInfo(p, "DoorLock.UnlockDoorServerRpc"); } else if ((Object)(object)p == (Object)null) { return false; } return true; } [HarmonyPatch("__rpc_handler_2046162111")] [HarmonyPrefix] public static bool OpenDoorAsEnemyServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { AntiCheatPlugin.LogInfo(p, "DoorLock.OpenDoorAsEnemyServerRpc"); } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(GrabbableObject))] [HarmonyWrapSafe] public static class GrabbableObjectOperationLogPatch { [HarmonyPrefix] [HarmonyPatch(typeof(LungProp), "EquipItem")] public static bool EquipItem(LungProp __instance) { if (PluginConfig.OperationLog.Value && __instance.isLungDocked && StartOfRound.Instance.shipHasLanded) { PatchHelper.ShowMessageHostOnly(PatchHelper.locale.OperationLog_GetString("GrabLungProp", new Dictionary<string, string> { ["{player}"] = StartOfRound.Instance.allPlayerScripts.First((PlayerControllerB x) => ((NetworkBehaviour)x).OwnerClientId == ((NetworkBehaviour)__instance).OwnerClientId).playerUsername })); } return true; } } public static class PlayerControllerOperationLogPatch { public static bool DropAllHeldItemsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!PatchHelper.Check(rpcParams, out var p)) { return (Object)(object)p != (Object)null; } AntiCheatPlugin.LogInfo(p, "PlayerControllerB.DropAllHeldItemsServerRpc"); return true; } } [HarmonyPatch(typeof(TerminalAccessibleObject))] [HarmonyWrapSafe] public static class TerminalAccessibleObjectPatch { [HarmonyPatch("__rpc_handler_1181174413")] [HarmonyPrefix] public static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { AntiCheatPlugin.LogInfo(p, "TerminalAccessibleObject.SetDoorOpenServerRpc"); } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(CentipedeAI))] [HarmonyWrapSafe] public static class CentipedeAIPatch { [HarmonyPatch("__rpc_handler_2791977891")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_2791977891(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: 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) if (!PatchHelper.Check(rpcParams, out var p)) { return (Object)(object)p != (Object)null; } int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); PatchHelper.LogInfo(p, "CentipedeAI.ClingToPlayerServerRpc", $"num:{num}"); if ((int)p.playerClientId == num) { if (PatchHelper.ClingTime.ContainsKey(p.playerSteamId)) { PatchHelper.ClingTime[p.playerSteamId] = DateTime.Now; } else { PatchHelper.ClingTime.Add(p.playerSteamId, DateTime.Now); } } return true; } } [HarmonyPatch(typeof(EnemyAI))] [HarmonyWrapSafe] public static class EnemyAICombatPatch { [HarmonyPatch("HitEnemyOnLocalClient")] [HarmonyPrefix] [HarmonyWrapSafe] public static void HitEnemyOnLocalClient(EnemyAI __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID) { if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost) { PatchHelper.bypassHit.Add(new PatchHelper.HitData { EnemyInstanceId = ((Object)__instance).GetInstanceID(), force = force, CalledClient = new List<ulong>() }); } } [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3538577804")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool HitEnemyServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p) || ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost) { if ((Object)(object)p == (Object)null) { return false; } int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); int num2 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num2); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); ((FastBufferReader)(ref reader)).Seek(0); EnemyAI val = (EnemyAI)target; PatchHelper.LogInfo(p, "(" + val.enemyType.enemyName + ")EnemyAI.HitEnemyServerRpc", $"EnemyId:{((Object)val).GetInstanceID()}", $"HP:{val.enemyHP}", $"force:{num}", $"playerWhoHit:{PatchHelper.PlayerClientIdConvertName(num2)}({num2})"); if (p.isHostPlayerObject) { return true; } if (num2 != -1 && (Object)(object)StartOfRound.Instance.allPlayerScripts[num2] != (Object)(object)p) { PatchHelper.LogInfo("return false;"); return false; } VehicleController val2 = Object.FindFirstObjectByType<VehicleController>(); if ((Object)(object)val2 != (Object)null) { PlayerControllerB currentDriver = val2.currentDriver; if (num == 2 && (Object)(object)currentDriver != (Object)null && currentDriver.playerClientId == p.playerClientId) { PatchHelper.lastDriver = currentDriver; return true; } if (num == 2 && (Object)(object)currentDriver == (Object)null && PatchHelper.lastDriver.playerClientId == p.playerClientId) { return true; } } foreach (PatchHelper.HitData item in PatchHelper.bypassHit) { if (item.EnemyInstanceId == ((Object)val).GetInstanceID() && item.force == num && !item.CalledClient.Contains(p.playerClientId)) { PatchHelper.LogInfo($"{((Object)val).GetInstanceID()} bypass|playerClientId:{p.playerClientId}"); item.CalledClient.Add(p.playerClientId); return true; } } if (PluginConfig.Shovel.Value) { GrabbableObject val3 = p.ItemSlots[p.currentItemSlot]; if (num == 6 && num2 == -1) { PatchHelper.LogInfo($"force = 6||enemyPostion:{((Component)val).transform.position}"); PatchHelper.explosions = PatchHelper.explosions.Where((PatchHelper.ExplosionData x) => x.CreateDateTime.AddSeconds(10.0) > DateTime.Now).ToList(); for (int num3 = PatchHelper.explosions.Count - 1; num3 > 0; num3--) { PatchHelper.ExplosionData explosionData = PatchHelper.explosions[num3]; if (!explosionData.CalledClient.Contains(p.playerSteamId)) { float num4 = Vector3.Distance(explosionData.ExplosionPostion, ((Component)val).transform.position); PatchHelper.LogInfo($"ExplosionPostion:{explosionData.ExplosionPostion}||Distance:{num4}"); if (num4 < 5f) { explosionData.CalledClient.Add(p.playerSteamId); return true; } } } } else if (num != 1 && (Object)(object)val3 != (Object)null && (PatchHelper.isShovel(val3) || PatchHelper.isKnife(val3))) { if (!PatchHelper.jcs.Contains(p.playerSteamId)) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Shovel4", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{enemyName}", val.enemyType.enemyName }, { "{damageAmount}", num.ToString() }, { "{item}", PatchHelper.isShovel(val3) ? PatchHelper.locale.Item_GetString("Shovel") : PatchHelper.locale.Item_GetString("Knife") } })); PatchHelper.jcs.Add(p.playerSteamId); if (PluginConfig.Shovel2.Value) { PatchHelper.KickPlayer(p); } return false; } } else if (!p.isPlayerDead && (Object)(object)val3 == (Object)null) { if (PatchHelper.ClingTime.ContainsKey(p.playerSteamId) && PatchHelper.ClingTime[p.playerSteamId].AddSeconds(5.0) > DateTime.Now) { return true; } if (p.ItemSlots.Any((GrabbableObject x) => PatchHelper.isShovel(x)) && num == 1) { return true; } if (!PatchHelper.jcs.Contains(p.playerSteamId)) { for (int num5 = 0; num5 < p.ItemSlots.Length; num5++) { PatchHelper.LogInfo($"p:{p.playerUsername}|i:{num5}|itemName:{p.ItemSlots[num5]?.itemProperties?.itemName}"); } PatchHelper.LogInfo($"currentItemSlot:{p.currentItemSlot}"); PatchHelper.LogInfo("currentlyHeldObjectServer:" + p.currentlyHeldObjectServer?.itemProperties?.itemName); PatchHelper.LogInfo($"obj:{val3}"); PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Shovel6", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{enemyName}", val.enemyType.enemyName }, { "{damageAmount}", num.ToString() } })); if (!PluginConfig.Shovel3.Value && (num == 1 || num == 2 || num == 3 || num == 5)) { PatchHelper.jcs.Add(p.playerSteamId); if (PluginConfig.Shovel2.Value) { PatchHelper.KickPlayer(p); } } return false; } } else if (PatchHelper.jcs.Contains(p.playerSteamId)) { return false; } } } return true; } } [HarmonyPatch(typeof(JesterAI))] [HarmonyWrapSafe] public static class JesterAIPatch { [HarmonyPatch("__rpc_handler_3446243450")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_3446243450(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return PatchHelper.KillPlayerServerRpc(target, reader, rpcParams, "JesterAI.KillPlayerServerRpc"); } } [HarmonyPatch(typeof(NutcrackerEnemyAI))] [HarmonyWrapSafe] public static class NutcrackerEnemyAIPatch { [HarmonyPatch("__rpc_handler_3881699224")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_3881699224(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return PatchHelper.KillPlayerServerRpc(target, reader, rpcParams, "NutcrackerEnemyAI.LegKickPlayerServerRpc"); } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyWrapSafe] public static class PlayerControllerCombatPatch { public static bool KillPlayerServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { if (PatchHelper.rpcs.ContainsKey("KillPlayer")) { PatchHelper.rpcs["KillPlayer"].Remove(p.playerClientId); } int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); Vector3 val = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref val); int num2 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num2); ((FastBufferReader)(ref reader)).Seek(0); PatchHelper.LogInfo(p, "PlayerControllerB.KillPlayerServerRpc", $"playerId:{PatchHelper.PlayerClientIdConvertName(num)}({num})", $"spawnBody:{flag}", $"bodyVelocity:{val}", $"num:{(object)(CauseOfDeath)num2}({num2})"); if (num < 0) { PatchHelper.LogInfo($"KillPlayerServerRpc:Invalid PlayerId({num})"); return false; } if ((Object)(object)StartOfRound.Instance.allPlayerScripts[num] != (Object)(object)p) { PatchHelper.LogInfo("KillPlayerServerRpc:Can't kill other player!"); return false; } if (p.isPlayerDead) { PatchHelper.LogInfo("KillPlayerServerRpc:Player death can't kill!"); return false; } if (num2 == 10) { string text = PatchHelper.locale.Msg_GetString("behind_player", new Dictionary<string, string> { { "{player}", p.playerUsername } }); PatchHelper.LogInfo(text); PatchHelper.AddTextMessageClientRpc(text); } } else if ((Object)(object)p == (Object)null) { return false; } return true; } [HarmonyPatch("__rpc_handler_638895557")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool DamagePlayerFromOtherClientServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown if (PatchHelper.Check(rpcParams, out var p)) { int damageAmount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref damageAmount); Vector3 val = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref val); int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); PatchHelper.LogInfo(p, "PlayerControllerB.DamagePlayerFromOtherClientServerRpc", $"damageAmount:{damageAmount}", $"hitDirection:{val}", $"playerWhoHit:{PatchHelper.PlayerClientIdConvertName(num)}({num})"); PlayerControllerB p2 = (PlayerControllerB)target; return PatchHelper.CheckDamage(p2, p, ref damageAmount); } if ((Object)(object)p == (Object)null) { return false; } return true; } [HarmonyPatch("__rpc_handler_2585603452")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool HealServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (PatchHelper.Check(rpcParams, out var p)) { PatchHelper.LogInfo(p, "PlayerControllerB.HealServerRpc", $"health:{p.health}", "newHealth:20"); p.health = 20; } else if ((Object)(object)p == (Object)null) { return false; } return true; } [HarmonyPatch("DamagePlayer")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool DamagePlayer(PlayerControllerB __instance, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = (CauseOfDeath)0, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3)) { return true; } [HarmonyPatch("__rpc_handler_1084949295")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool DamagePlayerServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown if (PatchHelper.Check(rpcParams, out var p) || ((NetworkBehaviour)StartOfRound.Instance).IsHost) { if (PatchHelper.rpcs.ContainsKey("Hit")) { PatchHelper.rpcs["Hit"].Remove(p.playerClientId); } int damageAmount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref damageAmount); int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); ((FastBufferReader)(ref reader)).Seek(0); PatchHelper.LogInfo(p, "PlayerControllerB.DamagePlayerServerRpc", $"damageNumber:{damageAmount}", $"newHealthAmount:{num}"); PlayerControllerB val = (PlayerControllerB)target; if ((Object)(object)val == (Object)(object)p) { if (PluginConfig.Health_Recover.Value && damageAmount < 0) { string msg = PatchHelper.locale.Msg_GetString("Health_Recover", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{hp}", (damageAmount * -1).ToString() } }); PatchHelper.ShowMessage(msg); if (PluginConfig.Health_Kick.Value) { PatchHelper.KickPlayer(p); } return false; } return true; } return PatchHelper.CheckDamage(val, p, ref damageAmount); } if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(RedLocustBees))] [HarmonyWrapSafe] public static class RedLocustBeesPatch { [HarmonyPatch("__rpc_handler_3246315153")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool __rpc_handler_3246315153(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return PatchHelper.KillPlayerServerRpc(target, reader, rpcParams, "RedLocustBees.BeeKillPlayerServerRpc"); } } public static class PlayerControllerMovementPatch { public unsafe static bool UpdatePlayerPositionServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref val); ((FastBufferReader)(ref reader)).Seek(0); if (PatchHelper.Check(rpcParams, out var p)) { if (PluginConfig.Invisibility.Value) { if ((Object)(object)StartOfRound.Instance.currentLevel != (Object)null && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap) { if (!PatchHelper.recentPlayerPositions.ContainsKey(p.playerSteamId)) { PatchHelper.recentPlayerPositions[p.playerSteamId] = new List<(Vector3, float)>(); } float now = Time.time; PatchHelper.recentPlayerPositions[p.playerSteamId] = PatchHelper.recentPlayerPositions[p.playerSteamId].Where(((Vector3 pos, float time) entry) => now - entry.time <= 5f).ToList(); PatchHelper.recentPlayerPositions[p.playerSteamId].Add((val, now)); } Vector3 serverPlayerPosition = p.serverPlayerPosition; if (p.teleportedLastFrame) { return true; } if (Vector3.Distance(serverPlayerPosition, val) > 100f && Vector3.Distance(val, Vector3.zero) > 10f) { PatchHelper.ShowMessage(PatchHelper.locale.Msg_GetString("Invisibility", new Dictionary<string, string> { { "{player}", p.playerUsername }, { "{player_position}", ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString() } })); if (PluginConfig.Invisibility2.Value) { PatchHelper.KickPlayer(p); } return false; } } } else if ((Object)(object)p == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyWrapSafe] internal static class StaminaObservationPatch { private sealed class ObservationState { internal readonly SprintSuspicionTracker Tracker = new SprintSuspicionTracker(); internal ulong Owner; internal SelectableLevel Level; internal Transform Parent; internal float DamageTime; internal bool TeleportFlags; internal double LastFrame; internal double NextSample; internal double GraceUntil; } private static readonly Dictionary<PlayerControllerB, ObservationState> States = new Dictionary<PlayerControllerB, ObservationState>(); private static StartOfRound observedRound; [HarmonyPostfix] internal static void LateUpdate(PlayerControllerB __instance) { //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; NetworkManager singleton = NetworkManager.Singleton; if (PluginConfig.StaminaObservation == null || !PluginConfig.StaminaObservation.Value || (Object)(object)instance == (Object)null || !((NetworkBehaviour)instance).IsHost || (Object)(object)singleton == (Object)null || !singleton.IsHost || !singleton.IsListening) { Clear(); return; } if (observedRound != instance) { Clear(); observedRound = instance; } if (!instance.shipHasLanded || instance.shipIsLeaving || instance.inShipPhase || instance.newGameIsLoading || instance.suckingPlayersOutOfShip || (Object)(object)instance.currentLevel == (Object)null || instance.timeSinceRoundStarted < 10f) { States.Clear(); return; } if (!IsRemotePlayer(__instance, instance)) { Forget(__instance); return; } double num = Time.time; if (!Finite(num)) { Forget(__instance); return; } if (!States.TryGetValue(__instance, out var value) || value.Owner != ((NetworkBehaviour)__instance).OwnerClientId || value.Level != instance.currentLevel) { value = new ObservationState { Owner = ((NetworkBehaviour)__instance).OwnerClientId, Level = instance.currentLevel, Parent = ((Component)__instance).transform.parent, DamageTime = __instance.timeSinceTakingDamage, TeleportFlags = (__instance.teleportingThisFrame || __instance.teleportedLastFrame), LastFrame = num, NextSample = num, GraceUntil = num + GraceDuration(__instance) }; States[__instance] = value; } bool flag = num < value.LastFrame || num - value.LastFrame > 1.0; value.LastFrame = num; bool flag2 = value.Parent != ((Component)__instance).transform.parent; value.Parent = ((Component)__instance).transform.parent; bool flag3 = value.DamageTime != __instance.timeSinceTakingDamage; value.DamageTime = __instance.timeSinceTakingDamage; bool flag4 = __instance.teleportingThisFrame || __instance.teleportedLastFrame; bool flag5 = flag4 && !value.TeleportFlags; value.TeleportFlags = flag4; if (flag || flag2 || flag3 || flag5 || UnsafeObservation(__instance)) { ResetWithGrace(value, __instance, num); return; } if (num < value.GraceUntil) { value.Tracker.ResetEvidence(); return; } Animator playerBodyAnimator = __instance.playerBodyAnimator; int num2; if (!playerBodyAnimator.IsInTransition(0) && !__instance.isExhausted) { AnimatorStateInfo currentAnimatorStateInfo = playerBodyAnimator.GetCurrentAnimatorStateInfo(0); num2 = (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("Sprinting") ? 1 : 0); } else { num2 = 0; } bool flag6 = (byte)num2 != 0; bool flag7 = !flag6 || (Finite(__instance.timeSincePlayerMoving) && __instance.timeSincePlayerMoving >= 0f && __instance.timeSincePlayerMoving <= 0.75f); if (!flag7) { value.Tracker.ResetEvidence(); } else if (!(num < value.NextSample)) { value.NextSample = num + 0.25; Vector3 serverPlayerPosition = __instance.serverPlayerPosition; if (value.Tracker.Observe(new SprintObservation { Time = num, X = serverPlayerPosition.x, Y = serverPlayerPosition.y, Z = serverPlayerPosition.z, SprintTime = __instance.sprintTime, MovementSpeed = __instance.movementSpeed, Eligible = true, Sprinting = flag6, PositionFresh = flag7 })) { AntiCheatPlugin.ShowStaminaSuspicion(__instance); } } } private static bool IsRemotePlayer(PlayerControllerB player, StartOfRound round) { if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsSpawned || ((NetworkBehaviour)player).IsOwner || player.isHostPlayerObject || !player.isPlayerControlled || player.isPlayerDead || player.actualClientId != ((NetworkBehaviour)player).OwnerClientId || round.ClientPlayerList == null || round.allPlayerScripts == null || !round.ClientPlayerList.TryGetValue(player.actualClientId, out var value) || value < 0 || value >= round.allPlayerScripts.Length) { return false; } if (player.playerClientId == (ulong)value) { return round.allPlayerScripts[value] == player; } return false; } private static bool UnsafeObservation(PlayerControllerB player) { if (Finite(Time.timeScale) && Time.timeScale == 1f && Finite(Time.deltaTime) && !(Time.deltaTime <= 0f) && !(Time.deltaTime > 0.5f) && Finite(player.sprintTime) && !(player.sprintTime <= 0f) && Finite(player.movementSpeed) && !(player.movementSpeed <= 0f) && Finite(player.timeSinceTakingDamage) && Finite(player.drunkness) && Finite(player.drunknessInertia) && Finite(player.poison) && player.health == 100 && !player.criticallyInjured && !(player.currentlyHeldObjectServer is TetraChemicalItem) && player.drunkness == 0f && player.drunknessInertia == 0f && !player.increasingDrunknessThisFrame && player.poison == 0f && !((Object)(object)player.physicsParent != (Object)null) && !((Object)(object)player.overridePhysicsParent != (Object)null) && !player.isInElevator && !player.isInHangarShipRoom && !player.inVehicleAnimation && !player.isClimbingLadder && !player.inSpecialInteractAnimation && !player.enteringSpecialAnimation && !((Object)(object)player.inAnimationWithEnemy != (Object)null) && !player.disableSyncInAnimation && !player.jetpackControls && !player.disablingJetpackControls && !player.isPlayerSliding && player.slipperyFloor == 0f && Finite(player.slimeSlipAudioVolumeSync) && !(player.slimeSlipAudioVolumeSync > 0f) && (!((Object)(object)player.slimeSlipAudio != (Object)null) || !player.slimeSlipAudio.isPlaying) && Finite(((Vector3)(ref player.externalForces)).sqrMagnitude) && Finite(((Vector3)(ref player.externalForceAutoFade)).sqrMagnitude) && !(((Vector3)(ref player.externalForces)).sqrMagnitude > 0.0001f) && !(((Vector3)(ref player.externalForceAutoFade)).sqrMagnitude > 0.0001f) && !player.isUnderwater && !player.isSinking && !((Object)(object)player.playerBodyAnimator == (Object)null)) { return !((Behaviour)player.playerBodyAnimator).isActiveAndEnabled; } return true; } internal static void ResetForEvent(PlayerControllerB player) { if ((Object)(object)player != (Object)null && States.TryGetValue(player, out var value) && Finite(Time.time)) { ResetWithGrace(value, player, Time.time); } } private static void ResetWithGrace(ObservationState state, PlayerControllerB player, double now) { state.Tracker.ResetEvidence(); state.GraceUntil = Math.Max(state.GraceUntil, now + GraceDuration(player)); state.NextSample = now; } private static double GraceDuration(PlayerControllerB player) { if (!Finite(player.sprintTime) || !(player.sprintTime > 0f)) { return 10.0; } return Math.Max(10.0, 2.0 * (double)player.sprintTime); } private static bool Finite(double value) { if (!double.IsNaN(value)) { return !double.IsInfinity(value); } return false; } internal static void Forget(PlayerControllerB player) { if (player != null) { States.Remove(player); } } internal static void Clear() { States.Clear(); observedRound = null; } } [HarmonyPatch] [HarmonyWrapSafe] internal static class StaminaObservationEventPatch { private static readonly List<MethodBase> Methods = FindMethods(); private static List<MethodBase> FindMethods() { List<MethodBase> list = new List<MethodBase>(); string[] array = new string[4] { "DamageOnOtherClients", "TeleportPlayer", "PlayerJumpedClientRpc", "OnDestroy" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(PlayerControllerB), text, (Type[])null, (Type[])null); if (methodInfo != null) { list.Add(methodInfo); } } string[] array2 = new string[3] { "OnPlayerDC", "EndOfGame", "OnDestroy" }; foreach (string text2 in array2) { MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(StartOfRound), text2, (Type[])null, (Type[])null); if (methodInfo2 != null) { list.Add(methodInfo2); } } return list; } [HarmonyPrepare] private static bool Prepare() { return Methods.Count > 0; } [HarmonyTargetMethods] private static IEnumerable<MethodBase> TargetMethods() { return Methods; } [HarmonyPostfix] internal static void Postfix(object __instance, MethodBase __originalMethod) { PlayerControllerB val = (PlayerControllerB)((__instance is PlayerControllerB) ? __instance : null);