diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index c887cb8..0000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-name: Build AntiCheat (.NET Framework 4.7.2)
-
-on:
- push:
- branches:
- - main
- pull_request:
- branches:
- - main
- workflow_dispatch:
-
-jobs:
- build:
- runs-on: windows-2019
-
- steps:
- - name: 检出代码
- uses: actions/checkout@v3
-
- - name: 设置 NuGet
- uses: NuGet/setup-nuget@v1.0.5
-
- - name: 恢复 NuGet 包
- run: nuget restore AntiCheat.sln
-
- - name: 设置 MSBuild
- uses: microsoft/setup-msbuild@v1.1
-
- - name: 编译解决方案
- run: msbuild AntiCheat.sln /p:Configuration=Release /p:Platform="Any CPU"
diff --git a/.gitignore b/.gitignore
index f4224b5..9491a2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,363 @@
-################################################################################
-# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
-################################################################################
-
-/AntiCheat/obj/Debug
-/.vs
-/AntiCheat/bin/Debug
-/AntiCheat.zip
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Oo]ut/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
\ No newline at end of file
diff --git a/AntiCheat.slnx b/AntiCheat.slnx
new file mode 100644
index 0000000..d1da2d4
--- /dev/null
+++ b/AntiCheat.slnx
@@ -0,0 +1,3 @@
+
+
+
diff --git a/AntiCheat/.vs/AntiCheat.csproj.dtbcache.json b/AntiCheat/.vs/AntiCheat.csproj.dtbcache.json
deleted file mode 100644
index 3e11cd3..0000000
--- a/AntiCheat/.vs/AntiCheat.csproj.dtbcache.json
+++ /dev/null
@@ -1 +0,0 @@
-{"RootPath":"C:\\Users\\91021\\source\\repos\\AntiCheat\\AntiCheat","ProjectFileName":"AntiCheat.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[],"References":[],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\91021\\source\\repos\\AntiCheat\\AntiCheat\\bin\\Debug\\AntiCheat.dll","OutputItemRelativePath":"AntiCheat.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
\ No newline at end of file
diff --git a/AntiCheat/AntiCheat.csproj b/AntiCheat/AntiCheat.csproj
new file mode 100644
index 0000000..4a00d6b
--- /dev/null
+++ b/AntiCheat/AntiCheat.csproj
@@ -0,0 +1,55 @@
+
+
+
+ netstandard2.1
+ AntiCheat
+ chuxiaaaa
+ AntiCheat
+ AntiCheat
+ 1.0.0
+ $(Product).deps.json
+ $(Product)
+ $(Product)
+
+
+ true
+ embedded
+ $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))=./
+
+
+
+
+ $(AssemblyName)
+ $(Product)
+ $(Version)
+
+
+
+ $(IntermediateOutputPath)LCMPluginInfo.cs
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
diff --git a/AntiCheat/AntiCheatPlugin.cs b/AntiCheat/AntiCheatPlugin.cs
new file mode 100644
index 0000000..f2b5f9f
--- /dev/null
+++ b/AntiCheat/AntiCheatPlugin.cs
@@ -0,0 +1,99 @@
+using AntiCheat;
+using AntiCheat.Locale;
+
+using BepInEx;
+using BepInEx.Logging;
+
+using GameNetcodeStuff;
+
+using HarmonyLib;
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+
+[BepInPlugin(LCMPluginInfo.PLUGIN_GUID, LCMPluginInfo.PLUGIN_NAME, LCMPluginInfo.PLUGIN_VERSION)]
+public class AntiCheatPlugin : BaseUnityPlugin
+{
+ internal static ManualLogSource Log = null!;
+
+ private void Awake()
+ {
+ Log = Logger;
+ PluginConfig.Init(this);
+ }
+
+ public static void LogInfo(string info)
+ {
+ if (StartOfRound.Instance == null || StartOfRound.Instance.IsHost)
+ {
+ if (PluginConfig.Log == null || PluginConfig.Log.Value)
+ {
+ Log.LogInfo($"{info}");
+ File.AppendAllLines("AntiCheat.log", new string[] { $"[{DateTime.Now.ToString("MM-dd HH:mm:ss:ff")}] {info}" });
+ }
+ }
+ }
+
+ public static void LogInfo(PlayerControllerB p, string rpc, params object[] param)
+ {
+ LogInfo($"{p.playerUsername}({p.playerClientId}) -> {rpc};{string.Join("|", param)}");
+ }
+
+ private static string lastMessage = string.Empty;
+
+ private static readonly MethodInfo AddChatMessageMethod =
+ AccessTools.DeclaredMethod(typeof(HUDManager), "AddChatMessage");
+
+ private static readonly MethodInfo AddTextMessageClientRpcMethod =
+ AccessTools.DeclaredMethod(typeof(HUDManager), "AddTextMessageClientRpc");
+
+ ///
+ /// 在游戏中输出信息
+ ///
+ public static void ShowMessage(string msg, string dedupeKey = null)
+ {
+ var template = locale.MessageFormat();
+ var showmsg = template
+ .Replace("{Prefix}", locale.Prefix())
+ .Replace("{msg}", msg);
+
+ var compareKey = dedupeKey ?? showmsg;
+
+ if (lastMessage == compareKey)
+ return;
+
+ lastMessage = compareKey;
+
+ if (HUDManager.Instance == null)
+ return;
+
+ switch (PluginConfig.DetectedMessageType.Value)
+ {
+ case PluginConfig.MessageType.PublicChat:
+ AddTextMessageClientRpc(showmsg);
+ break;
+
+ case PluginConfig.MessageType.HostChat:
+ ShowMessageHostOnly(showmsg);
+ break;
+ default:
+ LogInfo($"ShowGUI|{showmsg}");
+ break;
+ }
+
+
+ }
+
+ public static void ShowMessageHostOnly(string msg)
+ {
+ LogInfo($"ShowMessageHostOnly -> {msg}");
+ AddChatMessageMethod.Invoke(HUDManager.Instance,new object[] { msg, "", -1, false });
+ }
+
+ public static void AddTextMessageClientRpc(string showmsg)
+ {
+ AddTextMessageClientRpcMethod.Invoke(HUDManager.Instance,new object[] { showmsg });
+ }
+}
diff --git a/AntiCheat/Build/Build.bat b/AntiCheat/Build/Build.bat
deleted file mode 100644
index 0874d9f..0000000
--- a/AntiCheat/Build/Build.bat
+++ /dev/null
@@ -1,56 +0,0 @@
-@echo off
-setlocal enabledelayedexpansion
-
-:: ��ȡ����
-set projectDir=%~1
-set targetDir=%~2
-set solutionDir=%~3
-set projectName=%~4
-
-:: ������ʱĿ¼
-set tempDir=%TEMP%\%projectName%
-if exist "%tempDir%" (
- rmdir /s /q "%tempDir%"
-)
-mkdir "%tempDir%"
-
-:: �����ĵ��ļ�
-copy "%solutionDir%CHANGELOG.md" "%tempDir%\" >nul 2>&1
-copy "%solutionDir%README.md" "%tempDir%\" >nul 2>&1
-
-:: �������Ŀ¼�ṹ
-mkdir "%tempDir%\BepInEx\plugins"
-copy "%targetDir%%projectName%.dll" "%tempDir%\BepInEx\plugins\" >nul 2>&1
-
-:: �Զ��������������ļ�
-set langSourceDir=%projectDir%Lang
-set localesDir=%tempDir%\BepInEx\plugins\locales
-
-if exist "%langSourceDir%" (
- mkdir "%localesDir%"
- echo ���ڸ��������ļ�:
- for %%f in ("%langSourceDir%\*") do (
- copy "%%f" "%localesDir%\" >nul 2>&1
- echo - %%~nxf
- )
-)
-
-:: ����������Դ�ļ�
-copy "%solutionDir%icon.png" "%tempDir%\" >nul 2>&1
-copy "%solutionDir%manifest.json" "%tempDir%\" >nul 2>&1
-
-:: ����ZIP�ļ�
-set zipPath=%solutionDir%%projectName%.zip
-if exist "%zipPath%" (
- del /f "%zipPath%"
-)
-
-:: ʹ������ѹ������ (Windows 10+)
-powershell -Command "Compress-Archive -Path '%tempDir%\*' -DestinationPath '%zipPath%' -Force"
-
-:: ������ʱĿ¼
-rmdir /s /q "%tempDir%"
-
-:: ������
-echo.
-echo ZIP������: %zipPath%
\ No newline at end of file
diff --git a/AntiCheat/Core/AntiCheat.cs b/AntiCheat/Core/AntiCheat.cs
deleted file mode 100644
index e2e4b5b..0000000
--- a/AntiCheat/Core/AntiCheat.cs
+++ /dev/null
@@ -1,446 +0,0 @@
-using AntiCheat.Locale;
-using AntiCheat.Patch;
-
-using BepInEx;
-using BepInEx.Configuration;
-using BepInEx.Logging;
-
-using GameNetcodeStuff;
-
-using HarmonyLib;
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-using UnityEngine;
-using UnityEngine.Diagnostics;
-using UnityEngine.Rendering;
-using UnityEngine.SceneManagement;
-
-namespace AntiCheat.Core
-{
- [BepInPlugin("AntiCheat", "AntiCheat", Version)]
- public class AntiCheat : BaseUnityPlugin
- {
- public const string Version = "0.8.7";
- public static ManualLogSource ManualLog = null;
-
- public enum MessageType
- {
- GUI,
- HostChat,
- PublicChat
- }
-
- public static Locale.LocalizationManager localizationManager = null;
-
-
- public static ConfigEntry Log;
- public static ConfigEntry OperationLog;
-
- public static ConfigEntry IgnoreClientConfig;
-
- public static GameObject ui;
-
- public static ConfigEntry Shovel;
- public static ConfigEntry Shovel2;
- public static ConfigEntry Shovel3;
-
- public static ConfigEntry Prefix;
- public static ConfigEntry PlayerJoin;
-
- public static ConfigEntry ShipConfig;
- public static ConfigEntry ShipConfig2;
- public static ConfigEntry ShipConfig3;
- public static ConfigEntry ShipConfig4;
- public static ConfigEntry Ship_Kick;
- public static ConfigEntry ShipSetting_OnlyOneVote;
- public static ConfigEntry ShipSetting_ChangToFreeMoon;
-
- public static ConfigEntry ShipBuild;
- public static ConfigEntry ShipBuild2;
-
- public static ConfigEntry ShipLight;
- public static ConfigEntry ShipLight_Cooldown;
-
- public static ConfigEntry TerminalNoise;
- public static ConfigEntry TerminalNoise_Cooldown;
-
- public static ConfigEntry DespawnItem;
- public static ConfigEntry DespawnItem2;
-
- public static ConfigEntry ChatReal;
- public static ConfigEntry ChatReal_Cooldown;
- public static ConfigEntry ChatReal2;
-
- public static ConfigEntry Mask;
- public static ConfigEntry Mask2;
-
- public static ConfigEntry Gift;
- public static ConfigEntry Gift2;
-
- public static ConfigEntry Invisibility;
- public static ConfigEntry Invisibility2;
-
- public static ConfigEntry GrabObject;
- public static ConfigEntry GrabObject_MoreSlot;
- public static ConfigEntry GrabObject_TwoHand;
- public static ConfigEntry GrabObject_BeltBag;
- public static ConfigEntry GrabObject_Kick;
-
- public static ConfigEntry Boss;
- public static ConfigEntry Boss2;
-
- public static ConfigEntry Landmine;
- public static ConfigEntry Landmine2;
-
- public static ConfigEntry PlayerCarryWeight;
- public static ConfigEntry PlayerCarryWeight2;
- public static ConfigEntry PlayerCarryWeight3;
-
-
- public static ConfigEntry Turret;
- public static ConfigEntry Turret2;
-
- public static ConfigEntry Enemy;
-
- public static ConfigEntry KillEnemy;
- public static ConfigEntry KillEnemy2;
-
- public static ConfigEntry SpawnWebTrap;
- public static ConfigEntry SpawnWebTrap2;
-
- public static ConfigEntry Map;
- public static ConfigEntry Map2;
-
- public static ConfigEntry Jetpack;
- public static ConfigEntry Jetpack2;
-
- public static ConfigEntry ItemCooldown;
- public static ConfigEntry ItemCooldown2;
-
- public static ConfigEntry InfiniteAmmo;
- public static ConfigEntry InfiniteAmmo2;
-
- public static ConfigEntry FreeBuy;
- public static ConfigEntry FreeBuy2;
-
- public static ConfigEntry RemoteTerminal;
- public static ConfigEntry RemoteTerminal2;
-
- public static ConfigEntry Nameless;
- public static ConfigEntry Nameless2;
-
- public static ConfigEntry RPCReport_Delay;
- public static ConfigEntry RPCReport_Hit;
- public static ConfigEntry RPCReport_KillPlayer;
- public static ConfigEntry RPCReport_Kick;
-
- public static ConfigEntry Health_Recover;
- public static ConfigEntry Health_Kick;
-
-
- public static ConfigEntry DetectedMessageType;
-
- public static bool Gui;
-
-
- //public static void String(string text, GUIStyle style, float yPos)
- //{
- // float screenWidth = Screen.width;
- // Vector2 textSize = style.CalcSize(new GUIContent(text));
- // float xPos = (screenWidth - textSize.x) / 2;
- // GUI.Label(new Rect(xPos, yPos, textSize.x, textSize.y), text, style);
- //}
-
- //public void Update()
- //{
- // if (StartOfRound.Instance != null && !StartOfRound.Instance.IsHost)
- // {
- // return;
- // }
- // if (UnityInput.Current.GetKeyDown(KeyCode.F10))
- // {
- // Gui = !Gui;
- // }
- //}
-
- //public void OnGUI()
- //{
- // if (StartOfRound.Instance != null && !StartOfRound.Instance.IsHost)
- // {
- // return;
- // }
- // Scene activeScene = SceneManager.GetActiveScene();
- // Color darkBackground = new Color(23f / 255f, 23f / 255f, 23f / 255f, 1f);
-
- // GUI.backgroundColor = darkBackground;
- // GUI.contentColor = Color.white;
-
- // var Style = new GUIStyle(GUI.skin.label);
- // Style.normal.textColor = Color.white;
- // Style.fontStyle = FontStyle.Bold;
- // if (activeScene.name == "SampleSceneRelay")
- // {
- // if (!Gui)
- // {
- // String($"AntiCheat(Beta{AntiCheatPlugin.Version}) Press F10", Style, 10);
- // Cursor.visible = false;
- // Cursor.lockState = CursorLockMode.Locked;
- // }
- // else
- // {
- // Cursor.visible = true;
- // Cursor.lockState = CursorLockMode.None;
- // ShowMenu();
- // }
- // }
- //}
-
- public Dictionary Tabs { get; set; }
-
- //public void ShowMenu()
- //{
- // var e = Event.current.type;
- // if (e == EventType.Layout || e == EventType.Repaint)
- // {
- // float screenWidth = (Screen.width - 600) / 2;
- // GUILayout.Window(0, new Rect(screenWidth, 10, 600, 300), (x) =>
- // {
- // foreach (var item in Tabs)
- // {
- // if (GUILayout.Button(item.Key) || item.Value)
- // {
- // if (!item.Value)
- // {
- // Tabs[item.Key] = true;
- // }
- // GUILayout.BeginScrollView(Vector2.zero);
- // foreach (var item2 in Config.Keys.GroupBy(p => p.Section))
- // {
- // GUILayout.Label(item2.Key);
- // foreach (var item3 in item2)
- // {
- // if (GUILayout.Button(item3.Key))
- // {
-
- // }
- // }
- // }
- // GUILayout.EndScrollView();
- // }
- // }
-
- // GUILayout.BeginHorizontal();
- // foreach (var item in StartOfRound.Instance.allPlayerScripts)
- // {
- // //if (item.isPlayerControlled)
- // //{
- // // GUILayout.Label($"{item.playerUsername}:{item.gameObject.}");
- // //}
- // }
- // if (GUILayout.Button("检测记录"))
- // {
-
- // }
- // else if (GUILayout.Button("玩家管理"))
- // {
-
- // }
- // else if (GUILayout.Button("黑名单管理"))
- // {
-
- // }
- // else if (GUILayout.Button("语言设置"))
- // {
-
- // }
- // GUILayout.EndHorizontal();
- // }, $"AntiCheat(Beta{AntiCheatPlugin.Version})");
- // }
- //}
-
- void Awake()
- {
- ManualLog = Logger;
- //Tabs = new Dictionary();
- //Tabs.Add("模组配置", false);
- FileSystemWatcher watcher = new FileSystemWatcher();
- var fi = new FileInfo(Config.ConfigFilePath);
- watcher.Path = fi.DirectoryName;
- watcher.Filter = fi.Name;
- watcher.Changed += Watcher_Changed;
- LoadConfig();
- watcher.EnableRaisingEvents = true;
-
- Harmony.CreateAndPatchAll(typeof(Patches));
- Harmony.CreateAndPatchAll(typeof(ShipTeleporterPatch));
- Harmony.CreateAndPatchAll(typeof(TurretPatch));
- Harmony.CreateAndPatchAll(typeof(HUDManagerPatch));
- Harmony.CreateAndPatchAll(typeof(StartOfRoundPatch));
- Harmony.CreateAndPatchAll(typeof(GrabbableObjectPatch));
- Harmony.CreateAndPatchAll(typeof(TerminalPatch));
- Harmony.CreateAndPatchAll(typeof(PlayerControllerBPatch));
- Harmony.CreateAndPatchAll(typeof(DoorLockPatch));
- Harmony.CreateAndPatchAll(typeof(LandminePatch));
- Harmony.CreateAndPatchAll(typeof(RoundManagerPatch));
- Harmony.CreateAndPatchAll(typeof(TerminalAccessibleObjectPatch));
- }
-
- private void Watcher_Changed(object sender, FileSystemEventArgs e)
- {
- LogInfo($"Reload Config");
- LoadConfig();
- }
-
- public static void LogInfo(string info)
- {
- if (StartOfRound.Instance == null || StartOfRound.Instance.IsHost)
- {
- if (Log == null || Log.Value)
- {
- ManualLog.LogInfo($"{info}");
- File.AppendAllLines("AntiCheat.log", new string[] { $"[{DateTime.Now.ToString("MM-dd HH:mm:ss:ff")}] {info}" });
- }
- }
- }
-
- public static void LogInfo(PlayerControllerB p,string rpc, params object[] param)
- {
- LogInfo($"{p.playerUsername}({p.playerClientId}) -> {rpc};{string.Join("|", param)}");
- }
-
- private void LoadConfig()
- {
- localizationManager = new LocalizationManager();
- IgnoreClientConfig = Config.Bind("VersionSetting", "NetworkSetting", false, localizationManager.Cfg_GetString("NetworkSetting"));
- Prefix = Config.Bind("ServerNameSetting", "Prefix", "AC", localizationManager.Cfg_GetString("Prefix"));
- ShipConfig = Config.Bind("ShipSetting", "StartGameOnlyHost", true, localizationManager.Cfg_GetString("ShipSetting"));
- Log = Config.Bind("LogSetting", "Log", true, localizationManager.Cfg_GetString("Log"));
- OperationLog = Config.Bind("LogSetting", "OperationLog", true, localizationManager.Cfg_GetString("OperationLog"));
-
- Ship_Kick = Config.Bind("ShipSetting", "Kick", false, localizationManager.Cfg_GetString("ShipConfig5"));
- ShipConfig2 = Config.Bind("ShipSetting", "StartGamePlayerCount", 8, localizationManager.Cfg_GetString("ShipConfig2"));
- ShipConfig3 = Config.Bind("ShipSetting", "EndGamePlayerTime", "14:00", localizationManager.Cfg_GetString("ShipConfig3"));
- ShipConfig4 = Config.Bind("ShipSetting", "EndGamePlayerCount", 50, localizationManager.Cfg_GetString("ShipConfig4"));
- ShipSetting_OnlyOneVote = Config.Bind("ShipSetting", "OnlyOneVote", true, localizationManager.Cfg_GetString("ShipConfig6"));
- ShipSetting_ChangToFreeMoon = Config.Bind("ShipSetting", "ChangToFreeMoon", false, localizationManager.Cfg_GetString("ChangToFreeMoon"));
-
-
- RPCReport_Delay = Config.Bind("RPCReportSetting", "Delay", 1000, localizationManager.Cfg_GetString("RPCReport_Delay"));
- RPCReport_Hit = Config.Bind("RPCReportSetting", "Hit", true, localizationManager.Cfg_GetString("RPCReport_Hit"));
- RPCReport_KillPlayer = Config.Bind("RPCReportSetting", "KillPlayer", true, localizationManager.Cfg_GetString("RPCReport_KillPlayer"));
- RPCReport_Kick = Config.Bind("RPCReportSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Health_Recover = Config.Bind("HealthSetting", "Recover", true, localizationManager.Cfg_GetString("Health_Recover"));
- Health_Kick = Config.Bind("HealthSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- ShipBuild = Config.Bind("ShipBuildSetting", "Enable", true, localizationManager.Cfg_GetString("ShipBuild"));
- ShipBuild2 = Config.Bind("ShipBuildSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- ItemCooldown = Config.Bind("ItemCooldownSetting", "Enable", true, localizationManager.Cfg_GetString("ItemCooldown"));
- ItemCooldown2 = Config.Bind("ItemCooldownSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- ShipLight = Config.Bind("ShipLightSettings", "Enable", true, localizationManager.Cfg_GetString("ShipLight"));
- ShipLight_Cooldown = Config.Bind("ShipLightSettings", "Cooldown", 2000, localizationManager.Cfg_GetString("Cooldown"));
-
- TerminalNoise = Config.Bind("TerminalNoiseSettings", "Enable", true, localizationManager.Cfg_GetString("ShipTerminal"));
- TerminalNoise_Cooldown = Config.Bind("TerminalNoiseSettings", "Cooldown", 1000, localizationManager.Cfg_GetString("Cooldown"));
-
- DetectedMessageType = Config.Bind("DetectedMessageType", "Type", MessageType.PublicChat, localizationManager.Cfg_GetString("DetectedMessageType"));
-
- DespawnItem = Config.Bind("DespawnItemSettings", "Enable", true, localizationManager.Cfg_GetString("DespawnItem"));
- DespawnItem2 = Config.Bind("DespawnItemSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- ChatReal = Config.Bind("ChatRealSettings", "Enable", true, localizationManager.Cfg_GetString("ChatReal"));
- ChatReal_Cooldown = Config.Bind("ChatRealSettings", "Cooldown", 100, localizationManager.Cfg_GetString("Cooldown"));
- ChatReal2 = Config.Bind("ChatRealSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Mask = Config.Bind("MaskSettings", "Enable", true, localizationManager.Cfg_GetString("Mask"));
- Mask2 = Config.Bind("MaskSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Gift = Config.Bind("GiftSettings", "Enable", true, localizationManager.Cfg_GetString("Gift"));
- Gift2 = Config.Bind("GiftSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Turret = Config.Bind("TurretSettings", "Enable", true, localizationManager.Cfg_GetString("Turret"));
- Turret2 = Config.Bind("TurretSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- InfiniteAmmo = Config.Bind("InfiniteAmmoSettings", "Enable", true, localizationManager.Cfg_GetString("InfiniteAmmo"));
- InfiniteAmmo2 = Config.Bind("InfiniteAmmoSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Invisibility = Config.Bind("InvisibilitySettings", "Enable", true, localizationManager.Cfg_GetString("Invisibility"));
- Invisibility2 = Config.Bind("InvisibilitySettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
-
- Boss = Config.Bind("BossSetting", "Enable", true, localizationManager.Cfg_GetString("Boss"));
- Boss2 = Config.Bind("BossSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Jetpack = Config.Bind("JetpackSetting", "Enable", true, localizationManager.Cfg_GetString("Jetpack"));
- Jetpack2 = Config.Bind("JetpackSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- //PlayerCarryWeight = Config.Bind("PlayerCarryWeightSetting", "Enable", true, localizationManager.Cfg_GetString("PlayerCarryWeight"));
- //PlayerCarryWeight2 = Config.Bind("PlayerCarryWeightSetting", "Recovery", false, localizationManager.Cfg_GetString("PlayerCarryWeight2"));
- //PlayerCarryWeight3 = Config.Bind("PlayerCarryWeightSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Landmine = Config.Bind("LandmineSetting", "Enable", true, localizationManager.Cfg_GetString("Landmine"));
- Landmine2 = Config.Bind("LandmineSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- SpawnWebTrap = Config.Bind("SpawnWebTrapSetting", "Enable", true, localizationManager.Cfg_GetString("SpawnWebTrap"));
- SpawnWebTrap2 = Config.Bind("SpawnWebTrapSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Enemy = Config.Bind("EnemySetting", "Enable", true, localizationManager.Cfg_GetString("Enemy"));
-
- KillEnemy = Config.Bind("KillEnemySetting", "Enable", true, localizationManager.Cfg_GetString("KillEnemy"));
- KillEnemy2 = Config.Bind("KillEnemySetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Map = Config.Bind("MapSetting", "Enable", true, localizationManager.Cfg_GetString("Map"));
- Map2 = Config.Bind("MapSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- GrabObject = Config.Bind("GrabObjectSetting", "Enable", true, localizationManager.Cfg_GetString("GrabObject"));
- GrabObject_MoreSlot = Config.Bind("GrabObjectSetting", "MoreSlot", true, localizationManager.Cfg_GetString("GrabObject_MoreSlot"));
- GrabObject_TwoHand = Config.Bind("GrabObjectSetting", "TwoHand", true, localizationManager.Cfg_GetString("GrabObject_TwoHand"));
- GrabObject_BeltBag = Config.Bind("GrabObjectSetting", "BeltBag", true, localizationManager.Cfg_GetString("GrabObject_BeltBag"));
- GrabObject_Kick = Config.Bind("GrabObjectSetting", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Shovel = Config.Bind("ShovelSettings", "Enable", true, localizationManager.Cfg_GetString("Shovel"));
- Shovel3 = Config.Bind("ShovelSettings", "EmptyHand", false, localizationManager.Cfg_GetString("Shovel2"));
- Shovel2 = Config.Bind("ShovelSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- Nameless = Config.Bind("NamelessSettings", "Enable", true, localizationManager.Cfg_GetString("Nameless"));
- Nameless2 = Config.Bind("NamelessSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- FreeBuy = Config.Bind("FreeBuySettings", "Enable", true, localizationManager.Cfg_GetString("FreeBuy"));
- FreeBuy2 = Config.Bind("FreeBuySettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- RemoteTerminal = Config.Bind("RemoteTerminalSettings", "Enable", true, localizationManager.Cfg_GetString("RemoteTerminal"));
- RemoteTerminal2 = Config.Bind("RemoteTerminalSettings", "Kick", false, localizationManager.Cfg_GetString("Kick"));
-
- PlayerJoin = Config.Bind("MsgSettings", "PlayerJoinShip", localizationManager.Msg_GetString("wlc_player"), localizationManager.Msg_GetString("wlc_player"));
- CooldownManager.Reset();
- CooldownManager.RegisterCooldownGroup(
- "TerminalNoise",
- () => AntiCheat.TerminalNoise.Value,
- () => AntiCheat.TerminalNoise_Cooldown.Value / 1000f
- );
- CooldownManager.RegisterCooldownGroup(
- "ShipLight",
- () => AntiCheat.ShipLight.Value,
- () => AntiCheat.ShipLight_Cooldown.Value / 1000f
- );
- CooldownManager.RegisterCooldownGroup(
- "Chat",
- () => AntiCheat.ChatReal.Value,
- () => AntiCheat.ChatReal_Cooldown.Value / 1000f
- );
- LogInfo($"{localizationManager.Log_GetString("load")}");
- }
-
- }
-}
diff --git a/AntiCheat/FeatureConfig.cs b/AntiCheat/FeatureConfig.cs
new file mode 100644
index 0000000..e1c603b
--- /dev/null
+++ b/AntiCheat/FeatureConfig.cs
@@ -0,0 +1,39 @@
+using BepInEx.Configuration;
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace AntiCheat
+{
+ internal class FeatureConfig
+ {
+ private ConfigEntry _Enable { get; }
+ private ConfigEntry? _Kick { get; }
+
+ public bool Enable => _Enable.Value;
+
+ public bool Kick => _Kick?.Value ?? false;
+
+ public FeatureConfig(
+ ConfigFile config,
+ string section,
+ string enableDesc,
+ bool defaultEnable = true,
+ bool hasKick = true)
+ {
+ _Enable = config.Bind(section,
+ "Enable",
+ defaultEnable,
+ enableDesc);
+
+ if (hasKick)
+ {
+ _Kick = config.Bind(section,
+ "Kick",
+ false,
+ localizationManager.Cfg_GetString("Kick"));
+ }
+ }
+ }
+}
diff --git a/AntiCheat/Lang/en_US.json b/AntiCheat/Lang/en_US.json
deleted file mode 100644
index 7ee4c66..0000000
--- a/AntiCheat/Lang/en_US.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "Config": {
- "Boss": "Detects when a player attempts to force the company monster to attack.",
- "ChangToFreeMoon": "Detects when a player routing moon from priced to free",
- "ChatReal": "Detects when a player attempts to spoof their name as another player's.",
- "Cooldown": "Cooldown time. (in ms)",
- "DespawnItem": "Detects when items are unusually destroyed or deleted.",
- "DetectedMessageType": "Decide detection message display type, PublicChat = Shown for everyone, HostChat = Will only display in chat for the host, GUI = Display in GUI.",
- "Enemy": "Detects when a monster behaves abnormally.",
- "FreeBuy": "Detects when a player ordering items without spending credits.",
- "Gift": "Detects when a player having abnormal gift box interactions.",
- "GrabObject": "Detects picking up items outside of default grab range.",
- "GrabObject_BeltBag": "Disables players from picking up scrap with belt bags",
- "GrabObject_MoreSlot": "Prevents players from picking up more than 4 items",
- "GrabObject_TwoHand": "Prevents players from picking up multiple two-handed items at once",
- "Health_Recover": "Detects when a player using negative damage to regen health",
- "InfiniteAmmo": "Detects when a player has infinite ammo. Note that if a shotgun has already been given infinite ammo, a normal player using it may cause them to be detected as using infinite ammo as well.",
- "Invisibility": "Detects invisible players.",
- "ItemCooldown": "Detects when a player uses an item faster than they should.",
- "Jetpack": "Detects when a player forces a jetpack explosion.",
- "Kick": "Kick player when this behavior is detected.",
- "KillEnemy": "Detects when an enemy is instantly killed.",
- "Landmine": "Detects when a player abnormally detonates a landmine.",
- "Log": "Show logs.",
- "Map": "Detects the use of mini-map mods.",
- "Mask": "Detects when masked enemies are spawned abnormally.",
- "Nameless": "Detects invalid or anomalous player names such as Nameless or Unknown.",
- "NetworkSetting": "Ignore network configuration differences and try to avoid 'an error occurred' dialog.",
- "OperationLog": "Logging action made by the client.",
- "PlayerCarryWeight": "Detecting abnormal player carry weight.",
- "PlayerCarryWeight2": "Restore player carry weight.",
- "Prefix": "Puts text in square brackets before the lobby name, leave empty to disable.",
- "RemoteTerminal": "Detects when a player uses the terminal remotely.",
- "RPCReport_Delay": "RPC report grace period, decide how many time passed everytime the clients have to report the RPC. (in ms)",
- "RPCReport_Hit": "Enable Hit RPC report, when someone takes damage without reporting health lose, they will be detected. (invincibility detection)",
- "RPCReport_KillPlayer": "Enable KillPlayer RPC report, when someone dead but not reporting by themself after that, they will be detected. (invincibility detection)",
- "ShipBuild": "Detects the abnormal placement of furniture.",
- "ShipConfig2": "Clients can only pull the lever when this player count is reached. (StartGameOnlyHost must be set to false)",
- "ShipConfig3": "Clients can take off after this in-game time.",
- "ShipConfig4": "Clients can take off when the number of living players in the ship is equal or greater than the specified percentage. (0-100%)",
- "ShipConfig5": "Detects when a player attempts to force the ship lever. Kicks the player if detected.",
- "ShipConfig6": "Allow your single vote to instantly force the autopilot when as host.",
- "ShipLight": "Enable ship light switch cooldown.",
- "ShipSetting": "Only the host may land the ship.",
- "ShipTerminal": "Enable terminal noise sound cooldown.",
- "Shovel": "Detects unusual shovel damage.",
- "Shovel2": "Allow players to deal damage without a weapon. Note that some mods that can reverses hotbar scrolling can also cause items to be out of sync.",
- "SpawnWebTrap": "Detects when a player tries to spawn spiderwebs.",
- "Turret": "Detects when a player forces a turret to go berserk."
- },
- "Item": {
- "Knife": "Kitchen Knife",
- "Shotgun": "Shotgun",
- "Shovel": "Shovel",
- "Cruiser": "Cruiser"
- },
- "log": {
- "load": "AntiCheat mod is loaded!",
- "refuse_connect": "{steamId} attempted to connect to the game but was refused! (Already kicked)"
- },
- "Message": {
- "behind_player": "[{player}] was left behind.",
- "Boss": "{player} detected attempting to force the company monster to attack!",
- "ChangeLevel": "{player} was detected routing moon from priced to free! (Insufficient permissions)",
- "ChangeToFreeLevel": "{player} was detected routing moon from priced to free!",
- "ChatReal": "{player} tried to spoof {player2}'s name in chat!",
- "DespawnItem": "{player} was detected destroying items!",
- "Enemy_ChangeOwnershipOfEnemy": "{player} was detected trying to alter a monster's behavior!",
- "Enemy_SwitchToBehaviour": "{player} was detected trying to alter a monster's state!",
- "FreeBuy_Item": "{player} was detected buying an item for free!",
- "FreeBuy_Level": "{player} was detected routing to a priced moon for free!",
- "FreeBuy_SetMoney": "{player} was detected modifying crew credits! ({Money})!",
- "FreeBuy_unlockable": "{player} was detected buying a ship unlockable for free!",
- "game_start": "Anti-Cheat (v{ver}) is enabled in this lobby",
- "Gift": "{player} was detected causing a gift box to behave abnormally!",
- "GrabObject": "{player} was detected grabbing objects from too far away! (Player coordinates: {player_position}|Item coordinates: {object_position})",
- "Health_Recover": "{player} was detected regenerating health ({hp})!",
- "InfiniteAmmo": "{player} was detected using infinite ammo weapon!",
- "Invisibility": "{player} was detected to be invisible! (Player coordinates: {player_position})",
- "ItemCooldown": "{player} was detected using an item faster than its cooldown would allow!",
- "Jetpack": "{player} was detected forcing a jetpack explosion!",
- "Kick": "{player} was kicked!",
- "KickPlayer": "A cheat was detected",
- "KillEnemy": "{player} was detected killing a monster instantly! ({enemyName}, monster HP before: {HP})",
- "Landmine": "{player} was detected forcing a landmine explosion!",
- "Map": "{player} was detected to have a mini-map mod!",
- "Mask": "{player} was detected to have spawned Masked enemies abnormally!",
- "Nameless": "{player} was detected to have an anomalous or invalid name!",
- "KickReasonNameLess": "The host is unable to load your in-game name.\r\nPlease ensure your in-game name is not pure numbers/characters.",
- "PlayerCarryWeight": "{player} was detected abnormal carry weight!",
- "PlayerCarryWeight_Recovery": "Carry weights have been forcibly restored!",
- "RemoteTerminal": "{player} was detected using the terminal remotely!",
- "RPCReport": "{player} was detected not reporting {RPC} RPC!",
- "ShipBuild": "{player} was detected placing furniture in an abnormal position! ({position})",
- "ShipConfig2": "{player}, please wait until the number of people in the ship has reached {cfg} or more before pulling the lever, thanks!",
- "ShipConfig4": "{player}, please wait until the number of people in the ship has reached {player_count}({cfg4}%) and the time has reached {cfg3} to depart. (current time: {game_time})",
- "ShipConfig5": "{player} was detected attempting to force the ship lever!",
- "ShipTerminal": "{player} was detected making too much terminal noise!",
- "Shovel": "{player} was detected dealing abnormal damage to {player2} with a {item}! ({damageAmount})",
- "Shovel2": "{player} was detected with abnormal shovel range, and damaged {player2}! ({damageAmount})",
- "Shovel3": "{player} was detected damaging {player2} with no weapon! ({damageAmount})",
- "Shovel4": "{player} was detected dealing abnormal damage to {enemyName} with a {item}! ({damageAmount})",
- "Shovel5": "{player} was detected with abnormal shovel range, and damaged {enemyName}! ({damageAmount})",
- "Shovel6": "{player} was detected damaging [enemyName} with no weapon! ({damageAmount})",
- "snc_player": "[{player}] New creature data sent to terminal! ({enemy})",
- "Turret": "{player} was detected causing a turret to go berserk! (distance: {Distance})",
- "Turret2": "{player} was detected causing a turret to go berserk without a weapon!",
- "Kick_Nameless": "Your Steam name did not load correctly.",
- "vote": "You are the host, your vote can force the autopilot.",
- "vote_player": "{player} voted for the ship to leave early. ({now}/{max})",
- "wlc_player": "[{player}] joined the ship."
- },
- "OperationLog": {
- "BuyItem": "[ActionLog] {player} purchased {items}",
- "BuyShipUnlockable": "[ActionLog] {player} purchased {unlockable}",
- "ChangeLevel": "[ActionLog] {player} routed to moon {planet}",
- "GrabLungProp": "[ActionLog] {player} pull the apparatus",
- "JoinLobby": "{player} is joining..."
- },
- "MessageFormat": "{Prefix} {msg}",
- "Prefix": "[AC]"
-}
diff --git a/AntiCheat/Lang/ko_KR.json b/AntiCheat/Lang/ko_KR.json
deleted file mode 100644
index 57c658a..0000000
--- a/AntiCheat/Lang/ko_KR.json
+++ /dev/null
@@ -1,121 +0,0 @@
-{
- "Config": {
- "Boss": "플레이어가 회사 몬스터를 강제로 공격하게 하려고 시도할 때 이를 감지합니다.",
- "ChangToFreeMoon": "플레이어가 유료 달을 무료 달로 변경하는 것을 감지합니다",
- "ChatReal": "플레이어가 다른 플레이어의 이름으로 속이려고 할 때 이를 감지합니다.",
- "Cooldown": "쿨타임(밀리초 단위)",
- "DespawnItem": "아이템이 비정상적으로 파괴되거나 삭제될 때 이를 감지합니다.",
- "DetectedMessageType": "메시지 표시 유형을 감지합니다. PublicChat = 방 공개 채팅에 표시, HostChat = 호스트만 채팅에 표시, GUI = GUI 인터페이스에 표시",
- "Enemy": "몬스터가 비정상적으로 행동할 때 이를 감지합니다.",
- "FreeBuy": "플레이어가 무료로 아이템을 주문하는것을 감지합니다.",
- "Gift": "플레이어가 선물 상자를 여러번 사용하는걸 감지합니다.",
- "GrabObject": "기본 잡기 범위 밖에서 아이템을 집을 때 이를 감지합니다.",
- "GrabObject_BeltBag": "플레이어가 벨트 가방으로 스크랩을 집는 것을 비활성화합니다. (가방모드 비활성화)",
- "GrabObject_MoreSlot": "플레이어가 4개 이상의 아이템을 집는 것을 방지합니다.",
- "GrabObject_TwoHand": "플레이어가 동시에 여러 개의 양손 아이템을 집는 것을 방지합니다. (양손모드 비활성화)",
- "Health_Recover": "플레이어가 음수 피해를 사용하여 체력을 회복할 때 이를 감지합니다. (healthstation같은거 비활성화)",
- "NetworkSetting": "핑 차이를 무시하고 \"an error occurred\"메세지가 안나오게 합니다.",
- "InfiniteAmmo": "플레이어가 무한 탄약을 사용할 때 이를 감지합니다. 참고: 이미 무한 탄약이 주어진 샷건을 사용하는 정상적인 플레이어도 무한 탄약을 사용하는 것으로 감지될 수 있습니다.",
- "Invisibility": "보이지 않는 플레이어를 감지합니다.",
- "ItemCooldown": "플레이어가 아이템을 너무 빨리 사용할 때 이를 감지합니다.",
- "Jetpack": "플레이어가 제트팩 폭발을 강제할 때 이를 감지합니다.",
- "Kick": "이 행동이 감지되면 플레이어를 킥합니다.",
- "KillEnemy": "적이 즉시 죽을 때 이를 감지합니다. 삽의 공격력을 100이 아닙니다!!!",
- "Landmine": "플레이어가 비정상적으로 지뢰를 폭발시킬 때 이를 감지합니다.",
- "Log": "로그를 표시합니다.",
- "Map": "미니맵 모드를 사용할 때 이를 감지합니다.",
- "Mask": "가면을 쓴 적이 비정상적으로 생성될 때 이를 감지합니다.",
- "Nameless": "이름이 없거나 알 수 없는 플레이어 이름을 감지합니다.",
- "OperationLog": "클라이언트 측 플레이어 행동 로그",
- "PlayerCarryWeight": "플레이어의 비정상적인 운반 무게를 감지합니다.",
- "PlayerCarryWeight2": "플레이어의 운반 무게를 복원합니다.",
- "Prefix": "로비 이름 앞에 괄호로 텍스트를 넣습니다. 비활성화하려면 비워 두세요.",
- "RemoteTerminal": "플레이어가 원격으로 터미널을 사용할 때 이를 감지합니다.",
- "RPCReport_Delay": "RPC 보고 감지 지연, 플레이어가 이 시간 후에 RPC를 보고하는지 감지합니다 (밀리초 단위)",
- "RPCReport_Hit": "hit RPC 보고 감지, 플레이어가 공격을 받고 피를 흘리지 않는 경우 감지됩니다 (무적 감지)",
- "RPCReport_KillPlayer": "KillPlayer RPC 보고 감지, 플레이어가 죽었지만 죽음을 보고하지 않는 경우 감지됩니다 (무적 감지)",
- "ShipBuild": "비정상적으로 배치되는걸 감지합니다.",
- "ShipConfig2": "이 플레이어 수에 도달하면 클라이언트가 레버를 당길 수 있습니다. (StartGameOnlyHost가 false로 설정되어야 합니다.)",
- "ShipConfig3": "이 게임 시간이 지나면 클라이언트가 이륙할 수 있습니다.",
- "ShipConfig4": "함선에 있는 생존 플레이어 수가 지정된 비율 이상일 때 클라이언트가 이륙할 수 있습니다. (0-100%)",
- "ShipConfig5": "플레이어가 함선 레버를 강제로 작동시키려고 할 때 이를 감지합니다. 감지되면 플레이어를 킥합니다.",
- "ShipConfig6": "호스트로서 단일 투표로 자동 조종을 즉시 강제할 수 있습니다.",
- "ShipLight": "함선 조명 냉각시간",
- "ShipSetting": "호스트만이 함선을 착륙시킬 수 있습니다.",
- "ShipTerminal": "터미널 소음사용하여 시끄럽게 할 때 이를 감지합니다.",
- "Shovel": "비정상적인 삽 피해를 감지합니다.",
- "Shovel2": "플레이어가 무기 없이 피해를 입힐 수 있도록 허용합니다. 네트워크 비동기화로 인해 다른 플레이어의 활성 인벤토리 슬롯이 비동기화될 수 있습니다.",
- "SpawnWebTrap": "플레이어가 거미줄을 생성하려고 할 때 이를 감지합니다.",
- "Turret": "플레이어가 터렛을 폭주시키려고 할 때 이를 감지합니다."
- },
- "Item": {
- "Knife": "칼",
- "Shotgun": "샷건",
- "Shovel": "삽",
- "Cruiser": "크루저"
- },
- "Log": {
- "load": "AntiCheat 모드 로드 성공!",
- "refuse_connect": "{steamId}가 게임에 접속을 시도했으나 거부되었습니다! (이미 킥됨)"
- },
- "Message": {
- "behind_player": "[{player}] 가 버려졌습니다.",
- "Boss": "{player} 님이 회사 몬스터를 강제로 공격하게 하려고 시도하는 것이 감지되었습니다!",
- "ChangeLevel": "{player} 님이 유료 달을 무료 달로 변경하려고 시도하는 것이 감지되었습니다! (이 행동은 호스트에게만 허용됩니다!)",
- "ChangeToFreeLevel": "{player} 님이 유료 달을 무료 달로 바꾸는 것이 감지되었습니다!",
- "ChatReal": "{player} 님이 {player2}의 이름으로 채팅을 속이려고 시도했습니다!",
- "DespawnItem": "{player} 님이 아이템을 파괴하는 것이 감지되었습니다!",
- "Enemy_ChangeOwnershipOfEnemy": "{player} 님이 몬스터의 행동을 변경하려고 시도하는 것이 감지되었습니다!",
- "Enemy_SwitchToBehaviour": "{player} 님이 몬스터의 상태를 변경하려고 시도하는 것이 감지되었습니다!",
- "FreeBuy_Item": "{player} 님이 무료로 아이템을 구매하는 것이 감지되었습니다!",
- "FreeBuy_Level": "{player} 님이 유료 달로 무료로 이동하려고 시도하는 것이 감지되었습니다!",
- "FreeBuy_SetMoney": "{player} 님이 함선의 돈을 수정하는 것이 감지되었습니다! ({Money})!",
- "FreeBuy_unlockable": "{player} 님이 부적절한 물건을 구매하는것이 감지되었습니다",
- "game_start": "이 로비에서 Anti-Cheat (v{ver})가 활성화되었습니다",
- "Gift": "{player} 님이 선물 상자를 비정상적으로 작동시키는 것이 감지되었습니다!",
- "GrabObject": "{player} 님이 너무 멀리서 아이템을 집는 것이 감지되었습니다! (플레이어 좌표: {player_position}|아이템 좌표: {object_position})",
- "Health_Recover": "{player} 님이 체력을 회복하는 것이 감지되었습니다 ({hp})!",
- "InfiniteAmmo": "{player} 님이 무한 탄약을 사용하는 것이 감지되었습니다!",
- "Invisibility": "{player} 님이 보이지 않는 상태인 것이 감지되었습니다! (플레이어 좌표: {player_position})",
- "ItemCooldown": "{player} 님이 아이템을 너무 빨리 사용하는 것이 감지되었습니다!",
- "Jetpack": "{player} 님이 제트팩 폭발을 강제하는 것이 감지되었습니다!",
- "Kick": "{player} 님이 킥되었습니다!",
- "KickPlayer": "치트가 감지되었습니다",
- "KillEnemy": "{player} 님이 몬스터를 즉시 죽이는 것이 감지되었습니다! ({enemyName}, 몬스터 HP 이전: {HP})",
- "Landmine": "{player} 님이 지뢰를 강제로 폭발시키는 것이 감지되었습니다!",
- "Map": "{player} 님이 미니맵 모드를 사용하는 것이 감지되었습니다!",
- "Mask": "{player} 님이 가면을 쓴 적을 비정상적으로 생성하는 것이 감지되었습니다!",
- "Nameless": "{player} 님이 이름이 없거나 알 수 없는 이름을 사용하는 것이 감지되었습니다!",
- "KickReasonNameLess": "호스트가 당신의 게임 이름을 로드할 수 없습니다. 다시 방에 참가해 보세요\r\n이름이 순수 숫자/순수 문자가 아닌지 확인하세요",
- "PlayerCarryWeight": "{player} 님이 비정상적인 운반 무게를 사용하는 것이 감지되었습니다!",
- "PlayerCarryWeight_Recovery": "운반 무게가 강제로 복원되었습니다!",
- "RemoteTerminal": "{player} 님이 원격으로 터미널을 사용하는 것이 감지되었습니다!",
- "RPCReport": "{player} 님이 {RPC} RPC를 보고하지 않는 것이 감지되었습니다!",
- "ShipBuild": "{player} 님이 가구를 비정상적인 위치에 배치하는 것이 감지되었습니다! ({position})",
- "ShipConfig2": "{player}, 레버를 당기기 전에 함선에 있는 사람 수가 {cfg} 이상이 될 때까지 기다려 주세요, 감사합니다!",
- "ShipConfig4": "{player}, 함선에 있는 사람 수가 {player_count}({cfg4}%) 이상이고 시간이 {cfg3}에 도달할 때까지 기다려 주세요. (현재 시간: {game_time})",
- "ShipConfig5": "{player} 님이 함선 레버를 강제로 작동시키려고 시도하는 것이 감지되었습니다!",
- "ShipTerminal": "{player} 님이 터미널 소음을 너무 많이 내는 것이 감지되었습니다!",
- "Shovel": "{player} 님이 {player2}에게 {item}으로 비정상적인 피해를 입히는 것이 감지되었습니다! ({damageAmount})",
- "Shovel2": "{player} 님이 비정상적인 삽 범위로 {player2}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})",
- "Shovel3": "{player} 님이 무기 없이 {player2}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})",
- "Shovel4": "{player} 님이 {enemyName}에게 {item}으로 비정상적인 피해를 입히는 것이 감지되었습니다! ({damageAmount})",
- "Shovel5": "{player} 님이 비정상적인 삽 범위로 {enemyName}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})",
- "Shovel6": "{player} 님이 무기 없이 {enemyName}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})",
- "snc_player": "[{player}] 터미널에 새로운 생물 데이터를 보냈습니다! ",
- "Turret": "{player} 님이 터렛을 폭주시키는 것이 감지되었습니다! (거리: {Distance})",
- "Turret2": "{player} 님이 무기 없이 터렛을 폭주시키는 것이 감지되었습니다!",
- "vote": "당신은 호스트입니다, 다른사람의 투표를 강제할수 있습니다.",
- "vote_player": "{player} 님이 함선의 조기 출발을 위해 투표했습니다. ({now}/{max})",
- "wlc_player": "{player}이/가 입장했습니다"
- },
- "OperationLog": {
- "BuyItem": "[행동 로그] {player} 님이 {items}를 구매했습니다",
- "BuyShipUnlockable": "[행동 로그] {player} 님이 {unlockable}를 구매했습니다",
- "ChangeLevel": "[행동 로그] {player} 님이 달 {planet}로 라우팅했습니다",
- "GrabLungProp": "[행동 로그] {player} 님이 코어를 제거했습니다",
- "JoinLobby": "{player} 님이 참가 중..."
- },
- "MessageFormat": "{Prefix} {msg}",
- "Prefix": "[AC]"
-}
diff --git a/AntiCheat/Lang/localization_cfg.json b/AntiCheat/Lang/localization_cfg.json
deleted file mode 100644
index 924f32d..0000000
--- a/AntiCheat/Lang/localization_cfg.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "current_language": "",
- "support_language": {
- "zh_CN": "中文(简体)",
- "ko_KR": "한국어",
- "en_US": "English"
- }
-}
\ No newline at end of file
diff --git a/AntiCheat/Lang/zh_CN.json b/AntiCheat/Lang/zh_CN.json
deleted file mode 100644
index ff47430..0000000
--- a/AntiCheat/Lang/zh_CN.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "Config": {
- "Boss": "召唤老板检测",
- "ChangToFreeMoon": "检测玩家将 付费星球 切换至 免费星球",
- "ChatReal": "发言伪造检测",
- "Cooldown": "冷却时间(以毫秒为单位)",
- "DespawnItem": "销毁物品检测",
- "DetectedMessageType": "决定检测消息显示类型,PublicChat = 对所有人显示,HostChat = 仅在主机的聊天中显示,GUI = 在 GUI 界面中显示",
- "Enemy": "怪物异常检测",
- "FreeBuy": "零元购检测",
- "Gift": "刷礼物盒检测",
- "GrabObject": "隔空取物检测",
- "GrabObject_BeltBag": "禁止玩家用腰包拾取废料",
- "GrabObject_MoreSlot": "禁止玩家拾取超出四个物品",
- "GrabObject_TwoHand": "禁止玩家同时拾取多个双手物品",
- "Health_Recover": "玩家回血检测(使用负伤害回血)",
- "NetworkSetting": "忽略网络配置差异,并尝试避免出现 发生错误 对话框",
- "InfiniteAmmo": "无限子弹检测",
- "Invisibility": "隐身检测",
- "ItemCooldown": "物品使用冷却异常检测",
- "Jetpack": "喷气背包爆炸检测",
- "Kick": "检测到该行为时踢出玩家",
- "KillEnemy": "秒杀敌人检测",
- "Landmine": "引爆地雷检测",
- "Log": "显示控制台日志",
- "Map": "小地图检测",
- "Mask": "刷假人检测",
- "Nameless": "玩家名字检测(Nameless或Unknown)",
- "OperationLog": "客户端玩家操作记录",
- "PlayerCarryWeight": "玩家异常负重检测",
- "PlayerCarryWeight2": "强制恢复玩家负重",
- "Prefix": "设置房间名前缀,使用空值代表不启用前缀",
- "RemoteTerminal": "远程终端检测",
- "RPCReport_Delay": "RPC 报告宽限期,决定客户端每次必须报告 RPC 时经过的时间。(以毫秒为单位)",
- "RPCReport_Hit": "启用Hit RPC报告,当有人受到伤害但未报告生命值损失时,则会被检测(无敌检测)",
- "RPCReport_KillPlayer": "启用KillPlayer RPC报告,当有人死亡但之后没有自己报告时,则会被检测(无敌检测)",
- "ShipBuild": "飞船物品位置异常检测",
- "ShipConfig2": "非房主只有在超过指定人数才能进行着陆(需要关闭房主权限)",
- "ShipConfig3": "非房主只有在该时间点以后才能起飞",
- "ShipConfig4": "非房主只有在当飞船存活人数超过总存活人数时才能起飞(0-100%)",
- "ShipConfig5": "检测强制拉杆行为(检测到该行为时踢出玩家)",
- "ShipConfig6": "作为房主,你可以一票起飞",
- "ShipLight": "飞船灯关冷却",
- "ShipSetting": "只有房主才有着陆权限",
- "ShipTerminal": "终端噪音冷却",
- "Shovel": "铲子伤害检测",
- "Shovel2": "允许玩家空手时能造成正常伤害(网络延迟可能会导致玩家空手)",
- "SpawnWebTrap": "刷蜘蛛网检测",
- "Turret": "激怒机枪检测"
- },
- "Item": {
- "Knife": "小刀",
- "Shotgun": "霰弹枪",
- "Shovel": "铲子",
- "Cruiser": "卡车"
- },
- "Log": {
- "load": "反作弊模组已加载完毕!",
- "refuse_connect": "{steamId} 尝试重连游戏被拒绝(已被踢出)!"
- },
- "Message": {
- "behind_player": "[{player}] 被抛弃了",
- "Boss": "检测到玩家 {player} 召唤老板!",
- "ChangeLevel": "检测 {player} 将付费星球改为免费星球!(这个行为只有房主才被允许!)",
- "ChangeToFreeLevel": "检测到玩家 {player} 将 付费星球 切换至 免费星球",
- "ChatReal": "检测到玩家 {player} 尝试伪装成 {player2} 发言!",
- "DespawnItem": "检测到玩家 {player} 销毁物品 ({item})!",
- "Enemy_ChangeOwnershipOfEnemy": "检测到玩家 {player} 强制改变怪物仇恨!",
- "Enemy_SwitchToBehaviour": "检测到玩家 {player} 强制改变怪物状态!",
- "FreeBuy_Item": "检测到玩家 {player} 强制购买 {items} 物品!",
- "FreeBuy_Level": "检测到玩家 {player} 强制切换付费星球!",
- "FreeBuy_SetMoney": "检测到玩家 {player} 修改金钱({Money})!",
- "FreeBuy_unlockable": "检测到玩家 {player} 强制解锁飞船装饰!",
- "game_start": "本房间启用反作弊(v{ver})",
- "Gift": "检测到玩家 {player} 刷礼物盒!",
- "GrabObject": "检测到玩家 {player} 隔空取物!(玩家坐标:{player_position}|物品坐标:{object_position})",
- "Health_Recover": "检测到玩家 {player} 回复生命值({hp})!",
- "InfiniteAmmo": "检测到玩家 {player} 正使用无限子弹!",
- "Invisibility": "检测到玩家 {player} 坐标异常!(玩家坐标:{player_position})",
- "ItemCooldown": "检测到玩家 {player} 使用 {item} 频率异常!",
- "Jetpack": "检测到玩家 {player} 引爆喷气背包!",
- "Kick": "{player} 已被踢出",
- "KickPlayer": "检测到作弊行为",
- "KillEnemy": "检测到玩家 {player} 秒杀怪物!( {enemyName} ,剩余血量:{HP})",
- "Landmine": "检测到玩家 {player} 强制引爆地雷!",
- "Map": "检测到玩家 {player} 使用小地图!",
- "Mask": "检测到玩家 {player} 刷假人!",
- "Nameless": "检测到玩家名称异常!",
- "KickReasonNameLess": "房主无法加载你的游戏名称,你可以尝试重新加入房间\r\n请确保你的名称不是纯数字/纯字符",
- "PlayerCarryWeight": "检测到玩家 {player} 负重异常!",
- "PlayerCarryWeight_Recovery": "异常负重已被恢复!",
- "RemoteTerminal": "检测到玩家 {player} 使用远程终端!",
- "RPCReport": "检测到玩家 {player} 未上报 {RPC} RPC!",
- "ShipBuild": "检测到玩家 {player} 将飞船物品({object})摆放到异常位置({position})!",
- "ShipConfig2": "{player} 请等待飞船人数达到 {cfg} 以上再拉杆,谢谢!",
- "ShipConfig4": "{player} 请等待飞船人数达到 {player_count}({cfg4}%) 并且 游戏时间在 {cfg3} 之后起飞(当前时间:{game_time})",
- "ShipConfig5": "检测到玩家 {player} 强制拉杆!",
- "ShipTerminal": "检测到玩家 {player} 频繁制造噪音!",
- "Shovel": "检测到玩家 {player} 使用{item}对玩家 {player2} 造成异常伤害!({damageAmount})",
- "Shovel2": "检测到玩家 {player} {item}范围异常,对玩家 {player2} 造成伤害!({distance},{damageAmount})",
- "Shovel3": "检测到玩家 {player} 空手对玩家 {player2} 造成伤害!({damageAmount})",
- "Shovel4": "检测到玩家 {player} 使用{item}对敌人 {enemyName} 造成异常伤害!({damageAmount})",
- "Shovel5": "检测到玩家 {player} {item}范围异常,对敌人 {enemyName} 造成伤害!({damageAmount})",
- "Shovel6": "检测到玩家 {player} 空手对敌人 {enemyName} 造成伤害!({damageAmount})",
- "snc_player": "[{player}] 新的生物数据已发送至终端!({enemy})",
- "Turret": "检测玩家 {player} 强制激怒机枪!(距离:{Distance})",
- "Turret2": "检测玩家 {player} 强制激怒机枪(空手)!",
- "Kick_Nameless": "你的Steam名称未正确加载(如果你是纯数字名称,请更改名称)",
- "vote": "你是房主,投票直接起飞!",
- "vote_player": "{player} 投票让飞船提前离开({now}/{max})",
- "wlc_player": "欢迎 {player} 加入飞船"
- },
- "OperationLog": {
- "BuyItem": "[操作记录] {player} 购买 {items} 物品",
- "BuyShipUnlockable": "[操作记录] {player} 解锁 {unlockable} 物品",
- "ChangeLevel": "[操作记录] {player} 切换星球 {planet}",
- "GrabLungProp": "[操作记录] {player} 取下了设施电源",
- "JoinLobby": "{player} 加入房间中..."
- },
- "MessageFormat": "{Prefix} {msg}",
- "Prefix": "[反作弊]"
-}
\ No newline at end of file
diff --git a/AntiCheat/Locale/Locale.cs b/AntiCheat/Locale/Locale.cs
index aae9a24..396d2f8 100644
--- a/AntiCheat/Locale/Locale.cs
+++ b/AntiCheat/Locale/Locale.cs
@@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace AntiCheat.Locale
{
public class Locale
{
- public Dictionary Config { get; set; }
+ public Dictionary Config { get; set; }
public Dictionary Item { get; set; }
public Dictionary Log { get; set; }
- public Dictionary Message { get; set; }
- public Dictionary OperationLog { get; set; }
+ public Dictionary Message { get; set; }
+ public Dictionary OperationLog { get; set; }
public string Prefix { get; set; }
public string MessageFormat { get; set; }
}
@@ -21,6 +19,6 @@ public class LocaleCfg
{
public string current_language { get; set; }
- public Dictionary support_language { get; set; }
+ public Dictionary support_language { get; set; }
}
}
diff --git a/AntiCheat/Locale/LocalizationManager.cs b/AntiCheat/Locale/LocalizationManager.cs
index 3383948..fb7f2de 100644
--- a/AntiCheat/Locale/LocalizationManager.cs
+++ b/AntiCheat/Locale/LocalizationManager.cs
@@ -1,16 +1,10 @@
-
-using Newtonsoft.Json;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Resources;
using System.Text;
-using System.Threading.Tasks;
-
-using static AntiCheat.Core.AntiCheat;
namespace AntiCheat.Locale
{
@@ -38,8 +32,8 @@ public LocalizationManager()
{
cfg.current_language = "en_US";
}
- Core.AntiCheat.LogInfo($"no current language set, automatic language selection based on current region");
- Core.AntiCheat.LogInfo($"CurrentCulture:{lang},use language -> {cfg.current_language}");
+ AntiCheatPlugin.LogInfo($"no current language set, automatic language selection based on current region");
+ AntiCheatPlugin.LogInfo($"CurrentCulture:{lang},use language -> {cfg.current_language}");
}
current_language = cfg.current_language;
json = File.ReadAllText($"{Path.Combine(langPath, cfg.current_language)}.json");
@@ -83,7 +77,12 @@ private string ReplacePlaceholders(string input, Dictionary pair
{
if (pairs == null || string.IsNullOrEmpty(input))
return input;
- return pairs.Aggregate(input, (current, item) => current.Replace(item.Key, item.Value));
+ var result = new StringBuilder(input);
+ foreach (var pair in pairs)
+ {
+ result.Replace(pair.Key, pair.Value);
+ }
+ return result.ToString();
}
}
}
diff --git a/AntiCheat/Patch/DoorLockPatch.cs b/AntiCheat/Patch/DoorLockPatch.cs
deleted file mode 100644
index 3a23037..0000000
--- a/AntiCheat/Patch/DoorLockPatch.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using AntiCheat.Core;
-
-using HarmonyLib;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Unity.Netcode;
-
-namespace AntiCheat.Patch
-{
- [HarmonyPatch(typeof(DoorLock))]
- [HarmonyWrapSafe]
- public static class DoorLockPatch
- {
- [HarmonyPatch("__rpc_handler_184554516")]
- [HarmonyPrefix]
- public static bool UnlockDoorServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Patches.Check(rpcParams, out var p))
- {
- AntiCheat.Core.AntiCheat.LogInfo(p, "DoorLock.UnlockDoorServerRpc");
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- [HarmonyPatch("__rpc_handler_2046162111")]
- [HarmonyPrefix]
- public static bool OpenDoorAsEnemyServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Patches.Check(rpcParams, out var p))
- {
- AntiCheat.Core.AntiCheat.LogInfo(p, "DoorLock.OpenDoorAsEnemyServerRpc");
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
- }
-}
diff --git a/AntiCheat/Patch/GrabbableObjectPatch.cs b/AntiCheat/Patch/GrabbableObjectPatch.cs
deleted file mode 100644
index c029797..0000000
--- a/AntiCheat/Patch/GrabbableObjectPatch.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using AntiCheat.Core;
-
-using HarmonyLib;
-
-using Steamworks.Ugc;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Unity.Netcode;
-
-namespace AntiCheat
-{
- [HarmonyPatch(typeof(GrabbableObject))]
- [HarmonyWrapSafe]
- public static class GrabbableObjectPatch
- {
- ///
- /// ActivateItemServerRpc
- ///
- [HarmonyPrefix]
- [HarmonyPatch("__rpc_handler_4280509730")]
- public static bool ActivateItemServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Patches.Check(rpcParams, out var p))
- {
- if (target != null)
- {
- var grab = (GrabbableObject)target;
- if (grab != null)
- {
- if (grab is RemoteProp)
- {
- AntiCheat.Core.AntiCheat.LogInfo(p, $"({grab.itemProperties.itemName})GrabbableObject.ActivateItemServerRpc");
- bool canUse = CooldownManager.CheckCooldown("ShipLight", p);
- if (!canUse)
- {
- UnityEngine.Object.FindFirstObjectByType().SetShipLightsClientRpc(true);
- }
- return canUse;
- }
- }
- }
- else
- {
- return false;
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- [HarmonyPostfix]
- [HarmonyPatch(typeof(GiftBoxItem), "ItemActivate")]
- public static void ItemActivate(GiftBoxItem __instance)
- {
- if (StartOfRound.Instance.IsHost)
- {
- UnityEngine.Object.Destroy(__instance.gameObject);
- }
- }
-
- [HarmonyPrefix]
- [HarmonyPatch("__rpc_handler_3484508350")]
- public static bool SyncBatteryServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p) && false)
- return p != null;
- ByteUnpacker.ReadValueBitPacked(reader, out int num);
- reader.Seek(0);
- GrabbableObject target1 = ((GrabbableObject)target);
- if (target1.itemProperties.requiresBattery)
- {
- AntiCheat.Core.AntiCheat.LogInfo(p, $"({target1.itemProperties.itemName})GrabbableObject.SyncBatteryServerRpc", $"num:{num}");
- if (num > 100)
- {
- return false;
- }
- }
- return true;
- }
-
- ///
- /// EquipItemServerRpc
- ///
- [HarmonyPrefix]
- [HarmonyPatch(typeof(LungProp), "EquipItem")]
- public static bool EquipItem(LungProp __instance)
- {
- if (AntiCheat.Core.AntiCheat.OperationLog.Value)
- {
- if (__instance.isLungDocked && StartOfRound.Instance.shipHasLanded)
- {
- Patches.ShowMessageHostOnly(Patches.locale.OperationLog_GetString("GrabLungProp", new Dictionary() {
- { "{player}", $"{StartOfRound.Instance.allPlayerScripts.First(x => x.OwnerClientId == __instance.OwnerClientId).playerUsername}" }
- }));
- }
- }
- return true;
-
- }
- }
-}
diff --git a/AntiCheat/Patch/HUDManagerPatch.cs b/AntiCheat/Patch/HUDManagerPatch.cs
deleted file mode 100644
index d057b21..0000000
--- a/AntiCheat/Patch/HUDManagerPatch.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using HarmonyLib;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Unity.Netcode;
-
-namespace AntiCheat
-{
- [HarmonyPatch(typeof(HUDManager))]
- [HarmonyWrapSafe]
- public static class HUDManagerPatch
- {
-
- public static List SyncAllPlayerLevelsServerRpcCalls { get; set; } = new List();
-
- ///
- /// GetNewStoryLogServerRpc
- ///
- [HarmonyPrefix]
- [HarmonyPatch("__rpc_handler_3153465849")]
- public static bool GetNewStoryLogServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p))
- return p != null;
- ByteUnpacker.ReadValueBitPacked(reader, out int logID);
- reader.Seek(0);
- var terminal = UnityEngine.Object.FindObjectOfType();
- if (logID < terminal.logEntryFiles.Count && logID > 0)
- {
- return true;
- }
- return false;
- }
-
- ///
- /// SendErrorMessageServerRpc
- ///
- [HarmonyPrefix]
- [HarmonyPatch("__rpc_handler_1043384750")]
- public static bool SendErrorMessageServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- return !Patches.Check(rpcParams, out _);
- }
-
-
- ///
- /// SyncAllPlayerLevelsServerRpc
- ///
- [HarmonyPrefix]
- [HarmonyPatch("__rpc_handler_4217433937")]
- public static bool SyncAllPlayerLevelsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p))
- return p != null;
- if (SyncAllPlayerLevelsServerRpcCalls.Contains(p.playerSteamId))
- {
- return false;
- }
- ByteUnpacker.ReadValueBitPacked(reader, out int _);
- ByteUnpacker.ReadValueBitPacked(reader, out int playerClientId);
- reader.Seek(0);
- if (playerClientId != (int)p.playerClientId)
- {
- return false;
- }
- SyncAllPlayerLevelsServerRpcCalls.Add(p.playerSteamId);
- return true;
- }
-
- ///
- /// ScanNewCreatureServerRpc
- ///
- [HarmonyPatch("__rpc_handler_1944155956")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool ScanNewCreatureServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p))
- return p != null;
- ByteUnpacker.ReadValueBitPacked(reader, out int enemyID);
- reader.Seek(0);
- var terminal = UnityEngine.Object.FindObjectOfType();
- if (enemyID < terminal.enemyFiles.Count && enemyID > 0)
- {
- if (terminal.scannedEnemyIDs.Contains(enemyID) && terminal.newlyScannedEnemyIDs.Contains(enemyID))
- {
- return false;
- }
- string msg = Core.AntiCheat.localizationManager.Msg_GetString("snc_player", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{enemy}",terminal.enemyFiles[enemyID].creatureName }
- });
- Patches.LogInfo(msg);
- return true;
- }
- return false;
- }
-
- ///
- /// 玩家使用信号发射器发送消息
- /// Prefix UseSignalTranslatorServerRpc
- ///
- ///
- [HarmonyPatch("__rpc_handler_2436660286")]
- [HarmonyPrefix]
- public static bool UseSignalTranslatorServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p))
- return p != null;
- if (Core.AntiCheat.RemoteTerminal.Value)
- {
- if (!Patches.CheckRemoteTerminal(p, "HUDManager.UseSignalTranslatorServerRpc"))
- {
- return false;
- }
- }
- return true;
- }
- }
-}
diff --git a/AntiCheat/Patch/LandminePatch.cs b/AntiCheat/Patch/LandminePatch.cs
deleted file mode 100644
index e879135..0000000
--- a/AntiCheat/Patch/LandminePatch.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using HarmonyLib;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using UnityEngine;
-
-namespace AntiCheat.Patch
-{
- [HarmonyPatch(typeof(Landmine))]
- [HarmonyWrapSafe]
- public static class LandminePatch
- {
- [HarmonyPrefix]
- [HarmonyPatch("SpawnExplosion")]
- public static void SpawnExplosion(Vector3 explosionPosition)
- {
- Patches.LogInfo($"Landmine.SpawnExplosion -> {explosionPosition}");
- Patches.explosions = Patches.explosions.Where(x => x.CreateDateTime.AddSeconds(10) > DateTime.Now).ToList();
- Patches.explosions.Add(new Patches.ExplosionData()
- {
- ExplosionPostion = explosionPosition,
- CalledClient = new List(),
- CreateDateTime = DateTime.Now
- });
- }
- }
-}
diff --git a/AntiCheat/Patch/Patches.cs b/AntiCheat/Patch/Patches.cs
deleted file mode 100644
index a85f0a5..0000000
--- a/AntiCheat/Patch/Patches.cs
+++ /dev/null
@@ -1,3099 +0,0 @@
-using AntiCheat.Core;
-using AntiCheat.Patch;
-
-using BepInEx;
-using BepInEx.Configuration;
-
-using GameNetcodeStuff;
-
-using HarmonyLib;
-
-using Netcode.Transports.Facepunch;
-
-using Steamworks;
-using Steamworks.Data;
-using Steamworks.ServerList;
-
-using System;
-using System.CodeDom;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Configuration;
-using System.Diagnostics.Eventing.Reader;
-using System.IO;
-using System.Linq;
-using System.Net.Http.Headers;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Runtime.Remoting.Messaging;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-using TMPro;
-
-using Unity.Collections.LowLevel.Unsafe;
-using Unity.Netcode;
-
-using UnityEngine;
-using UnityEngine.Events;
-
-using static UnityEngine.GraphicsBuffer;
-
-namespace AntiCheat
-{
- public static class Patches
- {
- public static Locale.LocalizationManager locale { get => Core.AntiCheat.localizationManager; }
-
- public static List jcs = new List();
-
- public static Dictionary> czcd = new Dictionary>();
- public static Dictionary> sdqcd = new Dictionary>();
-
- public static Dictionary ConnectionIdtoSteamIdMap { get; set; } = new Dictionary();
-
- //public static Dictionary>> chcs = new Dictionary>>();
-
- public static List mjs { get; set; } = new List();
-
- public static List landMines { get; set; }
-
- public static Dictionary> rpcs { get; set; } = new Dictionary>();
-
- private static Dictionary> recentPlayerPositions = new Dictionary>();
-
- public static void LogInfo(string info) => Core.AntiCheat.LogInfo(info);
-
- public static void LogInfo(PlayerControllerB p, string rpc, params object[] param) => Core.AntiCheat.LogInfo(p, rpc, param);
-
- public static void LogError(string info)
- {
- if (Core.AntiCheat.Log.Value)
- {
- Core.AntiCheat.ManualLog.LogError($"{info}");
- }
- }
-
- ///
- /// PlayerControllerB.KillPlayerServerRpc
- ///
- ///
- ///
- ///
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_4121569671")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_4121569671(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (rpcs.ContainsKey("KillPlayer"))
- {
- rpcs["KillPlayer"].Remove(p.playerClientId);
- }
- ByteUnpacker.ReadValueBitPacked(reader, out int playerId);
- reader.ReadValueSafe(out bool spawnBody, default);
- reader.ReadValueSafe(out Vector3 bodyVelocity);
- ByteUnpacker.ReadValueBitPacked(reader, out int num);
- reader.Seek(0);
- LogInfo(p, "PlayerControllerB.KillPlayerServerRpc", $"playerId:{PlayerClientIdConvertName(playerId)}({playerId})", $"spawnBody:{spawnBody}", $"bodyVelocity:{bodyVelocity}", $"num:{(CauseOfDeath)num}({num})");
- if (playerId < 0)
- {
- LogInfo($"KillPlayerServerRpc:Invalid PlayerId({playerId})");
- return false;
- }
- if (StartOfRound.Instance.allPlayerScripts[playerId] != p)
- {
- LogInfo("KillPlayerServerRpc:Can't kill other player!");
- return false;
- }
- if (p.isPlayerDead)
- {
- LogInfo("KillPlayerServerRpc:Player death can't kill!");
- return false;
- }
- if ((CauseOfDeath)num == CauseOfDeath.Abandoned)
- {
- string msg = locale.Msg_GetString("behind_player", new Dictionary() {
- { "{player}",p.playerUsername }
- });
- LogInfo(msg);
- AddTextMessageClientRpc(msg);
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- ///
- /// Prefix PlayerControllerB.DamagePlayerFromOtherClientServerRpc
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_638895557")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_638895557(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- ByteUnpacker.ReadValueBitPacked(reader, out int damageAmount);
- reader.ReadValueSafe(out Vector3 hitDirection);
- ByteUnpacker.ReadValueBitPacked(reader, out int playerWhoHit);
- reader.Seek(0);
- LogInfo(p, "PlayerControllerB.DamagePlayerFromOtherClientServerRpc", $"damageAmount:{damageAmount}", $"hitDirection:{hitDirection}", $"playerWhoHit:{PlayerClientIdConvertName(playerWhoHit)}({playerWhoHit})");
- var p2 = (PlayerControllerB)target;
- return CheckDamage(p2, p, ref damageAmount);
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// Prefix PlayerControllerB.HealServerRpc
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2585603452")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2585603452(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- LogInfo(p, "PlayerControllerB.HealServerRpc", $"health:{p.health}", $"newHealth:20");
- p.health = 20;
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- private static bool CheckDamage(PlayerControllerB p2, PlayerControllerB p, ref int damageAmount)
- {
- if (damageAmount == 0)
- {
- return true;
- }
- LogInfo($"{p.playerUsername} hit {p2.playerUsername} damageAmount:{damageAmount}|p2:{p2.playerUsername}");
- try
- {
- if (Core.AntiCheat.Shovel.Value)
- {
- var distance = Vector3.Distance(p.transform.position, p2.transform.position);
- var obj = p.ItemSlots[p.currentItemSlot];
- string playerUsername = p.playerUsername;
- if (jcs.Contains(p.playerSteamId))
- {
- damageAmount = 0;
- }
- else if (damageAmount != 20 && obj != null && (isShovel(obj) || isKnife(obj)))
- {
- if (!jcs.Contains(p.playerSteamId))
- {
- ShowMessage(locale.Msg_GetString("Shovel", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{player2}",p2.playerUsername },
- { "{damageAmount}",damageAmount.ToString() },
- { "{item}", isShovel(obj) ? locale.Item_GetString("Shovel") : locale.Item_GetString("Knife") }
- }));
- jcs.Add(p.playerSteamId);
- if (Core.AntiCheat.Shovel2.Value)
- {
- KickPlayer(p);
- }
- }
- damageAmount = 0;
- }
- else if (distance > 11 && obj != null && (isShovel(obj) || isKnife(obj)))
- {
- if (p2.isPlayerDead)
- {
- return true;
- }
- if (!jcs.Contains(p.playerSteamId))
- {
- ShowMessage(locale.Msg_GetString("Shovel2", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{player2}",p2.playerUsername },
- { "{distance}",distance.ToString() },
- { "{damageAmount}",damageAmount.ToString() },
- { "{item}", isShovel(obj) ? locale.Item_GetString("Shovel") : locale.Item_GetString("Knife") }
- }));
- jcs.Add(p.playerSteamId);
- if (Core.AntiCheat.Shovel2.Value)
- {
- KickPlayer(p);
- }
- }
- damageAmount = 0;
- }
- else
- {
- if (ClingTime.ContainsKey(p.playerSteamId) && ClingTime[p.playerSteamId].AddSeconds(5) > DateTime.Now)
- {
- return true;
- }
- if (p.ItemSlots.Any(x => isShovel(x)) && damageAmount == 10)
- {
- return true;
- }
- //for (int i = 0; i <.Length; i++)
- //{
- // LogInfo($"p:{p.playerUsername}|i:{i}|itemName:{p.ItemSlots[i]?.itemProperties?.itemName}");
- //}
- //LogInfo($"currentItemSlot:{p.currentItemSlot}");
- //LogInfo($"currentlyHeldObjectServer:{p.currentlyHeldObjectServer?.itemProperties?.itemName}");
- //LogInfo($"obj:{obj}");
- //if (!jcs.Contains(p.playerSteamId))
- //{
- // if (Core.AntiCheat.Shovel3.Value && (damageAmount == 10 || damageAmount == 20 || damageAmount == 30 || damageAmount == 100))
- // {
- // ShowMessage(locale.Msg_GetString("Shovel3", new Dictionary() {
- // { "{player}",p.playerUsername },
- // { "{player2}",p2.playerUsername },
- // { "{damageAmount}",damageAmount.ToString() }
- // }));
- // return true;
- // }
- // else
- // {
- // ShowMessage(locale.Msg_GetString("Shovel3", new Dictionary() {
- // { "{player}",p.playerUsername },
- // { "{player2}",p2.playerUsername },
- // { "{damageAmount}",damageAmount.ToString() }
- // }));
- // jcs.Add(p.playerSteamId);
- // if (Core.AntiCheat.Shovel2.Value)
- // {
- // KickPlayer(p);
- // }
- // damageAmount = 0;
- // }
- //}
- }
- if (damageAmount == 0)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- }
- catch (Exception ex)
- {
- LogInfo($"{ex.ToString()}");
- }
- return true;
- }
-
-
- //[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")]
- //[HarmonyPrefix]
- //public static bool DamagePlayerFromOtherClientServerRpc(PlayerControllerB __instance, ref int damageAmount, Vector3 hitDirection, int playerWhoHit)
- //{
- // return DamagePlayerFromOtherClientServerRpc(ref damageAmount, playerWhoHit);
- //}
- public static bool isGun(GrabbableObject item)
- {
- return item is ShotgunItem;
- }
-
- public static bool isShovel(GrabbableObject item)
- {
- return item is Shovel;
- }
-
- public static bool isKnife(GrabbableObject item)
- {
- return item is KnifeItem;
- }
-
- public static bool isJetpack(GrabbableObject item)
- {
- return item is JetpackItem;
- }
-
- public static ulong lastClientId { get; set; }
-
-
- //[HarmonyPatch(typeof(StartOfRound), "StartTrackingAllPlayerVoices")]
- //[HarmonyPostfix]
- //[HarmonyWrapSafe]
- //public static void StartTrackingAllPlayerVoices()
- //{
- // if (!StartOfRound.Instance.localPlayerController.IsHost)
- // {
- // return;
- // }
- // foreach (var item in StartOfRound.Instance.allPlayerScripts)
- // {
- // if (!item.isPlayerControlled)
- // {
- // continue;
- // }
- // var playerName = item.playerUsername;
- // if (playerName == "Player #0")
- // {
- // continue;
- // }
- // if (StartOfRound.Instance.KickedClientIds.Contains(item.playerSteamId))
- // {
- // KickPlayer(item);
- // return;
- // }
- // LogInfo(playerName);
- // if (Regex.IsMatch(playerName, "Nameless\\d*") || Regex.IsMatch(playerName, "Unknown\\d*") || Regex.IsMatch(playerName, "Player #\\d*"))
- // {
- // if (Core.AntiCheat.Nameless.Value)
- // {
- // ShowMessage(locale.Msg_GetString("Nameless"));
- // if (Core.AntiCheat.Nameless2.Value)
- // {
- // KickPlayer(item, true, locale.Msg_GetString("Kick_Nameless"));
- // }
- // }
- // }
- // }
- // var p2 = StartOfRound.Instance.allPlayerScripts.OrderByDescending(x => x.playerClientId).FirstOrDefault();
- // if (p2.playerClientId != lastClientId)
- // {
- // if (p2.isPlayerControlled && p2.playerSteamId == 0)
- // {
- // KickPlayer(p2);
- // return;
- // }
- // else if (!p2.isPlayerControlled)
- // {
- // return;
- // }
- // bypass = true;
- // string msg = Core.AntiCheat.PlayerJoin.Value.Replace("{player}", p2.playerUsername);
- // LogInfo(msg);
- // HUDManager.Instance.AddTextToChatOnServer(msg, -1);
- // lastClientId = p2.playerClientId;
- // bypass = false;
- // }
- //}
-
-
-
- [HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")]
- [HarmonyPostfix]
- [HarmonyWrapSafe]
- public static void SteamMatchmaking_OnLobbyMemberJoined()
- {
- if (StartOfRound.Instance == null || StartOfRound.Instance.localPlayerController == null || !StartOfRound.Instance.localPlayerController.IsHost)
- {
- return;
- }
- LogInfo($"SetMoney:{Money}");
- Money = terminal.groupCredits;
- }
- public static Terminal terminal
- {
- get
- {
- if (_terminal == null)
- {
- _terminal = UnityEngine.Object.FindObjectOfType();
- }
- return _terminal;
- }
- }
-
- private static Terminal _terminal { get; set; }
-
- ///
- /// 游戏结束时重置所有变量
- /// StartOfRound.EndOfGame
- ///
- [HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
- [HarmonyPostfix]
- [HarmonyWrapSafe]
- public static void EndOfGame()
- {
- jcs = new List();
- //chcs = new Dictionary>>();
- if (rpcs.ContainsKey("Hit"))
- {
- rpcs["Hit"] = new List();
- }
- if (rpcs.ContainsKey("KillPlayer"))
- {
- rpcs["KillPlayer"] = new List();
- }
- }
-
- public static int Money = -1;
-
- ///
- /// Prefix StartOfRound.ChangeLevelServerRpc
- ///
- [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_1134466287")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1134466287(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- //LogInfo($"{p.playerUsername}|StartOfRound.ChangeLevelServerRpc");
- if (Core.AntiCheat.RemoteTerminal.Value)
- {
- if (!CheckRemoteTerminal(p, "StartOfRound.ChangeLevelServerRpc"))
- {
- return false;
- }
- }
- ByteUnpacker.ReadValueBitPacked(reader, out int levelID);
- ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCreditsAmount);
- reader.Seek(0);
- if (Core.AntiCheat.FreeBuy.Value)
- {
- if (newGroupCreditsAmount > Money || Money < 0)
- {
- ShowMessage(locale.Msg_GetString("FreeBuy_SetMoney", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{Money}",(newGroupCreditsAmount - Money).ToString() }
- }));
- if (Core.AntiCheat.FreeBuy2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- if (levelID > StartOfRound.Instance.levels.Length)
- {
- LogInfo(p, "StartOfRound.ChangeLevelServerRpc", "levelID > StartOfRound.Instance.levels.Length");
- return false;
- }
- var Route = terminal.terminalNodes.allKeywords.FirstOrDefault(x => x.word.ToLower() == "route");//Route
- var level = StartOfRound.Instance.levels[levelID].PlanetName.Split(' ')[0];
- var compatibleNoun = Route.compatibleNouns.Where(x => x.result.name == level + "route");
- if (compatibleNoun.Any())
- {
- int itemCost = compatibleNoun.First().result.itemCost;
- level = StartOfRound.Instance.currentLevel.PlanetName.Split(' ')[0];
- var nowCompatibleNoun = Route.compatibleNouns.Where(x => x.result.name == level + "route");
- if (itemCost == 0 && nowCompatibleNoun.Any() && nowCompatibleNoun.First().result.itemCost != 0)
- {
- ShowMessage(locale.Msg_GetString("ChangeToFreeLevel", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- return false;
- }
- LogInfo(p, "StartOfRound.ChangeLevelServerRpc", $"levelID:{levelID}", $"itemCost:{itemCost}");
- if (itemCost != 0)
- {
- int newValue = Money - itemCost;
- if (newValue != newGroupCreditsAmount || Money == 0)
- {
- ShowMessage(locale.Msg_GetString("FreeBuy_Level", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.FreeBuy2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- }
- }
- if (Core.AntiCheat.OperationLog.Value)
- {
- if (levelID < StartOfRound.Instance.levels.Length)
- {
- ShowMessageHostOnly(locale.OperationLog_GetString("ChangeLevel", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{planet}",StartOfRound.Instance.levels[levelID].PlanetName }
- }));
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- ///
- /// StartOfRound.BuyShipUnlockableServerRpc
- ///
- ///
- [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_3953483456")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3953483456(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.RemoteTerminal.Value)
- {
- if (!CheckRemoteTerminal(p, "StartOfRound.BuyShipUnlockableServerRpc"))
- {
- return false;
- }
- }
- ByteUnpacker.ReadValueBitPacked(reader, out int unlockableID);
- ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCreditsAmount);
- reader.Seek(0);
- if (Core.AntiCheat.FreeBuy.Value)
- {
- //LogInfo($"__rpc_handler_3953483456|newGroupCreditsAmount:{newGroupCreditsAmount}");
- if (Money == newGroupCreditsAmount || Money == 0)
- {
- //LogInfo($"Money:{Money}|newGroupCreditsAmount:{newGroupCreditsAmount}");
- ShowMessage(locale.Msg_GetString("FreeBuy_unlockable", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.FreeBuy2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else if (newGroupCreditsAmount > Money || Money < 0)
- {
- ShowMessage(locale.Msg_GetString("FreeBuy_SetMoney", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{Money}",(newGroupCreditsAmount - Money).ToString() }
- }));
- if (Core.AntiCheat.FreeBuy2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- if (Core.AntiCheat.OperationLog.Value)
- {
- if (unlockableID < StartOfRound.Instance.unlockablesList.unlockables.Count)
- {
- ShowMessageHostOnly(locale.OperationLog_GetString("BuyShipUnlockable", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{unlockable}",StartOfRound.Instance.unlockablesList.unlockables[unlockableID].unlockableName }
- }));
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
-
-
-
- [HarmonyPatch(typeof(StartOfRound), "BuyShipUnlockableClientRpc")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool BuyShipUnlockableClientRpc(int newGroupCreditsAmount, int unlockableID = -1)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)
- {
- return true;
- }
- Money = newGroupCreditsAmount;
- return true;
- }
-
-
-
- [HarmonyPatch(typeof(TimeOfDay), "SyncNewProfitQuotaClientRpc")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool SyncNewProfitQuotaClientRpc(int newProfitQuota, int overtimeBonus, int fulfilledQuota)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)
- {
- return true;
- }
- Money = Mathf.Clamp(terminal.groupCredits + overtimeBonus, terminal.groupCredits, 100000000);
- return true;
- }
-
- [HarmonyPatch(typeof(Terminal), "SyncGroupCreditsClientRpc")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool SyncGroupCreditsClientRpc(int newGroupCredits, int numItemsInShip)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)
- {
- return true;
- }
- Money = newGroupCredits;
- return true;
- }
-
- [HarmonyPatch(typeof(StartOfRound), "ChangeLevelClientRpc")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool ChangeLevelClientRpc(int levelID, int newGroupCreditsAmount)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)
- {
- return true;
- }
- Money = newGroupCreditsAmount;
- return true;
- }
-
-
- [HarmonyWrapSafe]
- [HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
- [HarmonyPrefix]
- public static bool BeginUsingTerminal(Terminal __instance)
- {
- if (!StartOfRound.Instance.IsHost)
- {
- return true;
- }
- Money = __instance.groupCredits;
- LogInfo($"SetMoney:{Money}");
- return true;
- }
-
- ///
- /// Prefix PlayerControllerB.DamagePlayer
- ///
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool DamagePlayer(PlayerControllerB __instance, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = CauseOfDeath.Unknown, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3))
- {
- //LogInfo($"PlayerControllerB.DamagePlayer|{__instance.playerUsername}|damageNumber:{damageNumber}|hasDamageSFX:{hasDamageSFX}|callRPC:{callRPC}");
- return true;
- }
-
- //[HarmonyPatch(typeof(PlayerControllerB), "IHittable.Hit")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool Hit(PlayerControllerB __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX = false, int hitID = -1)
- //{
- // if (!rpcs.ContainsKey("Hit"))
- // {
- // rpcs.Add("Hit", new List());
- // }
- // if (__instance.AllowPlayerDeath())
- // {
- // rpcs["Hit"].Add(__instance.playerClientId);
- // LogInfo($"PlayerControllerB.Hit|{__instance.playerUsername}|force:{force}|playerWhoHit:{playerWhoHit.playerUsername}|playHitSFX:{playHitSFX}|hitID:{hitID}");
- // __instance.StartCoroutine(CheckRpc(__instance, "Hit"));
- // }
- // return true;
- //}
-
-
-
- public static IEnumerator CheckRpc(PlayerControllerB __instance, string RPC)
- {
- if (RPC == "Hit" && !Core.AntiCheat.RPCReport_Hit.Value)
- {
- yield break;
- }
- if (RPC == "KillPlayer" && !Core.AntiCheat.RPCReport_KillPlayer.Value)
- {
- yield break;
- }
- LogInfo("700");
- yield return new WaitForSeconds(Core.AntiCheat.RPCReport_Delay.Value / 1000);
- LogInfo("702");
- if (__instance.isPlayerDead)
- {
- LogInfo("705");
- yield break;
- }
- LogInfo("708");
- if (rpcs[RPC].Contains(__instance.playerClientId))
- {
- LogInfo("711");
- rpcs[RPC].Remove(__instance.playerClientId);
- LogInfo($"{__instance.playerUsername}:{__instance.isPlayerDead}");
- ShowMessage(locale.Msg_GetString("RPCReport", new Dictionary() {
- { "{player}", __instance.playerUsername },
- { "{RPC}", RPC },
-
- }));
- if (Core.AntiCheat.RPCReport_Kick.Value)
- {
- KickPlayer(__instance);
- }
- }
- yield break;
- }
-
-
- ///
- /// Prefix PlayerControllerB.DamagePlayerServerRpc
- ///
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1084949295")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1084949295(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost)
- {
- if (rpcs.ContainsKey("Hit"))
- {
- rpcs["Hit"].Remove(p.playerClientId);
- }
- ByteUnpacker.ReadValueBitPacked(reader, out int damageNumber);
- ByteUnpacker.ReadValueBitPacked(reader, out int newHealthAmount);
- reader.Seek(0);
- LogInfo(p, "PlayerControllerB.DamagePlayerServerRpc", $"damageNumber:{damageNumber}", $"newHealthAmount:{newHealthAmount}");
- var p2 = (PlayerControllerB)target;
- if (p2 == p)
- {
- if (Core.AntiCheat.Health_Recover.Value)
- {
- if (damageNumber < 0)
- {
- string msg = locale.Msg_GetString("Health_Recover", new Dictionary() {
- { "{player}", p.playerUsername },
- { "{hp}", (damageNumber * -1).ToString() }
- });
- ShowMessage(msg);
- if (Core.AntiCheat.Health_Kick.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- return true;
- }
- return CheckDamage(p2, p, ref damageNumber);
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// Prefix EnemyAI.SwitchToBehaviourServerRpc
- ///
- [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_2081148948")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2081148948(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- ByteUnpacker.ReadValueBitPacked(reader, out int stateIndex);
- reader.Seek(0);
- var e = (EnemyAI)target;
- LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.SwitchToBehaviourServerRpc", $"stateIndex:{stateIndex}");
- if (Core.AntiCheat.Enemy.Value)
- {
- if (e is JesterAI j)
- {
- if (j.currentBehaviourStateIndex == 0 && stateIndex == 1)
- {
- if (j.targetPlayer != null)
- {
- return true;
- }
- }
- else if (j.currentBehaviourStateIndex == 1 && stateIndex == 2 && j.popUpTimer <= 0)
- {
- return true;
- }
- else if (j.currentBehaviourStateIndex == 2 && stateIndex == 0)
- {
- return true;
- }
- else
- {
- LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.SwitchToBehaviourServerRpc", $"stateIndex:{stateIndex}", $"popUpTimer:{j.popUpTimer}");
- //ShowMessage(locale.Msg_GetString("Enemy_SwitchToBehaviour", new Dictionary() {
- // { "{player}", p.playerUsername }
- //}));
- //return false;
- return true;
- }
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- #region Enemy Kill Player(Only Player Self)
-
- ///
- /// Prefix JesterAI.KillPlayerServerRpc
- ///
- [HarmonyPatch(typeof(JesterAI), "__rpc_handler_3446243450")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3446243450(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- return KillPlayerServerRpc(target, reader, rpcParams, "JesterAI.KillPlayerServerRpc");
- }
-
- /////
- ///// Prefix MouthDogAI.KillPlayerServerRpc
- /////
- //[HarmonyPatch(typeof(MouthDogAI), "__rpc_handler_998670557")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_998670557(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return KillPlayerServerRpc(target, reader, rpcParams, "MouthDogAI.KillPlayerServerRpc");
- //}
-
- /////
- ///// Prefix ForestGiantAI.GrabPlayerServerRpc
- /////
- //[HarmonyPatch(typeof(ForestGiantAI), "__rpc_handler_2965927486")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_2965927486(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return KillPlayerServerRpc(target, reader, rpcParams, "ForestGiantAI.GrabPlayerServerRpc");
- //}
-
- ///
- /// Prefix RedLocustBees.BeeKillPlayerServerRpc
- ///
- [HarmonyPatch(typeof(RedLocustBees), "__rpc_handler_3246315153")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3246315153(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- return KillPlayerServerRpc(target, reader, rpcParams, "RedLocustBees.BeeKillPlayerServerRpc");
- }
-
- /////
- ///// Prefix MaskedPlayerEnemy.KillPlayerAnimationServerRpc
- /////
- //[HarmonyPatch(typeof(MaskedPlayerEnemy), "__rpc_handler_3192502457")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_3192502457(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return KillPlayerServerRpc(target, reader, rpcParams, "MaskedPlayerEnemy.KillPlayerAnimationServerRpc");
- //}
-
- ///
- /// Prefix NutcrackerEnemyAI.LegKickPlayerServerRpc
- ///
- [HarmonyPatch(typeof(NutcrackerEnemyAI), "__rpc_handler_3881699224")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3881699224(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- return KillPlayerServerRpc(target, reader, rpcParams, "NutcrackerEnemyAI.LegKickPlayerServerRpc");
- }
-
- /////
- ///// Prefix BlobAI.SlimeKillPlayerEffectServerRpc
- /////
- //[HarmonyPatch(typeof(BlobAI), "__rpc_handler_3848306567")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_3848306567(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return KillPlayerServerRpc(target, reader, rpcParams, "BlobAI.SlimeKillPlayerEffectServerRpc");
- //}
-
- public static Dictionary ClingTime { get; set; } = new Dictionary();
-
- ///
- /// Prefix CentipedeAI.ClingToPlayerServerRpc
- ///
- [HarmonyPatch(typeof(CentipedeAI), "__rpc_handler_2791977891")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2791977891(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p))
- return p != null;
- ByteUnpacker.ReadValueBitPacked(reader, out int num);
- reader.Seek(0);
- LogInfo(p, "CentipedeAI.ClingToPlayerServerRpc", $"num:{num}");
- if ((int)p.playerClientId == num)
- {
- if (ClingTime.ContainsKey(p.playerSteamId))
- {
- ClingTime[p.playerSteamId] = DateTime.Now;
- }
- else
- {
- ClingTime.Add(p.playerSteamId, DateTime.Now);
- }
- }
- return true;
- //return KillPlayerServerRpc(target, reader, rpcParams, "CentipedeAI.ClingToPlayerServerRpc");
- }
-
- /////
- ///// Prefix RadMechAI.GrabPlayerServerRpc
- /////
- //[HarmonyPatch(typeof(RadMechAI), "__rpc_handler_3707286996")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_3707286996(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return KillPlayerServerRpc(target, reader, rpcParams, "RadMechAI.GrabPlayerServerRpc");
- //}
-
- /////
- ///// Prefix CaveDwellerAI.GrabPlayerServerRpc
- /////
- /////
- //[HarmonyPatch(typeof(CaveDwellerAI), "__rpc_handler_3591556954")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_3591556954(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return KillPlayerServerRpc(target, reader, rpcParams, "CaveDwellerAI.GrabPlayerServerRpc");
- //}
-
-
-
- private static bool KillPlayerServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams, string call)
- {
- if (Check(rpcParams, out var p))
- {
- var e = (EnemyAI)target;
- ByteUnpacker.ReadValueBitPacked(reader, out int playerId);
- reader.Seek(0);
- LogInfo(p, $"{e.GetType()}.KillPlayerServerRpc", $"playerId:{playerId}");
- if (playerId <= StartOfRound.Instance.allPlayerScripts.Length && StartOfRound.Instance.allPlayerScripts[playerId] != p)
- {
- LogInfo(p, $"{e.GetType()}.KillPlayerServerRpc", $"playerUsername:{StartOfRound.Instance.allPlayerScripts[playerId].playerUsername}");
- return false;
- }
- if (!rpcs.ContainsKey("KillPlayer"))
- {
- rpcs.Add("KillPlayer", new List());
- }
- if (p.AllowPlayerDeath())
- {
- LogInfo(p, "StartCoroutine:CheckRpc(KillPlayer)", $"call:{call}");
- rpcs["KillPlayer"].Add(p.playerClientId);
- p.StartCoroutine(CheckRpc(p, "KillPlayer"));
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- #endregion
-
- ///
- /// Prefix EnemyAI.UpdateEnemyPositionServerRpc
- ///
- [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_255411420")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_255411420(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- //reader.ReadValueSafe(out Vector3 newPos);
- //reader.Seek(0);
- //LogInfo($"{p.playerUsername} call EnemyAI.UpdateEnemyPositionServerRpc|newPos:{newPos}");
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_1810146992")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1810146992(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- var e = (EnemyAI)target;
- LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.KillEnemyServerRpc", $"EnemyId:{e.GetInstanceID()}", $"HP:{e.enemyHP}");
- if (Core.AntiCheat.KillEnemy.Value)
- {
- foreach (var item in bypassKill)
- {
- if (item.EnemyInstanceId == e.GetInstanceID() && !item.CalledClient.Contains(p.playerClientId))
- {
- LogInfo($"{e.GetInstanceID()} bypass|playerClientId:{p.playerClientId}");
- item.CalledClient.Add(p.playerClientId);
- return true;
- }
- }
- if (e.enemyHP <= 0)
- {
- return true;
- }
-
- if (Vector3.Distance(p.transform.position, e.transform.position) > 50f)
- {
- ShowMessage(locale.Msg_GetString("KillEnemy", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{enemyName}",e.enemyType.enemyName },
- { "{HP}",e.enemyHP.ToString() }
- }));
- if (Core.AntiCheat.KillEnemy2.Value)
- {
- KickPlayer(p);
- return false;
- }
- }
- }
- }
- return true;
- }
-
- [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3079913705")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3079913705(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Enemy.Value)
- {
- //LogInfo($"{p.playerUsername} call EnemyAI.UpdateEnemyRotationServerRpc");
- return true;
- }
- }
- return true;
- }
-
- //[HarmonyPatch(typeof(EnemyAI), "__rpc_handler_255411420")]
- //[HarmonyPrefix]
- //public static bool __rpc_handler_255411420(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // if (Check(rpcParams, out var p))
- // {
- // if (Core.AntiCheatPlugin.Enemy.Value)
- // {
- // LogInfo($"{p.playerUsername} call EnemyAI.UpdateEnemyPositionServerRpc");
- // return true;
- // }
- // }
- // else if (p == null)
- // {
- // return false;
- // }
- // return true;
- //}
-
- [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3587030867")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3587030867(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Enemy.Value)
- {
- ByteUnpacker.ReadValueBitPacked(reader, out int clientId);
- reader.Seek(0);
- var enemy = target.GetComponent();
- if (enemy is MouthDogAI || enemy is DressGirlAI)
- {
- return true;
- }
- float v = Vector3.Distance(p.transform.position, enemy.transform.position);
- LogInfo(p, $"({enemy.enemyType.enemyName})EnemyAI.ChangeEnemyOwnerServerRpc", $"Distance:{v}", $"CallClientId:{p.playerClientId}", $"OwnerClientId:{enemy.OwnerClientId}", $"NewClientId:{clientId}");
- return true;
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- [HarmonyPatch(typeof(JetpackItem), "__rpc_handler_3663112878")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3663112878(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Jetpack.Value)
- {
- var jp = (JetpackItem)target;
- if (jp.playerHeldBy != null && jp.playerHeldBy.playerClientId != p.playerClientId)
- {
- ShowMessage(locale.Msg_GetString("Jetpack", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Jetpack2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else if (jp.playerHeldBy == null)
- {
- ShowMessage(locale.Msg_GetString("Jetpack", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Jetpack2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- return true;
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- public static List bypassHit = new List();
- public static List bypassKill = new List();
-
- [HarmonyPatch(typeof(EnemyAI), "KillEnemyOnOwnerClient")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static void KillEnemyOnOwnerClient(EnemyAI __instance)
- {
- if (StartOfRound.Instance.localPlayerController.IsHost)
- {
- if (bypassKill.Any(x => x.EnemyInstanceId == __instance.GetInstanceID()))
- {
- return;
- }
- LogInfo($"bypassKill -> {__instance.enemyType.enemyName}({__instance.GetInstanceID()})");
- bypassKill.Add(new HitData()
- {
- EnemyInstanceId = __instance.GetInstanceID(),
- force = 0,
- CalledClient = new List()
- });
- }
- }
-
-
- [HarmonyPatch(typeof(EnemyAI), "HitEnemyOnLocalClient")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static void HitEnemyOnLocalClient(EnemyAI __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID)
- {
- if (StartOfRound.Instance.localPlayerController.IsHost)
- {
- //if (bypassHit.Any(x => x.EnemyInstanceId == __instance.GetInstanceID()))
- //{
- // return;
- //}
- //if (playerWhoHit == null)
- //{
- bypassHit.Add(new HitData()
- {
- EnemyInstanceId = __instance.GetInstanceID(),
- force = force,
- CalledClient = new List()
- });
- //}
- }
- }
-
- public static List explosions { get; set; } = new List();
-
- public class ExplosionData
- {
- public List CalledClient { get; set; }
-
- public Vector3 ExplosionPostion { get; set; }
-
- public DateTime CreateDateTime { get; set; }
- }
-
- public class HitData
- {
- public int EnemyInstanceId { get; set; }
-
- public int force { get; set; }
-
-
- public List CalledClient { get; set; }
- }
-
- public static PlayerControllerB lastDriver { get; set; }
-
-
- [HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static void ButlerEnemyAI_KillEnemy(EnemyAI __instance)
- {
- if (StartOfRound.Instance.localPlayerController.IsHost)
- {
- if (__instance is ButlerEnemyAI)
- {
- LandminePatch.SpawnExplosion(__instance.transform.position + Vector3.up * 0.15f);
- }
- }
- }
-
-
- //public static void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
- //{
- // LogInfo($"force:{force}|playerWhoHit:{playerWhoHit?.playerUsername}|playHitSFX:{playHitSFX}|hitID:{hitID}");
- //}
-
- public static string PlayerClientIdConvertName(int index)
- {
- if (index < 0 || index >= StartOfRound.Instance.allPlayerScripts.Length)
- {
- return "Unknown";
- }
- return StartOfRound.Instance.allPlayerScripts[index].playerUsername;
- }
-
- //[HarmonyPatch(typeof(EnemyAI), "HitEnemy")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static void HitEnemy(EnemyAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
- //{
- // AntiCheat.Core.AntiCheat.LogInfo($"({__instance.enemyType.enemyName})EnemyAI.HitEnemy;EnemyId:{__instance.GetInstanceID()}|HP:{__instance.enemyHP}|force:{force}|playerWhoHit:{playerWhoHit?.playerUsername}|playHitSFX:{playHitSFX}|hitID:{hitID}");
- //}
-
- [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3538577804")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool HitEnemyServerRpcPatch(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p) || StartOfRound.Instance.localPlayerController.IsHost)
- {
- if (p == null)
- {
- return false;
- }
- int force;
- ByteUnpacker.ReadValueBitPacked(reader, out force);
- ByteUnpacker.ReadValueBitPacked(reader, out int playerWhoHit);
- reader.ReadValueSafe(out bool playHitSFX, default);
- reader.Seek(0);
- var e = (EnemyAI)target;
- LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.HitEnemyServerRpc", $"EnemyId:{e.GetInstanceID()}", $"HP:{e.enemyHP}", $"force:{force}", $"playerWhoHit:{PlayerClientIdConvertName(playerWhoHit)}({playerWhoHit})");
- if (p.isHostPlayerObject)
- {
- return true;
- }
- if (playerWhoHit != -1 && StartOfRound.Instance.allPlayerScripts[playerWhoHit] != p)
- {
- LogInfo("return false;");
- return false;
- }
- VehicleController vehicleController = UnityEngine.Object.FindFirstObjectByType();
- if (vehicleController != null)
- {
- PlayerControllerB currentDriver = vehicleController.currentDriver;
- if (force == 2 && currentDriver != null && currentDriver.playerClientId == p.playerClientId)
- {
- lastDriver = currentDriver;
- return true;
- }
- if (force == 2 && currentDriver == null && lastDriver.playerClientId == p.playerClientId)
- {
- return true;
- }
- }
- //if (e.isEnemyDead)
- //{
- // return true;
- //}
- foreach (var item in bypassHit)
- {
- if (item.EnemyInstanceId == e.GetInstanceID() && item.force == force && !item.CalledClient.Contains(p.playerClientId))
- {
- LogInfo($"{e.GetInstanceID()} bypass|playerClientId:{p.playerClientId}");
- item.CalledClient.Add(p.playerClientId);
- return true;
- }
- }
- if (Core.AntiCheat.Shovel.Value)
- {
- //if (playerWhoHit == -1 && Vector3.Distance(p.transform.position, e.transform.position) < 30)
- //{
- // return true;
- //}
- var obj = p.ItemSlots[p.currentItemSlot];
- string playerUsername = p.playerUsername;
- if (force == 6 && playerWhoHit == -1)
- {
- LogInfo($"force = 6||enemyPostion:{e.transform.position}");
- explosions = explosions.Where(x => x.CreateDateTime.AddSeconds(10) > DateTime.Now).ToList();
- for (int i = explosions.Count - 1; i > 0; i--)
- {
- var item = explosions[i];
- if (item.CalledClient.Contains(p.playerSteamId))
- {
- continue;
- }
- float ExplosionDistance = Vector3.Distance(item.ExplosionPostion, e.transform.position);
- LogInfo($"ExplosionPostion:{item.ExplosionPostion}||Distance:{ExplosionDistance}");
- if (ExplosionDistance < 5f)
- {
- item.CalledClient.Add(p.playerSteamId);
- return true;
- }
- }
- }
- else if (force != 1 && obj != null && (isShovel(obj) || isKnife(obj)))
- {
- if (!jcs.Contains(p.playerSteamId))
- {
- ShowMessage(locale.Msg_GetString("Shovel4", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{enemyName}",e.enemyType.enemyName },
- { "{damageAmount}",force.ToString() },
- { "{item}", isShovel(obj) ? locale.Item_GetString("Shovel") : locale.Item_GetString("Knife") }
- }));
- jcs.Add(p.playerSteamId);
- if (Core.AntiCheat.Shovel2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- else if (!p.isPlayerDead && obj == null)
- {
- if (ClingTime.ContainsKey(p.playerSteamId) && ClingTime[p.playerSteamId].AddSeconds(5) > DateTime.Now)
- {
- return true;
- }
- if (p.ItemSlots.Any(x => isShovel(x)) && force == 1)
- {
- return true;
- }
- if (!jcs.Contains(p.playerSteamId))
- {
- for (int i = 0; i < p.ItemSlots.Length; i++)
- {
- LogInfo($"p:{p.playerUsername}|i:{i}|itemName:{p.ItemSlots[i]?.itemProperties?.itemName}");
- }
- LogInfo($"currentItemSlot:{p.currentItemSlot}");
- LogInfo($"currentlyHeldObjectServer:{p.currentlyHeldObjectServer?.itemProperties?.itemName}");
- LogInfo($"obj:{obj}");
- if (!Core.AntiCheat.Shovel3.Value && (force == 1 || force == 2 || force == 3 || force == 5))
- {
- ShowMessage(locale.Msg_GetString("Shovel6", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{enemyName}",e.enemyType.enemyName },
- { "{damageAmount}",force.ToString() }
- }));
- jcs.Add(p.playerSteamId);
- if (Core.AntiCheat.Shovel2.Value)
- {
- KickPlayer(p);
- }
- }
- else
- {
- ShowMessage(locale.Msg_GetString("Shovel6", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{enemyName}",e.enemyType.enemyName },
- { "{damageAmount}",force.ToString() }
- }));
- }
- return false;
- }
- }
- else if (jcs.Contains(p.playerSteamId))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private static string lastMessage = string.Empty;
-
- ///
- /// 在游戏中输出信息
- ///
- public static void ShowMessage(string msg, string lastmsg = null)
- {
- string showmsg = string.Empty;
- var type = Core.AntiCheat.DetectedMessageType.Value;
- showmsg = locale.MessageFormat(new Dictionary() {
- { "{Prefix}",locale.Prefix() },
- { "{msg}",msg }
- });
- if (lastMessage == msg || (lastmsg == lastMessage && lastmsg != null))
- {
- //LogInfo($"RepeatMessage|{showmsg}");
- return;
- }
- if (lastmsg != null)
- {
- lastMessage = lastmsg;
- }
- else
- {
- lastMessage = msg;
- }
- if (type == Core.AntiCheat.MessageType.PublicChat)
- {
- LogInfo($"AddTextMessageClientRpc|{showmsg}");
- AddTextMessageClientRpc(showmsg);
- }
- else if (type == Core.AntiCheat.MessageType.HostChat)
- {
- ShowMessageHostOnly(showmsg);
- }
- else
- {
- LogInfo($"ShowGUI|{showmsg}");
- }
- }
-
- public static void AddTextMessageClientRpc(string showmsg)
- {
- AccessTools.DeclaredMethod(typeof(HUDManager), "AddTextMessageClientRpc").Invoke(HUDManager.Instance, new object[] {
- showmsg
- });
- }
-
- public static bool bypass { get; set; }
-
- ///
- /// 开礼物盒事件(一个礼物盒只能开一次)
- /// Prefix GiftBoxItem.OpenGiftBoxServerRpc
- ///
- [HarmonyPatch(typeof(GiftBoxItem), "__rpc_handler_2878544999")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2878544999(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Gift.Value)
- {
- var item = (GiftBoxItem)target;
- if ((bool)AccessTools.DeclaredField(typeof(GiftBoxItem), "hasUsedGift").GetValue(item))
- {
- ShowMessage(locale.Msg_GetString("Gift", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Gift2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else
- {
- StartOfRound.Instance.localPlayerController.StartCoroutine(DestroySelf(item.gameObject));
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- public static IEnumerator DestroySelf(GameObject self)
- {
- yield return new WaitForSeconds(5f);
- UnityEngine.Object.Destroy(self);
- }
-
- ///
- /// 使用面具生成假人事件(一个面具只能生成一个假人)
- /// Prefix HauntedMaskItem.CreateMimicServerRpc
- ///
- [HarmonyPatch(typeof(HauntedMaskItem), "__rpc_handler_1065539967")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1065539967(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Mask.Value)
- {
- if (mjs.Contains(target.GetInstanceID()))
- {
- ShowMessage(locale.Msg_GetString("Mask", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Mask2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else
- {
- mjs.Add(target.GetInstanceID());
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 检测是否需要处理事件(顺带处理掉SteamID为0的玩家)
- ///
- public static bool Check(__RpcParams rpcParams, out PlayerControllerB p)
- {
- if (StartOfRound.Instance.localPlayerController == null)
- {
- p = default;
- return false;
- }
- else if (!StartOfRound.Instance.localPlayerController.IsHost)//非主机
- {
- p = StartOfRound.Instance.localPlayerController;
- return false;
- }
- var tmp = GetPlayer(rpcParams);
- p = tmp;
- if (p == null)//没玩家
- {
- NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId);
- return false;
- }
- else if (rpcParams.Server.Receive.SenderClientId == GameNetworkManager.Instance.localPlayerController.actualClientId)//非本地
- {
- p = StartOfRound.Instance.localPlayerController;
- return false;
- }
- else if (StartOfRound.Instance.KickedClientIds.Contains(p.playerSteamId))//如果被踢
- {
- Task.Delay(-100);
- NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId);
- return false;
- }
- else if (p.playerSteamId == 0)
- {
- uint clientId = ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId);
- if (clientId == 0)
- {
- return false;
- }
- ulong steamId = ConnectionIdtoSteamIdMap[clientId];
- Friend f = new Steamworks.Friend(steamId);
- NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId);
- StartOfRound.Instance.KickedClientIds.Add(steamId);
- LogInfo($"检测玩家 {f.Name}({steamId}) 使用AntiKick功能,已自动踢出!");
- return false;
- }
- return true;
- }
-
- public static uint ClientIdToTransportId(ulong SenderClientId)
- {
- if (SenderClientId == 0)
- {
- return 0;
- }
- NetworkConnectionManager networkConnectionManager = Traverse.Create(NetworkManager.Singleton).Field("ConnectionManager").GetValue();
- ulong transportId = Traverse.Create(networkConnectionManager).Method("ClientIdToTransportId", new object[] { SenderClientId }).GetValue();
- return (uint)transportId;
- }
-
- ///
- /// 降落时加载地图事件(显示反作弊信息)
- /// Prefix RoundManager.LoadNewLevel
- ///
- [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool LoadNewLevel(SelectableLevel newLevel)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)//非主机
- {
- return true;
- }
- landMines = new List();
- bypassHit = new List();
- bypassKill = new List();
- HUDManager.Instance.AddTextToChatOnServer(locale.Msg_GetString("game_start", new Dictionary() {
- { "{ver}",Core.AntiCheat.Version }
- }), -1);
- return true;
- }
-
- ///
- /// 玩家切换格子事件(拿了双手物品无法切换格子,他们本地客户端依旧可以)
- /// Prefix PlayerControllerB.SwitchItemSlotsServerRpc
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_412259855")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_412259855(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
-
- if (p.currentlyHeldObjectServer != null && p.currentlyHeldObjectServer.itemProperties.twoHanded)
- {
- return false;
- }
-
- return true;
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- ///
- /// 添加物品到腰包事件
- /// Prefix BeltBagItem.TryAddObjectToBagServerRpc
- ///
- [HarmonyPatch(typeof(BeltBagItem), "__rpc_handler_2988305002")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2988305002(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.GrabObject.Value && Core.AntiCheat.GrabObject_BeltBag.Value)
- {
- reader.ReadValueSafe(out NetworkObjectReference netObjectRef, default);
- ByteUnpacker.ReadValueBitPacked(reader, out int playerWhoAdded);
- reader.Seek(0);
- if (netObjectRef.TryGet(out NetworkObject networkObject, null))
- {
- GrabbableObject component = networkObject.GetComponent();
- if (!component.itemProperties.isScrap && !component.isHeld && !component.isHeldByEnemy && component.itemProperties.itemId != 123984 && component.itemProperties.itemId != 819501)
- {
- return true;
- }
- ((BeltBagItem)target).CancelAddObjectToBagClientRpc(playerWhoAdded);
- return false;
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 玩家捡起物品事件(用于检测多格子,单手拿双手物品,隔空取物)
- /// Prefix PlayerControllerB.GrabObjectServerRpc
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1554282707")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1554282707(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.GrabObject.Value)
- {
- reader.ReadValueSafe(out NetworkObjectReference grabbedObject, default);
- reader.Seek(0);
- var jetpack = false;
- if (grabbedObject.TryGet(out var networkObject, null))
- {
- var all = true;
- bool hastwohand = false;
- foreach (var item in p.ItemSlots)
- {
- if (item == null)
- {
- all = false;
- }
- else if (item.itemProperties.twoHanded)
- {
- hastwohand = true;
- }
- else if (item is JetpackItem)
- {
- jetpack = true;
- }
- }
- var g = networkObject.GetComponentInChildren();
- if (g != null)
- {
- LogInfo(p, "PlayerControllerB.GrabObjectServerRpc", $"itemName:{g.itemProperties.itemName}", $"heldByPlayerOnServer:{(g.heldByPlayerOnServer ? g.playerHeldBy?.playerUsername : "false")}", $"Distance:{Vector3.Distance(p.transform.position, g.transform.position)}");
- bool ban = false;
- if (Core.AntiCheat.GrabObject_TwoHand.Value)
- {
- if (g.itemProperties.twoHanded && hastwohand)
- {
- ban = true;
- }
- else if (g.itemProperties.twoHanded && jetpack)
- {
- ban = true;
- }
- else if (hastwohand && jetpack)
- {
- ban = true;
- }
- }
- if (Core.AntiCheat.GrabObject_MoreSlot.Value && !ban)
- {
- ban = all;
- }
- if (ban)
- {
- var __rpc_exec_stage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- __rpc_exec_stage.SetValue(target, 1);
- typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke((PlayerControllerB)target, new object[] {
- default
- });
- __rpc_exec_stage.SetValue(target, 0);
- return false;
- }
- if (Vector3.Distance(g.transform.position, p.serverPlayerPosition) > 100 && !StartOfRound.Instance.shipIsLeaving && StartOfRound.Instance.shipHasLanded)
- {
- if (p.teleportedLastFrame)
- {
- return true;
- }
- ShowMessage(locale.Msg_GetString("GrabObject", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{object_position}",g.transform.position.ToString() },
- { "{player_position}",p.serverPlayerPosition.ToString() }
- }));
- g = default;
- grabbedObject = default;
- if (Core.AntiCheat.GrabObject_MoreSlot.Value)
- {
- KickPlayer(p);
- }
- var __rpc_exec_stage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- __rpc_exec_stage.SetValue(target, 1);
- typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke((PlayerControllerB)target, new object[] {
- default
- });
- __rpc_exec_stage.SetValue(target, 0);
- return false;
- }
- }
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- /////
- ///// 玩家跳跃
- ///// Prefix PlayerControllerB.PlayerJumpedServerRpc
- /////
- //[HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2013428264")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_420292904(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // if (Check(rpcParams, out var p))
- // {
- // if (!PlayerJumping.ContainsKey(p))
- // {
- // PlayerJumping.Add(p, false);
- // }
- // if (!PlayerJumping[p])
- // {
- // p.StartCoroutine(PlayerJump(p));
- // }
- // }
- // else if (p == null)
- // {
- // return false;
- // }
- // return true;
- //}
-
- //public static Dictionary PlayerJumping { get; set; } = new Dictionary();
-
- //public static IEnumerator PlayerJump(PlayerControllerB p)
- //{
-
- // LogInfo($"{p.playerUsername} is Jumping");
- // PlayerJumping[p] = true;
- // yield return new WaitForSeconds(0.25f);
- // LogInfo($"{p.playerUsername} wait isGrounded");
- // yield return new WaitUntil(() => Physics.Raycast(p.transform.position, Vector3.down, out var raycastHit, 80f, 268437760, QueryTriggerInteraction.Ignore) && raycastHit.distance < 0.1);
- // LogInfo($"{p.playerUsername} is Grounded");
- // PlayerJumping[p] = false;
- //}
-
-
-
- ///
- /// 玩家坐标变动事件(玩家如果隐身会将本体传送到一个很远的位置,例如当前坐标-100)
- /// Prefix PlayerControllerB.UpdatePlayerPositionServerRpc
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2013428264")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2013428264(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- reader.ReadValueSafe(out Vector3 newPos);
- reader.Seek(0);
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Invisibility.Value)
- {
- if (StartOfRound.Instance.currentLevel != null && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
- {
- if (!recentPlayerPositions.ContainsKey(p.playerSteamId))
- recentPlayerPositions[p.playerSteamId] = new List<(Vector3, float)>();
- float now = Time.time;
- recentPlayerPositions[p.playerSteamId] = recentPlayerPositions[p.playerSteamId]
- .Where(entry => now - entry.time <= 5f)
- .ToList();
- recentPlayerPositions[p.playerSteamId].Add((newPos, now));
- }
- var oldpos = p.serverPlayerPosition;
- if (p.teleportedLastFrame)
- {
- return true;
- }
- if (Vector3.Distance(oldpos, newPos) > 100 && Vector3.Distance(newPos, new Vector3(0, 0, 0)) > 10)
- {
- ShowMessage(locale.Msg_GetString("Invisibility", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{player_position}",newPos.ToString() }
- }));
- if (Core.AntiCheat.Invisibility2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 记录本机SteamID
- /// Prefix NetworkManager.Awake
- ///
- [HarmonyPatch(typeof(NetworkManager), "Awake")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static void NetworkManagerAwake()
- {
- if (!GameNetworkManager.Instance.disableSteam)
- {
- ConnectionIdtoSteamIdMap[0] = SteamClient.SteamId;
- }
- }
-
- ///
- /// 代码来源 @Charlese2 HostFixes
- /// 客户端连接事件,获取真实的SteamID
- ///
- [HarmonyPatch(typeof(FacepunchTransport), "Steamworks.ISocketManager.OnConnecting")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool FacepunchTransportOnConnecting(ref Connection connection, ref ConnectionInfo info)
- {
- NetIdentity identity = Traverse.Create(info).Field("identity").Value;
- //if (StartOfRound.Instance.KickedClientIds.Contains(identity.SteamId.Value))
- //{
- // LogInfo(locale.Log_GetString("refuse_connect", new Dictionary() {
- // {"{steamId}",identity.SteamId.Value.ToString() }
- // }));
- // return false;
- //}
- if (StartOfRound.Instance.allPlayerScripts.Any(x => x.isPlayerControlled && x.playerSteamId == identity.SteamId.Value))
- {
- LogInfo("{steamId} repeatedly joins the game.");
- return false;
- }
- if (ConnectionIdtoSteamIdMap.ContainsKey(connection.Id))
- {
- ConnectionIdtoSteamIdMap[connection.Id] = identity.SteamId.Value;
- }
- else
- {
- ConnectionIdtoSteamIdMap.Add(connection.Id, identity.SteamId.Value);
- }
- if (Core.AntiCheat.OperationLog.Value)
- {
- ShowMessageHostOnly(locale.OperationLog_GetString("JoinLobby", new Dictionary() {
- { "{player}",new Friend(ConnectionIdtoSteamIdMap[connection.Id]).Name }
- }));
- }
- return true;
- }
-
-
- ///
- ///
- ///
- ///
- ///
- [HarmonyPatch(typeof(NetworkConfig), "CompareConfig")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool NetworkConnectionManagerInitialize(ref bool __result)
- {
- if (StartOfRound.Instance != null && StartOfRound.Instance.IsHost)
- {
- if (Core.AntiCheat.IgnoreClientConfig.Value)
- {
- __result = true;
- return false;
- }
- }
- return true;
- }
-
- ///
- /// 代码来源 @Charlese2 HostFixes
- /// 客户端断开连接事件
- /// Prefix FacepunchTransport.OnDisconnected
- ///
- [HarmonyPatch(typeof(FacepunchTransport), "Steamworks.ISocketManager.OnDisconnected")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static void FacepunchTransportOnDisconnected(ref Connection connection, ref ConnectionInfo info)
- {
- if (NetworkManager.Singleton?.IsListening == true)
- {
- NetIdentity identity = Traverse.Create(info).Field("identity").Value;
- HUDManagerPatch.SyncAllPlayerLevelsServerRpcCalls.Remove(ConnectionIdtoSteamIdMap[connection.Id]);
- StartOfRoundPatch.SyncShipUnlockablesServerRpcCalls.Remove(ConnectionIdtoSteamIdMap[connection.Id]);
- StartOfRoundPatch.SyncAlreadyHeldObjectsServerRpcCalls.Remove(ConnectionIdtoSteamIdMap[connection.Id]);
- ConnectionIdtoSteamIdMap.Remove(connection.Id);
- }
- }
-
-
-
-
-
- ///
- /// Prefix HUDManager.AddTextMessageServerRpc
- ///
- [HarmonyPatch(typeof(HUDManager), "__rpc_handler_2787681914")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2787681914(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- reader.ReadValueSafe(out bool flag, default);
- string chatMessage = null;
- if (flag)
- {
- reader.ReadValueSafe(out chatMessage, false);
- }
- reader.Seek(0);
- LogInfo(p, "HUDManager.AddTextMessageServerRpc", $"chatMessage:{chatMessage}");
- if (chatMessage.Contains("Tyzeron.Minimap"))
- {
- ShowMessage(locale.Msg_GetString("Map", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Map2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- return false;
- }
- else if (chatMessage.StartsWith("[morecompanycosmetics]"))//bypass MoreCompany
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- /////
- ///// HUDManager.AddPlayerChatMessageClientRpc
- /////
- //[HarmonyPatch(typeof(HUDManager), "__rpc_handler_168728662")]
- //[HarmonyPrefix]
- //[HarmonyWrapSafe]
- //public static bool __rpc_handler_168728662(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- //{
- // return __rpc_handler_2930587515(target, reader, rpcParams);
- //}
-
- ///
- /// HUDManager.AddPlayerChatMessageServerRpc
- ///
- [HarmonyPatch(typeof(HUDManager), "__rpc_handler_2930587515")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2930587515(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.ChatReal.Value)
- {
- try
- {
- reader.ReadValueSafe(out bool flag, default);
- string chatMessage = null;
- if (flag)
- {
- reader.ReadValueSafe(out chatMessage, false);
- }
- ByteUnpacker.ReadValueBitPacked(reader, out int playerId);
- reader.Seek(0);
- LogInfo(p, $"HUDManager.AddPlayerChatMessageServerRpc", $"chatMessage:{chatMessage}");
- if (playerId == -1)
- {
- return false;
- }
- if (playerId <= StartOfRound.Instance.allPlayerScripts.Length)
- {
- if (StartOfRound.Instance.allPlayerScripts[(int)playerId].playerSteamId != p.playerSteamId)
- {
- ShowMessage(locale.Msg_GetString("ChatReal", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{player2}",StartOfRound.Instance.allPlayerScripts[playerId].playerUsername },
- }));
- if (Core.AntiCheat.ChatReal2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else
- {
- bool ret = CooldownManager.CheckCooldown("Chat", p);
- if (ret && locale.current_language == "zh_CN")
- {
-
- AccessTools.DeclaredMethod(typeof(HUDManager), "AddPlayerChatMessageClientRpc").Invoke(HUDManager.Instance, new object[] {
- chatMessage,
- playerId
- });
- return false;
-
- }
- return ret;
- }
- }
- else
- {
- return false;
- }
- }
- catch (Exception ex)
- {
- LogInfo(ex.ToString());
- return false;
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- public static bool CheckRemoteTerminal(PlayerControllerB p, string call)
- {
- LogInfo(p, "CheckRemoteTerminal", $"Call:{call}");
- if (whoUseTerminal == null && lastWhoUseTerminal.Value == p.playerSteamId)
- {
- LogInfo($"whoUseTerminal == null && lastWhoUseTerminal == {p.playerSteamId}||Time:{Math.Round((DateTime.Now - lastWhoUseTerminal.Key).TotalSeconds, 2)}s");
- if (lastWhoUseTerminal.Key.AddSeconds(10) > DateTime.Now)
- {
- return true;
- }
- }
- if (whoUseTerminal != p)
- {
- if (whoUseTerminal == null)
- {
- LogInfo($"no player use terminal|request player:{p.playerUsername}|call:{call}");
- }
- else
- {
- LogInfo($"whoUseTerminal:{whoUseTerminal.playerUsername}|p:{p.playerUsername}|call:{call}");
- }
- ShowMessage(locale.Msg_GetString("RemoteTerminal", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.RemoteTerminal2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- return true;
- }
-
- [HarmonyPatch(typeof(InteractTrigger), "__rpc_handler_1430497838")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1430497838(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost)
- {
- ByteUnpacker.ReadValueBitPacked(reader, out int playerNum);
- reader.Seek(0);
- if (playerNum == (int)p.playerClientId)
- {
-
- var terminalTrigger = (InteractTrigger)AccessTools.DeclaredField(typeof(Terminal), "terminalTrigger").GetValue(terminal);
- if (terminalTrigger.GetInstanceID() == ((InteractTrigger)target).GetInstanceID())
- {
- whoUseTerminal = p;
- LogInfo($"player {p.playerUsername} use Terminal");
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- [HarmonyPatch(typeof(InteractTrigger), "__rpc_handler_880620475")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_880620475(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost)
- {
- ByteUnpacker.ReadValueBitPacked(reader, out int playerNum);
- reader.Seek(0);
- if (playerNum == (int)p.playerClientId)
- {
- if (p.isPlayerDead)
- {
- LogInfo($"player {p.playerUsername} death can't use terminal");
- return false;
- }
- var terminalTrigger = (InteractTrigger)AccessTools.DeclaredField(typeof(Terminal), "terminalTrigger").GetValue(terminal);
- if (terminalTrigger.GetInstanceID() == ((InteractTrigger)target).GetInstanceID())
- {
- lastWhoUseTerminal = new KeyValuePair(DateTime.Now, p.playerSteamId);
- whoUseTerminal = null;
- LogInfo($"player {p.playerUsername} stop use Terminal");
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 终端噪音限制
- /// Prefix Terminal.PlayTerminalAudioServerRpc
- ///
- [HarmonyPatch(typeof(Terminal), "__rpc_handler_1713627637")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1713627637(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.RemoteTerminal.Value)
- {
- if (!CheckRemoteTerminal(p, "Terminal.PlayTerminalAudioServerRpc"))
- {
- return false;
- }
- }
- return CooldownManager.CheckCooldown("TerminalNoise", p);
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 飞船灯开关速度限制
- /// Prefix ShipLights.SetShipLightsServerRpc
- ///
- [HarmonyPatch(typeof(ShipLights), "__rpc_handler_1625678258")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1625678258(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- bool canUse = CooldownManager.CheckCooldown("ShipLight", p);
- if (!canUse)
- {
- ((ShipLights)target).SetShipLightsClientRpc(true);
- }
- return canUse;
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 通过ClientId找到调用RPC的玩家
- ///
- ///
- ///
- private static PlayerControllerB GetPlayer(__RpcParams rpcParams)
- {
- foreach (var item in StartOfRound.Instance.allPlayerScripts)
- {
- if (item.actualClientId == rpcParams.Server.Receive.SenderClientId)
- {
- return item;
- }
- }
- return null;//??
- }
-
- public static Dictionary ReloadGun = new Dictionary();
-
- ///
- /// 上弹事件
- /// Prefix ShotgunItem.ReloadGunEffectsServerRpc
- ///
- [HarmonyPatch(typeof(ShotgunItem), "__rpc_handler_3349119596")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3349119596(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.InfiniteAmmo.Value)
- {
- reader.ReadValueSafe(out bool start, default);
- reader.Seek(0);
- var shot = (ShotgunItem)target;
- LogInfo(p, $"ShotgunItem.ReloadGunEffectsServerRpc", $"start:{start}", $"shellsLoaded:{shot.shellsLoaded}");
- if (!ReloadGun.ContainsKey(p.playerSteamId))
- {
- ReloadGun.Add(p.playerSteamId, start);
- }
- else
- {
- ReloadGun[p.playerSteamId] = start;
- }
- if (start)
- {
- var ammo = shot.playerHeldBy.ItemSlots.FirstOrDefault(x => x is GunAmmo ga && ga.ammoType == shot.gunCompatibleAmmoID);
- if (ammo != default)
- {
- shot.StartCoroutine(CheckAmmo(p, shot, ammo));
- return true;
- }
- else
- {
- ShowMessage(locale.Msg_GetString("InfiniteAmmo", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.InfiniteAmmo2.Value)
- {
- KickPlayer(p);
- }
- }
- return false;
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- public static IEnumerator CheckAmmo(PlayerControllerB p, ShotgunItem shot, GrabbableObject ammo)
- {
- yield return new WaitForSeconds(0.95f + 0.3f);
- yield return new WaitForSeconds(3f);//delay
- if (ReloadGun.ContainsKey(p.playerSteamId) && !ReloadGun[p.playerSteamId])
- {
- if (ammo != null && ammo.NetworkObject != null && ammo.NetworkObject.IsSpawned)
- {
- ShowMessage(locale.Msg_GetString("InfiniteAmmo", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.InfiniteAmmo2.Value)
- {
- KickPlayer(p);
- }
- }
- }
- }
-
-
-
- ///
- /// 开枪事件
- /// Prefix ShotgunItem.ShootGunServerRpc
- ///
- [HarmonyPatch(typeof(ShotgunItem), "__rpc_handler_1329927282")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1329927282(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p) || StartOfRound.Instance.localPlayerController.IsHost)
- {
- if (Core.AntiCheat.InfiniteAmmo.Value)
- {
- var s = (ShotgunItem)target;
- var localClientSendingShootGunRPC = (bool)typeof(ShotgunItem).GetField("localClientSendingShootGunRPC", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(s);
- if (localClientSendingShootGunRPC)
- {
- return true;
- }
- else
- {
- LogInfo(p, "ShotgunItem.ShootGunServerRpc", $"shellsLoaded:{s.shellsLoaded}");
- if (s.shellsLoaded == 0)
- {
- ShowMessage(locale.Msg_GetString("InfiniteAmmo", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.InfiniteAmmo2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- }
- if (Core.AntiCheat.ItemCooldown.Value)
- {
- var id = p.playerSteamId;
- var m = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- if (!sdqcd.ContainsKey(id))
- {
- sdqcd.Add(id, new List());
- }
- if (sdqcd[id].Count > 200)
- {
- sdqcd[id].RemoveRange(0, sdqcd[id].Count - 1);
- }
- if (sdqcd[id].Count(x => x == m) >= 2)
- {
- ShowMessage(locale.Msg_GetString("ItemCooldown", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{item}",locale.Item_GetString("Shotgun") }
- }));
- if (Core.AntiCheat.ItemCooldown2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else
- {
- sdqcd[id].Add(m);
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 挥刀事件
- /// Prefix KnifeItem.HitShovelServerRpc
- ///
- [HarmonyPatch(typeof(KnifeItem), "__rpc_handler_2696735117")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2696735117(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- return CheckCoolDownMethod(rpcParams, 10);
- }
-
- ///
- /// 挥铲事件
- /// Prefix Shovel.HitShovelServerRpc
- ///
- [HarmonyPatch(typeof(Shovel), "__rpc_handler_2096026133")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2096026133(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- return CheckCoolDownMethod(rpcParams, 3);
- }
-
- private static bool CheckCoolDownMethod(__RpcParams rpcParams, int cd)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.ItemCooldown.Value)
- {
- var id = p.playerSteamId;
- var m = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- if (!czcd.ContainsKey(id))
- {
- czcd.Add(id, new List());
- }
- if (czcd[id].Count > 200)
- {
- czcd[id].RemoveRange(0, czcd[id].Count - 1);
- }
- if (czcd[id].Count(x => x == m) >= cd)
- {
- ShowMessage(locale.Msg_GetString("ItemCooldown", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{item}",locale.Item_GetString("Shovel") }
- }));
- if (Core.AntiCheat.ItemCooldown2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- else
- {
- czcd[id].Add(m);
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- ///
- /// 玩家拉杆事件
- /// Prefix StartOfRound.__rpc_handler_1089447320
- ///
- [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_1089447320")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool StartGameServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- StartMatchLever startMatchLever = UnityEngine.Object.FindObjectOfType();
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.ShipConfig.Value && !GameNetworkManager.Instance.gameHasStarted)
- {
- ShowMessage(locale.Msg_GetString("ShipConfig5", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- startMatchLever.triggerScript.interactable = true;
- if (Core.AntiCheat.Ship_Kick.Value)
- {
- KickPlayer(p);
- return false;
- }
- return false;
- }
- else if (StartOfRound.Instance.allPlayerScripts.Count(x => x.isPlayerControlled) >= Core.AntiCheat.ShipConfig2.Value)
- {
- return true;
- }
- else
- {
- startMatchLever.triggerScript.interactable = true;
- ShowMessage(locale.Msg_GetString("ShipConfig2", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{cfg}",Core.AntiCheat.ShipConfig2.Value.ToString() }
- }));
- return false;
- }
- }
- else if (p == null)
- {
- startMatchLever.triggerScript.interactable = true;
- return false;
- }
- return true;
- }
-
- ///
- /// 玩家断开连接时清空SteamId(防止游戏缓存)
- /// Postfix StartOfRound.OnPlayerDC
- ///
- [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
- [HarmonyPostfix]
- [HarmonyWrapSafe]
- public static void OnPlayerDC(int playerObjectNumber, ulong clientId)
- {
- PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerObjectNumber].GetComponent();
- component.playerSteamId = 0;
- return;
- }
-
- public static KeyValuePair lastWhoUseTerminal { get; set; }
- public static PlayerControllerB whoUseTerminal { get; set; }
-
- ///
- /// 踢出玩家
- ///
- /// 玩家
- /// 重新加入
- public static void KickPlayer(PlayerControllerB kick, bool canJoin = false, string Reason = null)
- {
- if (kick.playerClientId == 0)
- {
- return;
- }
- NetworkManager.Singleton.DisconnectClient(kick.playerClientId, $"[{locale.Prefix()}] {locale.Msg_GetString("KickPlayer")}!");
- if (kick.playerSteamId == 0)
- {
- return;
- }
- var s = StartOfRound.Instance;
- ulong playerSteamId = kick.playerSteamId;
- if (!s.KickedClientIds.Contains(playerSteamId) && !canJoin)
- {
- s.KickedClientIds.Add(playerSteamId);
- }
- var terminal = UnityEngine.Object.FindAnyObjectByType();
- LogInfo("terminalInUse" + terminal.placeableObject.inUse);
- LogInfo("whoUseTerminal:" + whoUseTerminal?.playerUsername);
- LogInfo("playerUsername:" + kick?.playerUsername);
- if (whoUseTerminal == kick && terminal.placeableObject.inUse)
- {
- LogInfo("SetTerminalInUseServerRpc");
- terminal.SetTerminalInUseClientRpc(false);
- terminal.terminalInUse = false;
- }
- ShowMessage(locale.Msg_GetString("Kick", new Dictionary() {
- { "{player}",kick.playerUsername }
- }));
- }
-
-
-
- ///
- /// 拉杆事件(正常拉杆都要经过这一层)
- /// Prefix StartMatchLever.PlayLeverPullEffectsServerRpc
- ///
- [HarmonyPatch(typeof(StartMatchLever), "__rpc_handler_2406447821")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_2406447821(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
-
- if (Check(rpcParams, out var p))
- {
- if (UnityEngine.Object.FindAnyObjectByType().leverHasBeenPulled && !StartOfRound.Instance.shipHasLanded)
- {
- return StartGameServerRpc(target, reader, rpcParams);
- }
- else
- {
- return EndGameServerRpc(target, reader, rpcParams);
- }
- }
- else if (p == null)
- {
- UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true;
- return false;
- }
- return true;
- }
-
-
- ///
- /// 出售完货物事件(用于更新反作弊的记录金钱)
- /// Postfix DepositItemsDesk.SellAndDisplayItemProfits
- ///
- [HarmonyPatch(typeof(DepositItemsDesk), "SellAndDisplayItemProfits")]
- [HarmonyPostfix]
- [HarmonyWrapSafe]
- public static void SellAndDisplayItemProfits(int profit, int newGroupCredits)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)
- {
- return;
- }
- Money = newGroupCredits;
- LogInfo($"SetMoney:{Money}");
- }
-
- ///
- /// 玩家销毁物品事件(允许销毁礼物盒和钥匙)
- /// Prefix PlayerControllerB.DespawnHeldObjectServerRpc
- ///
- [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1786952262")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_1786952262(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.DespawnItem.Value)
- {
- LogInfo(p, "PlayerControllerB.DespawnHeldObjectServerRpc", $"itemName:{p.currentlyHeldObjectServer.itemProperties.itemName}");
- if (p.currentlyHeldObjectServer != null && !(p.currentlyHeldObjectServer is GiftBoxItem) && !(p.currentlyHeldObjectServer is KeyItem))
- {
- ShowMessage(locale.Msg_GetString("DespawnItem", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{item}",p.currentlyHeldObjectServer.itemProperties.itemName }
- }));
- if (Core.AntiCheat.DespawnItem2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
-
-
- ///
- /// UI更新事件(房主死亡时加上一票起飞提示)
- /// Postfix HUDManager.Update
- ///
- [HarmonyPatch(typeof(HUDManager), "Update")]
- [HarmonyPostfix]
- [HarmonyWrapSafe]
- public static void Update()
- {
- if (!StartOfRound.Instance.IsHost)
- {
- return;
- }
- if (GameNetworkManager.Instance == null || GameNetworkManager.Instance.localPlayerController == null)
- {
- return;
- }
- if (StartOfRound.Instance.shipIsLeaving || !StartOfRound.Instance.currentLevel.planetHasTime)
- {
- return;
- }
- if (Core.AntiCheat.ShipSetting_OnlyOneVote.Value)
- {
- if (!TimeOfDay.Instance.shipLeavingAlertCalled)
- {
- if (GameNetworkManager.Instance.localPlayerController.isPlayerDead && !string.IsNullOrEmpty(HUDManager.Instance.holdButtonToEndGameEarlyVotesText.text))
- {
- HUDManager.Instance.holdButtonToEndGameEarlyVotesText.text += Environment.NewLine + locale.Msg_GetString("vote");
- }
- }
- }
- }
-
-
- ///
- /// 死亡玩家投票事件(这里处理房主一票起飞)
- /// Postfix TimeOfDay.SetShipLeaveEarlyServerRpc
- ///
- [HarmonyPatch(typeof(TimeOfDay), "__rpc_handler_543987598")]
- [HarmonyPostfix]
- [HarmonyWrapSafe]
- public static void Postfix__rpc_handler_543987598(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (StartOfRound.Instance.localPlayerController.IsHost)
- {
- if (Core.AntiCheat.ShipSetting_OnlyOneVote.Value)
- {
- if (rpcParams.Server.Receive.SenderClientId == 0)
- {
- TimeOfDay.Instance.SetShipLeaveEarlyClientRpc(TimeOfDay.Instance.normalizedTimeOfDay + 0.1f, StartOfRound.Instance.allPlayerScripts.Length);
- }
- }
- }
-
- }
-
- ///
- /// 死亡玩家投票事件(将事件转发到起飞拉杆事件)
- /// Prefix TimeOfDay.SetShipLeaveEarlyServerRpc
- ///
- [HarmonyPatch(typeof(TimeOfDay), "__rpc_handler_543987598")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_543987598(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- int num = StartOfRound.Instance.connectedPlayersAmount + 1 - StartOfRound.Instance.livingPlayers;
- string msg = locale.Msg_GetString("vote_player", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{now}",(TimeOfDay.Instance.votesForShipToLeaveEarly + 1).ToString() },
- { "{max}",num.ToString() }
- });
- ShowMessageHostOnly(msg);
- if (TimeOfDay.Instance.votesForShipToLeaveEarly + 1 >= num)
- {
- LogInfo("Vote EndGame");
- return EndGameServerRpc(target, reader, rpcParams);
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- public static void ShowMessageHostOnly(string msg)
- {
- LogInfo($"ShowMessageHostOnly -> {msg}");
- AccessTools.DeclaredMethod(typeof(HUDManager), "AddChatMessage").Invoke(HUDManager.Instance, new object[] { msg, "", -1, false });
- }
-
- ///
- /// 起飞拉杆事件
- /// Prefix StartOfRound.EndGameServerRpc
- ///
- [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_2028434619")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool EndGameServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- ByteUnpacker.ReadValueBitPacked(reader, out int num);
- reader.Seek(0);
- LogInfo(p, "StartOfRound.EndGameServerRpc", $"num:{num}", $"shipHasLanded:{StartOfRound.Instance.shipHasLanded}");
- if (num == 0 && p.playerClientId != 0)
- {
- UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true;
- return false;
- }
- if (!StartOfRound.Instance.shipHasLanded)
- {
- UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true;
- return false;
- }
- if (TimeOfDay.Instance.shipLeavingAlertCalled)
- {
- return true;
- }
- var hour = int.Parse(Core.AntiCheat.ShipConfig3.Value.Split(':')[0]);
- var min = int.Parse(Core.AntiCheat.ShipConfig3.Value.Split(':')[1]);
- var time = (int)(TimeOfDay.Instance.normalizedTimeOfDay * (60f * TimeOfDay.Instance.numberOfHours)) + 360;
- int time2 = (int)Mathf.Floor((float)(time / 60));
- bool pm = false;
- if (time2 > 12)
- {
- pm = true;
- time2 %= 12;
- }
- time = time % 60;
- if (pm)
- {
- time2 += 12;
- }
- var live = StartOfRound.Instance.allPlayerScripts.Where(x => x.isPlayerControlled && !x.isPlayerDead);
-
- if (live.Count() == 1 && live.FirstOrDefault().isInHangarShipRoom)
- {
- return true;
- }
- decimal p1 = Math.Round((decimal)live.Count() * (decimal)(Core.AntiCheat.ShipConfig4.Value / 100m), 2);
- decimal p2 = StartOfRound.Instance.allPlayerScripts.Count(x => x.isPlayerControlled && x.isInHangarShipRoom); //
- if (StartOfRound.Instance.currentLevel.PlanetName.Contains("Gordion"))
- {
- time2 = hour;
- time = min;
- }
- if (hour <= time2 && min <= time && p2 >= p1)
- {
- return true;
- }
- else
- {
- ShowMessage(locale.Msg_GetString("ShipConfig4", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{player_count}",p1.ToString() },
- { "{cfg4}",Core.AntiCheat.ShipConfig4.Value.ToString() },
- { "{cfg3}",$"{hour.ToString("00")}:{min.ToString("00")}" },
- { "{game_time}",$"{time2.ToString("00")}:{time.ToString("00")}" }
- }));
- UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true;
- return false;
- }
- }
- else if (p == null)
- {
- UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true;
- return false;
- }
- return true;
- }
-
- ///
- /// 放置飞船装饰事件(检测)
- /// Prefix ShipBuildModeManager.PlaceShipObjectServerRpc
- ///
- [HarmonyPatch(typeof(ShipBuildModeManager), "__rpc_handler_861494715")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_861494715(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost)
- {
- if (Core.AntiCheat.ShipBuild.Value)
- {
- Vector3 newPosition;
- reader.ReadValueSafe(out newPosition);
- Vector3 newRotation;
- reader.ReadValueSafe(out newRotation);
- reader.ReadValueSafe(out NetworkObjectReference objectRef, default);
- reader.Seek(0);
- if (objectRef.TryGet(out var networkObject, null))
- {
- PlaceableShipObject placingObject = networkObject.gameObject.GetComponentInChildren();
- LogInfo(p, "ShipBuildModeManager.PlaceShipObjectServerRpc", $"object:{placingObject.parentObject.name}", $"newPosition:{newPosition.ToString()}", $"newRotation:{newRotation}");
- //LogInfo($"newRotation:{newRotation}|mainMesh:{placingObject.mainMesh.transform.eulerAngles.ToString()}");
- if (Math.Floor(newRotation.x) != Math.Floor(placingObject.mainMesh.transform.eulerAngles.x) || Math.Floor(newRotation.z) != Math.Floor(placingObject.mainMesh.transform.eulerAngles.z))
- {
- ShowMessage(locale.Msg_GetString("ShipBuild", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{position}",newRotation.ToString() },
- { "{object}",placingObject.parentObject.name }
- }), locale.Msg_GetString("ShipBuild"));
- if (Core.AntiCheat.ShipBuild2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- var ShipBuildModeManager = (ShipBuildModeManager)target;
- //LogInfo($"{p.playerUsername}|ShipBuildModeManager.PlaceShipObjectServerRpc|placingObject:{placingObject.parentObject.name},{placingObject.unlockableID}|newPosition:{newPosition}|newRotation:{newRotation}");
- if (!StartOfRound.Instance.shipInnerRoomBounds.bounds.Contains(newPosition))
- {
- ShowMessage(locale.Msg_GetString("ShipBuild", new Dictionary() {
- { "{player}",p.playerUsername },
- { "{position}",newPosition.ToString() }
- }), locale.Msg_GetString("ShipBuild"));
- if (Core.AntiCheat.ShipBuild2.Value)
- {
- KickPlayer(p);
- }
- return false;
- }
- }
- }
- return true;
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
-
- ///
- /// 离开地雷事件(记录是否触发过)
- /// Prefix Landmine.OnTriggerExit
- ///
- [HarmonyPatch(typeof(Landmine), "OnTriggerExit")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool TriggerMineOnLocalClientByExiting(Landmine __instance, Collider other)
- {
- if (!StartOfRound.Instance.IsHost)
- {
- return true;
- }
- if (__instance.hasExploded)
- {
- return true;
- }
- if (!__instance.gameObject.activeSelf)
- {
- return true;
- }
- bool mineActivated = (bool)AccessTools.DeclaredField(typeof(Landmine), "mineActivated").GetValue(__instance);
- if (!mineActivated)
- {
- return true;
- }
- int id = __instance.GetInstanceID();
- if (!landMines.Contains(id))
- {
- landMines.Add(id);
- }
- //LogInfo($"Landmine.OnTriggerExit({id})");
- return true;
- }
-
- ///
- /// 地雷引爆事件(检测)
- /// Prefix Landmine.ExplodeMineServerRpc
- ///
- [HarmonyPatch(typeof(Landmine), "__rpc_handler_3032666565")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3032666565(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Landmine.Value)
- {
- var lm = (Landmine)target;
- int id = lm.GetInstanceID();
- //LogInfo(p, "Landmine.ExplodeMineServerRpc", $"LandMineId:{id}");
- if (!landMines.Contains(id) && !lm.hasExploded)
- {
- if(recentPlayerPositions.TryGetValue(p.playerSteamId,out var postions)) {
- if (!postions.Any(x => Vector3.Distance(x.pos, lm.transform.position) < 5))
- {
- ShowMessage(locale.Msg_GetString("Landmine", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Landmine2.Value)
- {
- KickPlayer(p);
- }
- }
- }
-
- }
- }
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 老板激怒事件(正常被激怒只有主机才会调用SeverRpc,客户端调用就是有问题)
- /// Prefix DepositItemsDesk.AttackPlayersServerRpc
- ///
- [HarmonyPatch(typeof(DepositItemsDesk), "__rpc_handler_3230280218")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static bool __rpc_handler_3230280218(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Check(rpcParams, out var p))
- {
- if (Core.AntiCheat.Boss.Value)
- {
- ShowMessage(locale.Msg_GetString("Boss", new Dictionary() {
- { "{player}",p.playerUsername }
- }));
- if (Core.AntiCheat.Boss2.Value)
- {
- KickPlayer(p);
- }
- }
- return false;
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
-
- ///
- /// 自动添加AC标识
- /// Prefix GameNetworkManager.StartHost
- ///
- [HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- public static void StartHost()
- {
- if (Core.AntiCheat.Prefix.Value.IsNullOrWhiteSpace())
- {
- return;
- }
- var setting = GameNetworkManager.Instance.lobbyHostSettings;
- string rawText = setting.lobbyName;
- rawText = rawText.Replace("【", "[").Replace("】", "]");
- List labels = new List();
- var match = Regex.Match(rawText, "^\\[(.*?)\\]");
- if (match.Success)
- {
- var txt = match.Groups[1].Value;
- labels.AddRange(txt.Split('/'));
- rawText = rawText.Remove(0, match.Groups[0].Value.Length).TrimStart();
- }
- if (!labels.Any(x => x == Core.AntiCheat.Prefix.Value))
- {
- labels.Add(Core.AntiCheat.Prefix.Value);
- }
- setting.lobbyName = "[" + string.Join("/", labels) + "]" + " " + rawText;
- }
- }
-}
diff --git a/AntiCheat/Patch/PlayerControllerBPatch.cs b/AntiCheat/Patch/PlayerControllerBPatch.cs
deleted file mode 100644
index dcabee3..0000000
--- a/AntiCheat/Patch/PlayerControllerBPatch.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using AntiCheat.Core;
-
-using GameNetcodeStuff;
-
-using HarmonyLib;
-
-using Steamworks;
-using Steamworks.Data;
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net.Http.Headers;
-using System.Runtime.Remoting.Messaging;
-using System.Security.Permissions;
-using System.Text;
-using System.Threading.Tasks;
-
-using Unity.Netcode;
-
-using UnityEngine;
-
-namespace AntiCheat.Patch
-{
- [HarmonyPatch(typeof(PlayerControllerB))]
- [HarmonyWrapSafe]
- public static class PlayerControllerBPatch
- {
- [HarmonyPostfix]
- [HarmonyPatch("ConnectClientToPlayerObject")]
- public static void ConnectClientToPlayerObject(PlayerControllerB __instance)
- {
- if (__instance.isHostPlayerObject && StartOfRound.Instance.IsHost)
- {
- if (File.Exists("AntiCheat.log"))
- {
- File.Delete("AntiCheat.log");
- }
- Patches.explosions = new List();
- Patches.ConnectionIdtoSteamIdMap = new Dictionary();
- HUDManagerPatch.SyncAllPlayerLevelsServerRpcCalls = new List();
- StartOfRoundPatch.SyncShipUnlockablesServerRpcCalls = new List();
- StartOfRoundPatch.SyncAlreadyHeldObjectsServerRpcCalls = new List();
- }
- }
-
- ///
- /// DropAllHeldItemsServerRpc
- ///
- ///
- [HarmonyPatch("__rpc_handler_760742013")]
- [HarmonyPrefix]
- public static bool DropAllHeldItemsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!Patches.Check(rpcParams, out var p))
- return p != null;
- AntiCheat.Core.AntiCheat.LogInfo(p, $"PlayerControllerB.DropAllHeldItemsServerRpc");
- return true;
- }
-
- ///
- /// 玩家发送SteamID事件(目前还没遇到过伪造)
- /// Prefix PlayerControllerB.SendNewPlayerValuesServerRpc
- ///
- [HarmonyPatch("__rpc_handler_2504133785")]
- [HarmonyPrefix]
- public static bool SendNewPlayerValuesServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (!StartOfRound.Instance.localPlayerController.IsHost)//非主机
- {
- return true;
- }
- if (rpcParams.Server.Receive.SenderClientId == 0)
- {
- return true;
- }
- ByteUnpacker.ReadValueBitPacked(reader, out ulong newPlayerSteamId);
- reader.Seek(0);
- ulong steamId = Patches.ConnectionIdtoSteamIdMap[Patches.ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId)];
- Friend friend = new Friend(steamId);
- if (newPlayerSteamId != steamId)
- {
- NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId);
- AntiCheat.Core.AntiCheat.LogInfo($"玩家 {friend.Name}({steamId}) 伪造SteamID({newPlayerSteamId})加入游戏");
- return false;
- }
- else
- {
- string msg = Core.AntiCheat.PlayerJoin.Value.Replace("{player}", friend.Name);
- Patches.AddTextMessageClientRpc(msg);
- }
- return true;
- }
- }
-}
diff --git a/AntiCheat/Patch/TerminalAccessibleObjectPatch.cs b/AntiCheat/Patch/TerminalAccessibleObjectPatch.cs
deleted file mode 100644
index 7f60b33..0000000
--- a/AntiCheat/Patch/TerminalAccessibleObjectPatch.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using HarmonyLib;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Unity.Netcode;
-
-namespace AntiCheat.Patch
-{
- [HarmonyPatch(typeof(TerminalAccessibleObject))]
- [HarmonyWrapSafe]
- public static class TerminalAccessibleObjectPatch
- {
- [HarmonyPatch("__rpc_handler_1181174413")]
- [HarmonyPrefix]
- public static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
- {
- if (Patches.Check(rpcParams, out var p))
- {
- AntiCheat.Core.AntiCheat.LogInfo(p, "TerminalAccessibleObject.SetDoorOpenServerRpc");
- }
- else if (p == null)
- {
- return false;
- }
- return true;
- }
- }
-}
diff --git a/AntiCheat/Patches/LandminePatch.cs b/AntiCheat/Patches/LandminePatch.cs
new file mode 100644
index 0000000..901a935
--- /dev/null
+++ b/AntiCheat/Patches/LandminePatch.cs
@@ -0,0 +1,117 @@
+using AntiCheat;
+
+using HarmonyLib;
+
+using System;
+using System.Collections.Generic;
+
+using Unity.Netcode;
+
+using UnityEngine;
+
+[HarmonyPatch(typeof(Landmine))]
+[HarmonyWrapSafe]
+public static class LandminePatch
+{
+ private static readonly HashSet _landMines = new HashSet();
+ private static readonly List _explosions = new List();
+ private static readonly object _explosionsLock = new object();
+
+ private static readonly AccessTools.FieldRef _mineActivatedField =
+ AccessTools.FieldRefAccess("mineActivated");
+
+ private const int EXPLOSION_EXPIRE_SECONDS = 10;
+ private const float MINE_TRIGGER_DISTANCE = 5f;
+
+ [HarmonyPrefix]
+ [HarmonyPatch("SpawnExplosion")]
+ public static void SpawnExplosion(Vector3 explosionPosition)
+ {
+ AntiCheatPlugin.LogInfo($"Landmine.SpawnExplosion -> {explosionPosition}");
+
+ lock (_explosionsLock)
+ {
+ _explosions.RemoveAll(x => x.CreateDateTime.AddSeconds(EXPLOSION_EXPIRE_SECONDS) < DateTime.UtcNow);
+
+ _explosions.Add(new ExplosionData(explosionPosition));
+ }
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch("OnTriggerExit")]
+ public static bool TriggerMineOnLocalClientByExiting(Landmine __instance, Collider other)
+ {
+ if (!StartOfRound.Instance.IsHost ||
+ __instance.hasExploded ||
+ !__instance.gameObject.activeSelf)
+ {
+ return true;
+ }
+
+ if (!_mineActivatedField(__instance))
+ {
+ return true;
+ }
+
+ lock (_landMines)
+ {
+ _landMines.Add(__instance.GetInstanceID());
+ }
+
+ return true;
+ }
+
+ [HarmonyPatch("__rpc_handler_3032666565")]
+ [HarmonyPrefix]
+ [HarmonyWrapSafe]
+ public static bool __rpc_handler_3032666565(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
+ {
+ if (!PluginConfig.Landmine.Enable || !Check(rpcParams, out var p) || p == null)
+ {
+ return p != null; // 如果 p 为 null 返回 false
+ }
+
+ var lm = (Landmine)target;
+ int id = lm.GetInstanceID();
+
+ lock (_landMines)
+ {
+ if (_landMines.Contains(id) || lm.hasExploded)
+ {
+ return true;
+ }
+ }
+
+ // 使用距离平方比较,避免开方
+ const float triggerDistanceSq = MINE_TRIGGER_DISTANCE * MINE_TRIGGER_DISTANCE;
+
+ if (recentPlayerPositions.TryGetValue(p.playerSteamId, out var positions) &&
+ !positions.Any(x => (x.pos - lm.transform.position).sqrMagnitude < triggerDistanceSq))
+ {
+ AntiCheatPlugin.ShowMessage(locale.Msg_GetString("Landmine", new Dictionary
+ {
+ ["{player}"] = p.playerUsername
+ }));
+
+ if (PluginConfig.Landmine.Kick)
+ {
+ KickPlayer(p);
+ }
+ }
+
+ return true;
+ }
+}
+
+public class ExplosionData
+{
+ public List CalledClient { get; } = new List();
+ public Vector3 ExplosionPostion { get; set; }
+ public DateTime CreateDateTime { get; set; }
+
+ public ExplosionData(Vector3 position)
+ {
+ ExplosionPostion = position;
+ CreateDateTime = DateTime.UtcNow;
+ }
+}
\ No newline at end of file
diff --git a/AntiCheat/Patch/RoundManagerPatch.cs b/AntiCheat/Patches/RoundManagerPatch.cs
similarity index 78%
rename from AntiCheat/Patch/RoundManagerPatch.cs
rename to AntiCheat/Patches/RoundManagerPatch.cs
index 9d82f71..fc0a655 100644
--- a/AntiCheat/Patch/RoundManagerPatch.cs
+++ b/AntiCheat/Patches/RoundManagerPatch.cs
@@ -2,13 +2,11 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using Unity.Netcode;
-namespace AntiCheat.Patch
+namespace AntiCheat.Patches
{
[HarmonyPatch(typeof(RoundManager))]
[HarmonyWrapSafe]
@@ -24,7 +22,7 @@ public static bool FinishedGeneratingLevelServerRpc(NetworkBehaviour target, Fas
{
int playersFinishedGeneratingFloorCount = (RoundManager.Instance.playersFinishedGeneratingFloor.Count + 1);
- AntiCheat.Core.AntiCheat.LogInfo(p, $"RoundManager.FinishedGeneratingLevelServerRpc", $"playersFinishedGeneratingFloor:{playersFinishedGeneratingFloorCount}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}");
+ AntiCheatPlugin.LogInfo(p, $"RoundManager.FinishedGeneratingLevelServerRpc", $"playersFinishedGeneratingFloor:{playersFinishedGeneratingFloorCount}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}");
CallFinishedGeneratingLevelServerRpc.Add(p.playerSteamId);
if (playersFinishedGeneratingFloorCount < GameNetworkManager.Instance.connectedPlayers && playersFinishedGeneratingFloorCount + 5 > GameNetworkManager.Instance.connectedPlayers)
{
@@ -42,12 +40,12 @@ public static bool FinishedGeneratingLevelServerRpc(NetworkBehaviour target, Fas
}
if (!string.IsNullOrWhiteSpace(sb.ToString()))
{
- AntiCheat.Core.AntiCheat.LogInfo($"FinishedGeneratingLevelServerRpc Wait For:{sb.ToString()}");
+ AntiCheatPlugin.LogInfo($"FinishedGeneratingLevelServerRpc Wait For:{sb.ToString()}");
}
}
if (playersFinishedGeneratingFloorCount == GameNetworkManager.Instance.connectedPlayers)
{
- AntiCheat.Core.AntiCheat.LogInfo($"FinishedGeneratingLevelServerRpc All Players Loaded");
+ AntiCheatPlugin.LogInfo($"FinishedGeneratingLevelServerRpc All Players Loaded");
CallFinishedGeneratingLevelServerRpc = new List();
}
}
diff --git a/AntiCheat/Patch/ShipTeleporterPatch.cs b/AntiCheat/Patches/ShipTeleporterPatch.cs
similarity index 73%
rename from AntiCheat/Patch/ShipTeleporterPatch.cs
rename to AntiCheat/Patches/ShipTeleporterPatch.cs
index 881379f..6ac435b 100644
--- a/AntiCheat/Patch/ShipTeleporterPatch.cs
+++ b/AntiCheat/Patches/ShipTeleporterPatch.cs
@@ -2,13 +2,11 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using Unity.Netcode;
-namespace AntiCheat.Patch
+namespace AntiCheat.Patches
{
[HarmonyPatch(typeof(ShipTeleporter))]
[HarmonyWrapSafe]
@@ -21,18 +19,18 @@ public static class ShipTeleporterPatch
[HarmonyPatch("__rpc_handler_389447712")]
public static bool PressTeleportButtonServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
- if (Patches.Check(rpcParams, out var p))
+ if (AntiCheatPlugin.Check(rpcParams, out var p))
{
var shiptp = (ShipTeleporter)target;
- Core.AntiCheat.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"isInverseTeleporter:{shiptp.isInverseTeleporter}");
- if (shiptp.isInverseTeleporter && !(bool)AccessTools.DeclaredMethod(typeof(ShipTeleporter), "CanUseInverseTeleporter").Invoke(shiptp,null))
+ AntiCheatPlugin.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"isInverseTeleporter:{shiptp.isInverseTeleporter}");
+ if (shiptp.isInverseTeleporter && !(bool)AccessTools.DeclaredMethod(typeof(ShipTeleporter), "CanUseInverseTeleporter").Invoke(shiptp, null))
{
return false;
}
var cooldownTime = (float)AccessTools.DeclaredField(typeof(ShipTeleporter), "cooldownTime").GetValue(shiptp);
if (cooldownTime > 0)
{
- Core.AntiCheat.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"cooldownAmount:{cooldownTime}");
+ AntiCheatPlugin.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"cooldownAmount:{cooldownTime}");
return false;
}
return true;
diff --git a/AntiCheat/Patch/StartOfRoundPatch.cs b/AntiCheat/Patches/StartOfRoundPatch.cs
similarity index 76%
rename from AntiCheat/Patch/StartOfRoundPatch.cs
rename to AntiCheat/Patches/StartOfRoundPatch.cs
index 01bfdd7..b8a1f95 100644
--- a/AntiCheat/Patch/StartOfRoundPatch.cs
+++ b/AntiCheat/Patches/StartOfRoundPatch.cs
@@ -1,19 +1,13 @@
-using AntiCheat.Core;
-
-using HarmonyLib;
+using HarmonyLib;
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using Unity.Netcode;
-using UnityEngine;
-
-namespace AntiCheat
+namespace AntiCheat.Patches
{
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyWrapSafe]
@@ -30,13 +24,13 @@ public static class StartOfRoundPatch
public static bool SyncAlreadyHeldObjectsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
var steamId = Patches.ConnectionIdtoSteamIdMap[Patches.ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId)];
- AntiCheat.Core.AntiCheat.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|32");
+ AntiCheatPlugin.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|32");
if (SyncAlreadyHeldObjectsServerRpcCalls.Contains(steamId))
{
- AntiCheat.Core.AntiCheat.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|36");
+ AntiCheatPlugin.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|36");
return false;
}
- AntiCheat.Core.AntiCheat.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|39");
+ AntiCheatPlugin.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|39");
SyncAlreadyHeldObjectsServerRpcCalls.Add(steamId);
return true;
}
@@ -52,7 +46,7 @@ public static bool PlayerHasRevivedServerRpc(NetworkBehaviour target, FastBuffer
if (Patches.Check(rpcParams, out var p))
{
int playersRevived = (int)AccessTools.DeclaredField(typeof(StartOfRound), "playersRevived").GetValue(StartOfRound.Instance);
- AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.PlayerHasRevivedServerRpc", $"playersRevived:{(playersRevived + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}");
+ AntiCheatPlugin.LogInfo(p, $"StartOfRound.PlayerHasRevivedServerRpc", $"playersRevived:{(playersRevived + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}");
CallPlayerHasRevivedServerRpc.Add(p.playerSteamId);
if (playersRevived < GameNetworkManager.Instance.connectedPlayers && playersRevived + 5 > GameNetworkManager.Instance.connectedPlayers)
{
@@ -70,13 +64,13 @@ public static bool PlayerHasRevivedServerRpc(NetworkBehaviour target, FastBuffer
}
if (!string.IsNullOrWhiteSpace(sb.ToString()))
{
- AntiCheat.Core.AntiCheat.LogInfo($"PlayerHasRevivedServerRpc Wait For:{sb.ToString()}");
+ AntiCheatPlugin.LogInfo($"PlayerHasRevivedServerRpc Wait For:{sb.ToString()}");
}
-
+
}
if ((playersRevived + 1) == GameNetworkManager.Instance.connectedPlayers)
{
- AntiCheat.Core.AntiCheat.LogInfo($"PlayerHasRevivedServerRpc All Players Loaded");
+ AntiCheatPlugin.LogInfo($"PlayerHasRevivedServerRpc All Players Loaded");
CallPlayerHasRevivedServerRpc = new List();
}
}
@@ -101,7 +95,7 @@ public static bool PlayerLoadedServerRpc(NetworkBehaviour target, FastBufferRead
if (Patches.Check(rpcParams, out var p))
{
int fullyLoadedPlayers = StartOfRound.Instance.fullyLoadedPlayers.Count;
- AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.PlayerLoadedServerRpc", $"fullyLoadedPlayers:{(fullyLoadedPlayers + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}");
+ AntiCheatPlugin.LogInfo(p, $"StartOfRound.PlayerLoadedServerRpc", $"fullyLoadedPlayers:{(fullyLoadedPlayers + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}");
CallPlayerLoadedServerRpc.Add(p.playerSteamId);
if (fullyLoadedPlayers < GameNetworkManager.Instance.connectedPlayers && fullyLoadedPlayers + 5 > GameNetworkManager.Instance.connectedPlayers)
{
@@ -119,13 +113,13 @@ public static bool PlayerLoadedServerRpc(NetworkBehaviour target, FastBufferRead
}
if (!string.IsNullOrWhiteSpace(sb.ToString()))
{
- AntiCheat.Core.AntiCheat.LogInfo($"PlayerLoadedServerRpc Wait For:{sb.ToString()}");
+ AntiCheatPlugin.LogInfo($"PlayerLoadedServerRpc Wait For:{sb.ToString()}");
}
}
if ((fullyLoadedPlayers + 1) == GameNetworkManager.Instance.connectedPlayers)
{
CallPlayerLoadedServerRpc = new List();
- AntiCheat.Core.AntiCheat.LogInfo($"PlayerLoadedServerRpc All Players Loaded");
+ AntiCheatPlugin.LogInfo($"PlayerLoadedServerRpc All Players Loaded");
}
}
return true;
@@ -140,13 +134,13 @@ public static bool __rpc_handler_744998938(NetworkBehaviour target, FastBufferRe
{
if (Patches.Check(rpcParams, out var p))
{
- AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "140");
+ AntiCheatPlugin.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "140");
if (SyncShipUnlockablesServerRpcCalls.Contains(p.playerSteamId))
{
- AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "144");
+ AntiCheatPlugin.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "144");
return false;
}
- AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "146");
+ AntiCheatPlugin.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "146");
SyncShipUnlockablesServerRpcCalls.Add(p.playerSteamId);
return true;
}
diff --git a/AntiCheat/Patch/TerminalPatch.cs b/AntiCheat/Patches/TerminalPatch.cs
similarity index 87%
rename from AntiCheat/Patch/TerminalPatch.cs
rename to AntiCheat/Patches/TerminalPatch.cs
index 3d5998d..4cb160d 100644
--- a/AntiCheat/Patch/TerminalPatch.cs
+++ b/AntiCheat/Patches/TerminalPatch.cs
@@ -1,18 +1,13 @@
-using AntiCheat.Locale;
-
-using HarmonyLib;
+using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using Unity.Netcode;
-using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
-
-namespace AntiCheat.Patch
+namespace AntiCheat.Patches
{
[HarmonyPatch(typeof(Terminal))]
[HarmonyWrapSafe]
@@ -29,7 +24,7 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r
{
if (Patches.Check(rpcParams, out var p))
{
- if (Core.AntiCheat.RemoteTerminal.Value)
+ if (PluginConfig.RemoteTerminal.Value)
{
if (!Patches.CheckRemoteTerminal(p, "Terminal.BuyItemsServerRpc"))
{
@@ -44,7 +39,7 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r
}
ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCredits);
reader.Seek(0);
- if (Core.AntiCheat.FreeBuy.Value)
+ if (PluginConfig.FreeBuy.Value)
{
//LogInfo("__rpc_handler_4003509079|boughtItems:" + string.Join(",", boughtItems) + "|newGroupCredits:" + newGroupCredits + "|Money:" + Money);
if (Patches.Money == newGroupCredits || Patches.Money == 0)
@@ -54,7 +49,7 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r
{ "{player}",p.playerUsername },
{ "{items}", string.Join(",", boughtItems.GroupBy(x => terminal.buyableItemsList[x].itemName).Select(g => g.Count() == 1 ? g.Key : $"{g.Key}*{g.Count()}")) }
}));
- if (Core.AntiCheat.FreeBuy2.Value)
+ if (PluginConfig.FreeBuy_Kick.Value)
{
Patches.KickPlayer(p);
}
@@ -66,14 +61,14 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r
{ "{player}",p.playerUsername },
{ "{Money}",(newGroupCredits - Patches.Money).ToString() }
}));
- if (Core.AntiCheat.FreeBuy2.Value)
+ if (PluginConfig.FreeBuy_Kick.Value)
{
Patches.KickPlayer(p);
}
return false;
}
}
- if (Core.AntiCheat.OperationLog.Value)
+ if (PluginConfig.OperationLog.Value)
{
var terminal = (Terminal)target;
if (boughtItems.Count(x => x < terminal.buyableItemsList.Length) == boughtItems.Count())
@@ -98,7 +93,7 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader
{
if (Patches.Check(rpcParams, out var p) || true)
{
- if (Core.AntiCheat.RemoteTerminal.Value)
+ if (PluginConfig.RemoteTerminal.Value)
{
if (!Patches.CheckRemoteTerminal(p, "Terminal.BuyVehicleServerRpc"))
{
@@ -109,9 +104,9 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader
ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCredits);
reader.ReadValueSafe(out bool useWarranty, default);
reader.Seek(0);
- if (Core.AntiCheat.FreeBuy.Value)
+ if (PluginConfig.FreeBuy.Value)
{
- if(useWarranty && (bool)AccessTools.DeclaredField(typeof(Terminal), "hasWarrantyTicket").GetValue(target))
+ if (useWarranty && (bool)AccessTools.DeclaredField(typeof(Terminal), "hasWarrantyTicket").GetValue(target))
{
//可以免费购买
}
@@ -121,7 +116,7 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader
{ "{player}",p.playerUsername },
{ "{items}", Patches.locale.Item_GetString("Cruiser") }
}));
- if (Core.AntiCheat.FreeBuy2.Value)
+ if (PluginConfig.FreeBuy_Kick.Value)
{
Patches.KickPlayer(p);
}
@@ -133,14 +128,14 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader
{ "{player}",p.playerUsername },
{ "{Money}",(newGroupCredits - Patches.Money).ToString() }
}));
- if (Core.AntiCheat.FreeBuy2.Value)
+ if (PluginConfig.FreeBuy_Kick.Value)
{
Patches.KickPlayer(p);
}
return false;
}
}
- if (Core.AntiCheat.OperationLog.Value)
+ if (PluginConfig.OperationLog.Value)
{
var terminal = (Terminal)target;
Patches.ShowMessageHostOnly(Patches.locale.OperationLog_GetString("BuyItem", new Dictionary() {
diff --git a/AntiCheat/Patch/TurretPatch.cs b/AntiCheat/Patches/TurretPatch.cs
similarity index 85%
rename from AntiCheat/Patch/TurretPatch.cs
rename to AntiCheat/Patches/TurretPatch.cs
index b6326b4..355c218 100644
--- a/AntiCheat/Patch/TurretPatch.cs
+++ b/AntiCheat/Patches/TurretPatch.cs
@@ -1,20 +1,14 @@
-using AntiCheat.Core;
-using AntiCheat.Locale;
-
-using HarmonyLib;
+using HarmonyLib;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Security.Policy;
using System.Text;
-using System.Threading.Tasks;
using Unity.Netcode;
using UnityEngine;
-namespace AntiCheat.Patch
+namespace AntiCheat.Patches
{
[HarmonyPatch(typeof(Turret))]
[HarmonyWrapSafe]
@@ -32,7 +26,7 @@ public static bool EnterBerserkModeServerRpc(NetworkBehaviour target, FastBuffer
{
if (Patches.Check(rpcParams, out var p))
{
- if (Core.AntiCheat.Turret.Value)
+ if (PluginConfig.Turret.Enable)
{
var obj = p.ItemSlots[p.currentItemSlot];
if (obj != null && (Patches.isShovel(obj) || Patches.isKnife(obj)))
@@ -45,7 +39,7 @@ public static bool EnterBerserkModeServerRpc(NetworkBehaviour target, FastBuffer
{ "{player}",p.playerUsername },
{ "{Distance}",v.ToString() }
}));
- if (Core.AntiCheat.Turret2.Value)
+ if (PluginConfig.Turret.Kick)
{
Patches.KickPlayer(p);
}
@@ -57,7 +51,7 @@ public static bool EnterBerserkModeServerRpc(NetworkBehaviour target, FastBuffer
Patches.ShowMessage(Patches.locale.Msg_GetString("Turret2", new Dictionary() {
{ "{player}",p.playerUsername }
}));
- if (Core.AntiCheat.Turret2.Value)
+ if (PluginConfig.Turret.Kick)
{
Patches.KickPlayer(p);
}
@@ -79,7 +73,7 @@ public static bool ToggleTurretServerRpc(NetworkBehaviour target, FastBufferRead
{
if (Patches.Check(rpcParams, out var p))
{
- if (AntiCheat.Core.AntiCheat.RemoteTerminal.Value)
+ if (PluginConfig.RemoteTerminal.Enable)
{
bool remote = Patches.CheckRemoteTerminal(p, "Turret.ToggleTurretServerRpc");
if (!remote)
@@ -87,8 +81,8 @@ public static bool ToggleTurretServerRpc(NetworkBehaviour target, FastBufferRead
return false;
}
}
- }
- else if (p == null)
+ }
+ else if (p == null)
{
return false;
}
diff --git a/AntiCheat/PluginConfig.cs b/AntiCheat/PluginConfig.cs
new file mode 100644
index 0000000..0c792e3
--- /dev/null
+++ b/AntiCheat/PluginConfig.cs
@@ -0,0 +1,284 @@
+using AntiCheat.Utils;
+
+using BepInEx;
+using BepInEx.Configuration;
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using static UnityEngine.InputSystem.InputRemoting;
+
+namespace AntiCheat
+{
+ internal class PluginConfig
+ {
+ public static FeatureConfig Jetpack = null!;
+ public static FeatureConfig ShipBuild = null!;
+ public static FeatureConfig Landmine = null!;
+ public static FeatureConfig InfiniteAmmo = null!;
+ public static FeatureConfig Mask = null!;
+ public static FeatureConfig Gift = null!;
+ public static FeatureConfig Turret = null!;
+ public static FeatureConfig Invisibility = null!;
+ public static FeatureConfig KillEnemy = null!;
+ public static FeatureConfig SpawnWebTrap = null!;
+ public static FeatureConfig Map = null!;
+ public static FeatureConfig FreeBuy = null!;
+ public static FeatureConfig RemoteTerminal = null!;
+ public static FeatureConfig Nameless = null!;
+ public static FeatureConfig DespawnItem = null!;
+ public static FeatureConfig ChatReal = null!;
+ public static FeatureConfig ShipLight = null!;
+ public static FeatureConfig TerminalNoise = null!;
+ public static FeatureConfig ItemCooldown = null!;
+ public static FeatureConfig Health = null!;
+ public static FeatureConfig RPCReport = null!;
+ public static FeatureConfig Boss = null!;
+ public static FeatureConfig Shovel = null!;
+ public static FeatureConfig GrabObject = null!;
+
+ public static ConfigEntry Prefix = null!;
+ public static ConfigEntry PlayerJoin = null!;
+ public static ConfigEntry Log = null!;
+ public static ConfigEntry OperationLog = null!;
+ public static ConfigEntry ShipSetting_OnlyOneVote = null!;
+ public static ConfigEntry ShipSetting_ChangToFreeMoon = null!;
+ public static ConfigEntry ShipLight_Cooldown = null!;
+ public static ConfigEntry TerminalNoise_Cooldown = null!;
+ public static ConfigEntry ChatReal_Cooldown = null!;
+ public static ConfigEntry DetectedMessageType = null!;
+ public enum MessageType
+ {
+ GUI,
+ HostChat,
+ PublicChat
+ }
+
+
+
+ //public static ConfigEntry Shovel = null!;
+ //public static ConfigEntry Shovel_Kick = null!;
+ //public static ConfigEntry Shovel3 = null!;
+
+
+
+ //public static ConfigEntry ShipConfig = null!;
+ //public static ConfigEntry ShipConfig2 = null!;
+ //public static ConfigEntry ShipConfig3 = null!;
+ //public static ConfigEntry ShipConfig4 = null!;
+ //public static ConfigEntry Ship_Kick = null!;
+
+ //public static ConfigEntry ShipBuild = null!;
+ //public static ConfigEntry ShipBuild_Kick = null!;
+
+ //public static ConfigEntry ShipLight = null!;
+
+ //public static ConfigEntry TerminalNoise = null!;
+
+ //public static ConfigEntry DespawnItem = null!;
+ //public static ConfigEntry DespawnItem_Kick = null!;
+
+ //public static ConfigEntry