using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CustomCompany.Behaviour; using CustomCompany.Patch; using GameNetcodeStuff; using HarmonyLib; using LitJson; using OPJosMod.ReviveCompany; using OPJosMod.ReviveCompany.CustomRpc; using Steamworks; using Steamworks.Data; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CustomCompany")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CustomCompany")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("409b1866-07ec-4891-8037-38ee545cb7ad")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace CustomCompany { [BepInPlugin("TAIGU.CleanShip", "CleanShip", "2.5.1")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; private static readonly Harmony harmony = new Harmony("TAIGU.CustomCompany"); public static CustomLog Log = new CustomLog(); private void Awake() { Log.LogInfo("Loading CustomCompany.CleanShip Mod"); Log.enable = true; Instance = this; CustomCompanyManager.Init(); CustomCompanyUI.Init(); TryPatch(typeof(PlayerControllerB_Patch)); TryPatch(typeof(StartOfRound_Patch)); } private static void TryPatch(Type type) { try { harmony.PatchAll(type); } catch (Exception arg) { Log.LogError($"Unable to patch {type}. {arg}"); } } } internal static class CustomCompanyConfig { public static KeyControl menuKey = Keyboard.current.equalsKey; public static BehaviourConfig BehaviourConfig = new BehaviourConfig(); private static string keyDisplayNames; public static void LoadConfig() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) keyDisplayNames = string.Join(", ", ((IEnumerable)(object)Keyboard.current.allKeys).Select((KeyControl x) => (x == null) ? "null" : ((InputControl)x).displayName)); menuKey = BindKey("按键配置", "菜单键", Keyboard.current.equalsKey, "参考按键对应字符串: " + keyDisplayNames); } public static void LoadBehaviourConfig() { if (File.Exists("BepInEx/config/TAIGU.CleanShip.json")) { BehaviourConfig = (BehaviourConfig)JsonMapper.ToObject(File.ReadAllText("BepInEx/config/TAIGU.CleanShip.json"), typeof(BehaviourConfig)); } } public static void SaveBehaviourConfig() { File.WriteAllText("BepInEx/config/TAIGU.CleanShip.json", JsonMapper.ToJson((object)BehaviourConfig)); } private static KeyControl BindKey(string section, string key, KeyControl defaultValue, string configDescription = null) { try { ConfigEntry val = ((BaseUnityPlugin)Plugin.Instance).Config.Bind(section, key, ((InputControl)defaultValue).displayName, configDescription); KeyControl val2 = Keyboard.current.FindKeyOnCurrentKeyboardLayout(val.Value); if (val2 != null) { return val2; } Plugin.Log.LogWarning("按键设置失败!" + key + ":" + val.Value); return defaultValue; } catch (Exception ex) { Plugin.Log.LogWarning("按键设置失败!" + ex.Message); return defaultValue; } } } public class CustomCompanyManager : MonoBehaviour { private static CustomCompanyManager instance; public static CustomCompanyManager Instance { get { if ((Object)(object)instance == (Object)null) { Init(); } return instance; } } public static void Init() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)instance != (Object)null)) { GameObject val = new GameObject("CustomCompanyManager"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; instance = val.AddComponent(); } } private void Start() { CustomCompanyConfig.LoadConfig(); CustomCompanyConfig.LoadBehaviourConfig(); CleanShipBehaviour.LoadConfig(); CollectScrapBehaviour.LoadConfig(); } private void Update() { } } internal class CustomCompanyUI : MonoBehaviour { private static Rect WinRect = new Rect(1300f, 100f, 450f, 700f); private string[] SelectStr = new string[3] { "整理", "收集", "其他功能" }; private bool bRelease = false; private int selectedId; private bool isRandom = false; private bool isSorting = false; private string cleanOffset = Setting.cleanOffset.ToString(); private string saveStr = string.Empty; private bool isCollecting = false; private string collectSaveStr = string.Empty; private bool isUnfold; private Vector2 scollView; private bool isViewItemNames; private string namesLabel = string.Empty; private bool isCollectTargetListUnfold; private Vector2 CollectTargetListScollView; private bool isCollectIgnoreListUnfold; private Vector2 CollectIgnoreListScollView; private string allCollectNames = string.Empty; private Vector2 playersScollViewPos; private bool bPlayersScollView; internal CustomLog Log = Plugin.Log; public static void Init() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("CustomCompanyMenu.CleanShip"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent(); } private void Update() { if (((ButtonControl)CustomCompanyConfig.menuKey).wasPressedThisFrame) { Setting.bMenu = !Setting.bMenu; if (Setting.bMenu) { OnOpen(); } else { OnClose(); } } } private void OnOpen() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (bRelease) { SelectStr = new string[3] { "整理", "其他功能", "说明" }; } else { SelectStr = new string[4] { "整理", "收集", "其他功能", "说明" }; } if (Utility.IsModLoaded("OpJosMod.ReviveCompany")) { Setting.hasReviveCompany = true; } else { Setting.hasReviveCompany = false; } float num = (float)Screen.width * 0.67f; float num2 = (float)Screen.height * 0.1f; WinRect = new Rect(num, num2, 450f, 700f); } private void OnClose() { saveStr = string.Empty; } private void OnGUI() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (Setting.bMenu) { WinRect = GUILayout.Window(0, WinRect, new WindowFunction(WindowFunc), "CleanShip", Array.Empty()); } } private void WindowFunc(int id) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 13) { GUI.FocusControl((string)null); } SelectFunc(); if (bRelease) { if (selectedId == 0) { SortFunc(); } else if (selectedId == 1) { OtherFunc(); } else if (selectedId == 2) { ReadMeFunc(); } } else if (selectedId == 0) { SortFunc(); } else if (selectedId == 1) { CollectFunc(); } else if (selectedId == 2) { OtherFunc(); } else if (selectedId == 3) { ReadMeFunc(); } GUI.DragWindow(); } private void SelectFunc() { selectedId = GUILayout.Toolbar(selectedId, SelectStr, Array.Empty()); } private void SortFunc() { //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) if (CleanShipBehaviour.CleanShipConfig == null) { return; } if (!bRelease) { isRandom = GUILayout.Toggle(isRandom, "随机位置 (将你的飞船弄得乱七八糟!)", Array.Empty()); } GUI.enabled = !isCollecting; if (GUILayout.Button(isSorting ? "停止整理" : "开始整理", Array.Empty())) { if (!isSorting) { Setting.bRandomTidy = isRandom; CleanShipBehaviour.StartSort(delegate { isSorting = false; }); } else { CleanShipBehaviour.StopSort(); } isSorting = !isSorting; } GUI.enabled = true; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("位置随机偏移", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); cleanOffset = GUILayout.TextField(cleanOffset, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); GUI.SetNextControlName("应用按钮"); if (GUILayout.Button("应用", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { Setting.cleanOffset = (float.TryParse(cleanOffset, out var result) ? result : Setting.cleanOffset); cleanOffset = Setting.cleanOffset.ToString(); GUI.FocusControl("应用按钮"); } GUILayout.EndHorizontal(); Setting.bOnlyCustom = GUILayout.Toggle(Setting.bOnlyCustom, "仅整理自定义物品", Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUI.color = Color.green; GUILayout.Label(saveStr, Array.Empty()); GUI.color = Color.white; if (GUILayout.Button("保存配置信息", Array.Empty())) { CleanShipBehaviour.SaveConfig(); saveStr = "保存成功"; } GUILayout.EndHorizontal(); CleanShipBehaviour.CleanShipConfig.bigItemPos = DrawSortPosOne("大件废料位置", CleanShipBehaviour.CleanShipConfig.bigItemPos); CleanShipBehaviour.CleanShipConfig.smallItemPos = DrawSortPosOne("小件废料位置", CleanShipBehaviour.CleanShipConfig.smallItemPos); CleanShipBehaviour.CleanShipConfig.shovelPos = DrawSortPosOne("铲子位置", CleanShipBehaviour.CleanShipConfig.shovelPos); CleanShipBehaviour.CleanShipConfig.lightPos = DrawSortPosOne("手电筒位置", CleanShipBehaviour.CleanShipConfig.lightPos); CleanShipBehaviour.CleanShipConfig.stunPos = DrawSortPosOne("震撼闪光弹位置", CleanShipBehaviour.CleanShipConfig.stunPos); CleanShipBehaviour.CleanShipConfig.sprPos = DrawSortPosOne("喷漆罐位置", CleanShipBehaviour.CleanShipConfig.sprPos); CleanShipBehaviour.CleanShipConfig.keyPos = DrawSortPosOne("钥匙位置", CleanShipBehaviour.CleanShipConfig.keyPos); CleanShipBehaviour.CleanShipConfig.bagPos = DrawSortPosOne("喷气背包位置", CleanShipBehaviour.CleanShipConfig.bagPos); CleanShipBehaviour.CleanShipConfig.radarPos = DrawSortPosOne("雷达位置", CleanShipBehaviour.CleanShipConfig.radarPos); CleanShipBehaviour.CleanShipConfig.gunPos = DrawSortPosOne("霰弹枪位置", CleanShipBehaviour.CleanShipConfig.gunPos); CleanShipBehaviour.CleanShipConfig.ammoPos = DrawSortPosOne("霰弹枪子弹位置", CleanShipBehaviour.CleanShipConfig.ammoPos); CleanShipBehaviour.CleanShipConfig.otherPos = DrawSortPosOne("其他物品位置", CleanShipBehaviour.CleanShipConfig.otherPos); DrawSortPosList(); DrawGetItemsName(); } private void CollectFunc() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) GUI.enabled = !isSorting; if (GUILayout.Button(isCollecting ? "停止收集" : "开始收集", Array.Empty())) { if (!isCollecting) { CollectScrapBehaviour.StartCollect(delegate { isCollecting = false; }); } else { CollectScrapBehaviour.StopCollect(); } isCollecting = !isCollecting; } GUI.enabled = true; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUI.color = Color.green; GUILayout.Label(collectSaveStr, Array.Empty()); GUI.color = Color.white; if (GUILayout.Button("保存配置信息", Array.Empty())) { CollectScrapBehaviour.SaveConfig(); collectSaveStr = "保存成功"; } GUILayout.EndHorizontal(); CollectScrapBehaviour.Config.bTarget = GUILayout.Toggle(CollectScrapBehaviour.Config.bTarget, "仅收集目标", Array.Empty()); DrawCollectTargetList(); CollectScrapBehaviour.Config.bIgnore = GUILayout.Toggle(CollectScrapBehaviour.Config.bIgnore, "忽略物品", Array.Empty()); DrawCollectIgnoreList(); DrawAllItemNames(); } private void OtherFunc() { DrawDisconnect(); DrawTeleportPlayer(); DrawNightVision(); DrawRevivePlayers(); DrawDamageCkeck(); DrawReviveCompany(); DrawKillEnemy(); DrawTest(); } private void ReadMeFunc() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) GUI.skin.label.wordWrap = true; GUI.color = Color.red; GUILayout.Label("* 整理或收集期间无法使用物品栏,出现卡住的情况请点击停止整理或收集。", Array.Empty()); GUILayout.Label("* 复活功能已知问题:非主机好友看不到复活的玩家,复活后无法造成伤害。", Array.Empty()); GUI.color = Color.white; GUI.skin.label.wordWrap = false; } private StrVector3 DrawSortPosOne(string posName, StrVector3 posInfo) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(posName, Array.Empty()); GUILayout.Label("x:", Array.Empty()); GUILayout.Label(posInfo.X, Array.Empty()); GUILayout.Label("z:", Array.Empty()); GUILayout.Label(posInfo.Z, Array.Empty()); if (GUILayout.Button("应用玩家当前位置", Array.Empty())) { Vector3 localPlayerPosition = Utility.GetLocalPlayerPosition(); posInfo.X = localPlayerPosition.x.ToString(); posInfo.Y = localPlayerPosition.y.ToString(); posInfo.Z = localPlayerPosition.z.ToString(); } GUILayout.EndHorizontal(); return posInfo; } private void DrawSortPosList() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (GUILayout.Button(isUnfold ? "▼ 自定义物品列表" : "▶ 自定义物品列表", Array.Empty())) { isUnfold = !isUnfold; } if (!isUnfold) { return; } scollView = GUILayout.BeginScrollView(scollView, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(100f) }); List customItems = CleanShipBehaviour.CleanShipConfig.customItems; for (int i = 0; i < customItems.Count; i++) { CleanShipCustomItem cleanShipCustomItem = customItems[i]; StrVector3 pos = cleanShipCustomItem.pos; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(400f) }); GUILayout.Label("名称", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); cleanShipCustomItem.name = GUILayout.TextField(cleanShipCustomItem.name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); GUILayout.Label("x:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) }); GUILayout.Label(pos.X, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); GUILayout.Label("z:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) }); GUILayout.Label(pos.Z, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); if (GUILayout.Button("应用玩家位置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { Vector3 localPlayerPosition = Utility.GetLocalPlayerPosition(); pos.X = localPlayerPosition.x.ToString(); pos.Y = localPlayerPosition.y.ToString(); pos.Z = localPlayerPosition.z.ToString(); cleanShipCustomItem.pos = pos; } if (GUILayout.Button("删除", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { customItems.Remove(cleanShipCustomItem); } GUILayout.EndHorizontal(); } if (GUILayout.Button("添加", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(400f) })) { CleanShipBehaviour.CleanShipConfig.customItems.Add(new CleanShipCustomItem()); } GUILayout.EndScrollView(); } private void DrawGetItemsName() { if (GUILayout.Button("查看飞船物品名称参考", Array.Empty()) && CleanShipBehaviour.TryGetShipItemNames(out var names)) { namesLabel = string.Join(", ", names); } GUILayout.TextArea(namesLabel, Array.Empty()); } private void DrawCollectTargetList() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (GUILayout.Button(isCollectTargetListUnfold ? "▼ 收集目标列表" : "▶ 收集目标列表", Array.Empty())) { isCollectTargetListUnfold = !isCollectTargetListUnfold; } if (!isCollectTargetListUnfold) { return; } CollectTargetListScollView = GUILayout.BeginScrollView(CollectTargetListScollView, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxHeight(100f) }); List targetList = CollectScrapBehaviour.Config.targetList; for (int i = 0; i < targetList.Count; i++) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(400f) }); GUILayout.Label("物品名称", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); targetList[i] = GUILayout.TextField(targetList[i], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (GUILayout.Button("删除", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { targetList.RemoveAt(i); } GUILayout.EndHorizontal(); } if (GUILayout.Button("添加", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(400f) })) { CollectScrapBehaviour.Config.targetList.Add(string.Empty); } GUILayout.EndScrollView(); } private void DrawCollectIgnoreList() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (GUILayout.Button(isCollectIgnoreListUnfold ? "▼ 忽略物品列表" : "▶ 忽略物品列表", Array.Empty())) { isCollectIgnoreListUnfold = !isCollectIgnoreListUnfold; } if (!isCollectIgnoreListUnfold) { return; } CollectIgnoreListScollView = GUILayout.BeginScrollView(CollectIgnoreListScollView, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxHeight(100f) }); List ignoreList = CollectScrapBehaviour.Config.ignoreList; for (int i = 0; i < ignoreList.Count; i++) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(400f) }); GUILayout.Label("物品名称", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); ignoreList[i] = GUILayout.TextField(ignoreList[i], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (GUILayout.Button("删除", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { ignoreList.RemoveAt(i); } GUILayout.EndHorizontal(); } if (GUILayout.Button("添加", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(400f) })) { CollectScrapBehaviour.Config.ignoreList.Add(string.Empty); } GUILayout.EndScrollView(); } private void DrawAllItemNames() { if (GUILayout.Button("查看所有废料名称参考", Array.Empty()) && CollectScrapBehaviour.TryGetAllScrapNames(out var names)) { allCollectNames = string.Join(",", names); } GUILayout.TextArea(allCollectNames, Array.Empty()); } private void DrawDisconnect() { GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("强制断开连接", Array.Empty())) { ForceDisconnectBehaviour.ForceDisconnec(); } GUILayout.Label(" 进房间黑屏时使用", Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private void DrawTeleportPlayer() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("传送指定玩家", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) })) { TeleportPlayerBehaviour.TeleportPlayer(); } string text = "[选择目标]"; if ((Object)(object)Setting.curTarget != (Object)null) { text = Setting.curTarget.playerUsername; } if (GUILayout.Button(text, Array.Empty())) { bPlayersScollView = !bPlayersScollView; } GUILayout.EndHorizontal(); if (!bPlayersScollView) { return; } playersScollViewPos = GUILayout.BeginScrollView(playersScollViewPos, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxHeight(120f) }); if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.allPlayerScripts != null && StartOfRound.Instance.allPlayerScripts.Length != 0) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (!val.playerUsername.StartsWith("Player #")) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Space(125f); if (GUILayout.Button(val.playerUsername, Array.Empty())) { Setting.curTarget = val; bPlayersScollView = false; } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); } private void DrawNightVision() { GUILayout.BeginHorizontal(Array.Empty()); Setting.bNightVision = GUILayout.Toggle(Setting.bNightVision, "开启夜视仪功能", Array.Empty()); GUILayout.EndHorizontal(); } private void DrawRevivePlayers() { GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("复活所有队友", Array.Empty()) && (Object)(object)StartOfRound.Instance != (Object)null) { StartOfRound.Instance.Debug_ReviveAllPlayersServerRpc(); } GUILayout.Label("仅支持主机复活Steam好友", Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private void DrawDamageCkeck() { GUILayout.BeginHorizontal(Array.Empty()); Setting.bDmgCheck = GUILayout.Toggle(Setting.bDmgCheck, "开启队友伤害检测", Array.Empty()); GUILayout.Label("仅主机", Array.Empty()); GUILayout.EndHorizontal(); } private void DrawReviveCompany() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!Setting.hasReviveCompany || !((Object)(object)StartOfRound.Instance != (Object)null)) { return; } GUILayout.BeginHorizontal(Array.Empty()); GUI.color = Color.blue; GUILayout.Label("ReviveCompany专用:", Array.Empty()); GUI.color = Color.white; if (GUILayout.Button("复活所有队友", Array.Empty())) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerDead) { Log.LogInfo("开始复活队友:" + val.playerUsername); ReviveFromReviveCompany(val); } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private void ReviveFromReviveCompany(PlayerControllerB player) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown RpcMessage val = new RpcMessage((MessageTasks)1, player.playerClientId.ToString(), (int)StartOfRound.Instance.localPlayerController.playerClientId, (MessageCodes)0); RpcMessageHandler.SendRpcMessage(val); ResponseHandler.SentMessageNeedResponses(val); GeneralUtil.RevivePlayer((int)player.playerClientId); RpcMessage val2 = new RpcMessage((MessageTasks)2, player.playerClientId.ToString(), (int)StartOfRound.Instance.localPlayerController.playerClientId, (MessageCodes)0); RpcMessageHandler.SendRpcMessage(val2); } private void DrawKillEnemy() { GUILayout.BeginHorizontal(Array.Empty()); Setting.bKillEnemy = GUILayout.Toggle(Setting.bKillEnemy, "开启强制击杀怪物", Array.Empty()); GUILayout.Label(" 瞄准怪物后按z键", Array.Empty()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(" 击杀距离 " + Setting.killEnemyDis.ToString("0.00"), Array.Empty()); Setting.killEnemyDis = GUILayout.HorizontalSlider(Setting.killEnemyDis, 1f, 50f, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); Setting.bDestroyEnemy = GUILayout.Toggle(Setting.bDestroyEnemy, "强制击杀后删除怪物", Array.Empty()); GUILayout.EndHorizontal(); } private void DrawTest() { GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("获取所有房间", Array.Empty())) { GetLobbysAsync(); } GUILayout.EndHorizontal(); } private async void GetLobbysAsync() { LobbyQuery query = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref query)).WithMaxResults(100); Lobby[] array = await ((LobbyQuery)(ref query)).RequestAsync(); for (int i = 0; i < array.Length; i++) { Lobby lobby = array[i]; Plugin.Log.LogInfo("房间:" + ((Lobby)(ref lobby)).GetData("name")); lobby = default(Lobby); } } } internal static class Setting { public static bool bMenu; public static bool bCleaning; public static bool bCollecting; public static bool bRandomTidy; public static bool bCleanCustom; public static float cleanOffset = 0.2f; public static bool bOnlyCustom; public static bool bNoclip; public static float noclipSpeed; public static PlayerControllerB curTarget; public static bool bNightVision; public static float playerVolumesRate = 1f; public static bool bDmgCheck; public static bool hasReviveCompany; public static bool bKillEnemy; public static bool bDestroyEnemy; public static float killEnemyDis = 10f; } public static class Utility { internal static CustomLog Log = Plugin.Log; public static BindingFlags protectedFlags = BindingFlags.Instance | BindingFlags.NonPublic; public static Vector3 GetLocalPlayerPosition() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null || StartOfRound.Instance.localPlayerController.isPlayerDead) { return Vector3.zero; } return ((Component)StartOfRound.Instance.localPlayerController).transform.position; } public static object CallMethod(object instance, string methodName, BindingFlags bindingFlags, params object[] parameters) { Type type = instance.GetType(); MethodInfo method = type.GetMethod(methodName, bindingFlags); object result; if (method != null) { object obj = method.Invoke(instance, parameters); result = obj; } else { result = null; Log.LogError($"执行方法失败!{instance}.{methodName}"); } return result; } public static Vector3 SetPositionY(this Vector3 position, float y) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector3(position.x, y, position.z); } public static bool IsModLoaded(string guid) { return Chainloader.PluginInfos.ContainsKey(guid); } public static T DeepCopy(T obj) { using MemoryStream memoryStream = new MemoryStream(); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, obj); memoryStream.Seek(0L, SeekOrigin.Begin); return (T)binaryFormatter.Deserialize(memoryStream); } } public class CustomLog { public bool enable = true; internal static ManualLogSource Log = Logger.CreateLogSource("TAIGU.CustomCompany.CleanShip"); public void LogInfo(object message) { if (enable) { Log.LogInfo(message); } } public void LogWarning(object message) { if (enable) { Log.LogWarning(message); } } public void LogError(object message) { if (enable) { Log.LogError(message); } } public void LogDebug(object message) { if (enable) { Log.LogDebug(message); } } public void LogMessage(object message) { if (enable) { Log.LogMessage(message); } } public void LogFatal(object message) { if (enable) { Log.LogFatal(message); } } } } namespace CustomCompany.Patch { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRound_Patch { private static IEnumerable Debug_ReviveAllPlayersServerRpcTranspiler(IEnumerable instructions) { List list = instructions.ToList(); list[73].opcode = OpCodes.Nop; return list; } private static IEnumerable Debug_ReviveAllPlayersClientRpcTranspiler(IEnumerable instructions) { List list = instructions.ToList(); list[58].opcode = OpCodes.Nop; return list; } } [HarmonyPatch] public class PlayerControllerB_Patch { [HarmonyPatch(typeof(PlayerControllerB), "SetObjectAsNoLongerHeld")] [HarmonyPostfix] private static void SetObjectAsNoLongerHeldPostfix(PlayerControllerB __instance, bool droppedInElevator, bool droppedInShipRoom, Vector3 targetFloorPosition, GrabbableObject dropObject, int floorYRot = -1) { if (((NetworkBehaviour)__instance).IsOwner) { Plugin.Log.LogInfo("物品丢弃成功!:" + dropObject.itemProperties.itemName); } } [HarmonyPatch(typeof(PlayerControllerB), "SetObjectAsNoLongerHeld")] [HarmonyPrefix] private static bool SetObjectAsNoLongerHeldPrefix(PlayerControllerB __instance, bool droppedInElevator, bool droppedInShipRoom, Vector3 targetFloorPosition, GrabbableObject dropObject, int floorYRot = -1) { if (!((NetworkBehaviour)__instance).IsOwner) { return true; } if ((Object)(object)dropObject == (Object)null) { Plugin.Log.LogInfo("物品丢弃失败!:目标为空"); return true; } Plugin.Log.LogInfo("物品丢弃成功!:" + dropObject.itemProperties.itemName); return true; } [HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")] [HarmonyPostfix] private static void SwitchToItemSlotPrefix(PlayerControllerB __instance, int slot, GrabbableObject fillSlotWithItem = null) { if (((NetworkBehaviour)__instance).IsOwner && (Object)(object)fillSlotWithItem != (Object)null) { Plugin.Log.LogInfo($"物品拿取成功!{slot} {fillSlotWithItem.itemProperties.itemName}"); } } [HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")] [HarmonyPrefix] private static bool ScrollMouse_performedPrefix(PlayerControllerB __instance, CallbackContext context) { if (!((NetworkBehaviour)__instance).IsOwner) { return true; } if (Setting.bCleaning || Setting.bCollecting) { Plugin.Log.LogInfo("正在操作飞船物品,无法切换!"); return false; } return true; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] public static bool UpdatePrefix(PlayerControllerB __instance) { if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController) { __instance.disableLookInput = __instance.quickMenuManager.isMenuOpen || Setting.bMenu; if (__instance.quickMenuManager.isMenuOpen || Setting.bMenu) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } else { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } } return true; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void UpdatePostfix(PlayerControllerB __instance) { if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController) { NoclipBehaviour.Update(); NightVisionBehaviour.Update(__instance); KillEnemyBehaviour.Update(__instance); } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] public static void StartPostfix(PlayerControllerB __instance) { if (!((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController)) { } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")] [HarmonyPostfix] public static void DamagePlayerFromOtherClientServerRpcPostfix(PlayerControllerB __instance, int damageAmount, Vector3 hitDirection, int playerWhoHit) { DamageCkeckBehaviour.Check(__instance, playerWhoHit); } } } namespace CustomCompany.Behaviour { [Serializable] public class BehaviourConfig { public CleanShipConfig CleanShipConfig = new CleanShipConfig(); public CollectScrapConfig CollectScrapConfig = new CollectScrapConfig(); } internal static class CollectScrapBehaviour { public static CollectScrapConfig Config = new CollectScrapConfig(); private static Coroutine collectCoroutine; internal static CustomLog Log => Plugin.Log; public static void StartCollect(Action callBack) { if (!((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) && !StartOfRound.Instance.localPlayerController.isPlayerDead) { StopCollect(); collectCoroutine = ((MonoBehaviour)CustomCompanyManager.Instance).StartCoroutine(CollectCoroutine(callBack)); } } public static void StopCollect() { if (collectCoroutine != null) { ((MonoBehaviour)CustomCompanyManager.Instance).StopCoroutine(collectCoroutine); collectCoroutine = null; } Setting.bCollecting = false; } public static bool TryGetAllScrapNames(out List names) { names = new List(); if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null || !GameNetworkManager.Instance.gameHasStarted) { return false; } GrabbableObject[] array = Object.FindObjectsOfType(); GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { if (!((Object)(object)val == (Object)null) && val.itemProperties.isScrap && !val.isInShipRoom && val.grabbable) { string itemName = val.itemProperties.itemName; names.Add(itemName); } } names = names.Distinct().ToList(); return true; } public static void LoadConfig() { Config = Utility.DeepCopy(CustomCompanyConfig.BehaviourConfig.CollectScrapConfig); } public static void SaveConfig() { CustomCompanyConfig.BehaviourConfig.CollectScrapConfig = Utility.DeepCopy(Config); CustomCompanyConfig.SaveBehaviourConfig(); } private static IEnumerator CollectCoroutine(Action callBack) { Setting.bCollecting = true; PlayerControllerB player = StartOfRound.Instance.localPlayerController; GrabbableObject[] allObj = Object.FindObjectsOfType(); GrabbableObject[] array = allObj; foreach (GrabbableObject item in array) { if (CkeckTarget(item)) { Log.LogInfo(string.Format("等待丢弃操作结束...{0} 当前准备抓取的物品 {1}", Traverse.Create((object)player).Field("throwingObject").Value, item.itemProperties.itemName)); yield return (object)new WaitUntil((Func)(() => !Traverse.Create((object)player).Field("throwingObject").Value)); Log.LogInfo("开始抓取飞船物品:" + item.itemProperties.itemName); NetworkObjectReference obj = new NetworkObjectReference(((NetworkBehaviour)item).NetworkObject); Traverse.Create((object)player).Field("currentlyGrabbingObject").Value = item; item.InteractItem(); player.twoHanded = item.itemProperties.twoHanded; PlayerControllerB obj2 = player; obj2.carryWeight += Mathf.Clamp(item.itemProperties.weight - 1f, 0f, 10f); item.parentObject = player.localItemHolder; Utility.CallMethod(player, "GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic, obj); Log.LogInfo($"等待抓取操作结束... 当前准备丢弃的物品 {player.currentlyHeldObjectServer}"); yield return (object)new WaitUntil((Func)(() => (Object)(object)player.currentlyHeldObjectServer == (Object)(object)item)); Log.LogInfo("开始丢弃手持物品:" + item.itemProperties.itemName); player.isHoldingObject = true; player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true); } } collectCoroutine = null; Setting.bCollecting = false; callBack?.Invoke(); yield return null; } private static bool CkeckTarget(GrabbableObject item) { if ((Object)(object)item == (Object)null) { return false; } if (!item.itemProperties.isScrap) { return false; } if (item.isInShipRoom) { return false; } if (item.isHeld) { return false; } if (!item.grabbable) { return false; } if (item.heldByPlayerOnServer) { return false; } if (Config.bIgnore && Config.ignoreList.Contains(item.itemProperties.itemName)) { return false; } if (Config.bTarget && !Config.targetList.Contains(item.itemProperties.itemName)) { return false; } return true; } } [Serializable] public class CollectScrapConfig { public List targetList = new List(); public bool bTarget; public List ignoreList = new List(); public bool bIgnore; } internal static class DamageCkeckBehaviour { public static void Check(PlayerControllerB __instance, int playerWhoHit) { if (Setting.bDmgCheck) { string playerUsername = __instance.playerUsername; string text = "神秘人"; if ((Object)(object)StartOfRound.Instance.allPlayerScripts[playerWhoHit] != (Object)null) { text = StartOfRound.Instance.allPlayerScripts[playerWhoHit].playerUsername; } string text2 = text + " 正在殴打 " + playerUsername + "!"; Plugin.Log.LogInfo("发送消息:" + text2); SendMessageBehaviour.Send(text2); } } } public static class ForceDisconnectBehaviour { public static void ForceDisconnec() { GameNetworkManager instance = GameNetworkManager.Instance; if (Object.op_Implicit((Object)(object)instance)) { instance.isDisconnecting = true; if (instance.isHostingGame) { instance.disallowConnection = true; } Utility.CallMethod(instance, "StartDisconnect", BindingFlags.Instance | BindingFlags.NonPublic); instance.SaveGame(); if ((Object)(object)NetworkManager.Singleton == (Object)null) { Debug.Log((object)"Server is not active; quitting to main menu"); Utility.CallMethod(instance, "ResetGameValuesToDefault", BindingFlags.Instance | BindingFlags.NonPublic); SceneManager.LoadScene("MainMenu"); } else { ((MonoBehaviour)instance).StartCoroutine((IEnumerator)Utility.CallMethod(instance, "DisconnectProcess", BindingFlags.Instance | BindingFlags.NonPublic)); } } } } internal static class KillEnemyBehaviour { private static Ray interactRay; private static RaycastHit hit; public static void Update(PlayerControllerB player) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!Setting.bKillEnemy) { return; } interactRay = new Ray(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward); if (Physics.Raycast(interactRay, ref hit, Setting.killEnemyDis, LayerMask.GetMask(new string[1] { "Enemies" }))) { EnemyAI componentInParent = ((Component)((RaycastHit)(ref hit)).transform).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && ((ButtonControl)Keyboard.current.zKey).wasPressedThisFrame) { Plugin.Log.LogInfo("击杀敌人:" + ((Object)componentInParent).name); componentInParent.KillEnemyServerRpc(Setting.bDestroyEnemy); } } } } internal static class NightVisionBehaviour { private static bool bOn; private static Color tempColor; private static float tempRange; private static float tempIntensity; public static void Update(PlayerControllerB player) { if (Setting.bNightVision) { On(player); } else { Off(player); } } public static void On(PlayerControllerB player) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!bOn) { bOn = true; player.nightVision.color = new Color(1f, 1f, 1f, 1f); player.nightVision.range = 5000f; player.nightVision.intensity = 1000f; } } public static void Off(PlayerControllerB player) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (bOn) { bOn = false; player.nightVision.color = tempColor; player.nightVision.range = tempRange; player.nightVision.intensity = tempIntensity; } } } internal static class SendMessageBehaviour { public static void Send(string message, int playerId = -1, string color = "red") { string text = "" + message + ""; HUDManager.Instance.AddTextToChatOnServer(text, playerId); } } public static class TeleportPlayerBehaviour { private static ShipTeleporter shipTeleporter; private static Camera cmr; private static Coroutine coroutine; internal static CustomLog Log => Plugin.Log; public static void TeleportPlayer() { if (coroutine != null) { ((MonoBehaviour)CustomCompanyManager.Instance).StopCoroutine(coroutine); coroutine = null; } coroutine = ((MonoBehaviour)CustomCompanyManager.Instance).StartCoroutine(TeleportPlayerSync()); } private static IEnumerator TeleportPlayerSync() { ShipTeleporter teleporter = GetShipTeleporter(); if (Object.op_Implicit((Object)(object)teleporter) && Object.op_Implicit((Object)(object)Setting.curTarget)) { int num = SearchForPlayerInRadar(); StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(num); yield return (object)new WaitForSeconds(0.15f); yield return (object)new WaitUntil((Func)(() => StartOfRound.Instance.mapScreen.targetTransformIndex == num)); teleporter.PressTeleportButtonOnLocalClient(); } else { Log.LogInfo("传送器为空!"); yield return null; } } private static ShipTeleporter GetShipTeleporter() { if ((Object)(object)shipTeleporter != (Object)null) { return shipTeleporter; } ShipTeleporter[] array = Object.FindObjectsOfType(); ShipTeleporter val = null; ShipTeleporter[] array2 = array; foreach (ShipTeleporter val2 in array2) { if (!val2.isInverseTeleporter) { val = val2; break; } } shipTeleporter = val; return shipTeleporter; } private static int SearchForPlayerInRadar() { int result = -1; for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count(); i++) { if (!((Object)(object)((Component)StartOfRound.Instance.mapScreen.radarTargets[i].transform).gameObject.GetComponent() != (Object)(object)Setting.curTarget)) { result = i; break; } } return result; } } [Serializable] public class CleanShipConfig : ICloneable { public StrVector3 bigItemPos = new StrVector3(-3.3f, 0.5f, -15.8f); public StrVector3 smallItemPos = new StrVector3(-3.3f, 0.5f, -12.7f); public StrVector3 shovelPos = new StrVector3(5f, 0.5f, -16f); public StrVector3 lightPos = new StrVector3(2.9f, 0.5f, -15.6f); public StrVector3 stunPos = new StrVector3(-4.3f, 0.5f, -14f); public StrVector3 sprPos = new StrVector3(2.9f, 0.5f, -12.7f); public StrVector3 keyPos = new StrVector3(9.5f, 0.5f, -16f); public StrVector3 bagPos = new StrVector3(5f, 0.5f, -11.7f); public StrVector3 radarPos = new StrVector3(-0.8f, 0.5f, -12.7f); public StrVector3 otherPos = new StrVector3(6.8f, 0.5f, -11.9f); public StrVector3 gunPos = new StrVector3(10f, 0.5f, -11.9f); public StrVector3 ammoPos = new StrVector3(9f, 0.5f, -11.9f); public List customItems = new List(); public object Clone() { throw new NotImplementedException(); } public bool TryGet(string name, out StrVector3 v3) { CleanShipCustomItem cleanShipCustomItem = customItems.FirstOrDefault((CleanShipCustomItem itemInfo) => !string.IsNullOrEmpty(itemInfo.name) && itemInfo.name.Equals(name)); v3 = cleanShipCustomItem?.pos ?? null; return cleanShipCustomItem != null; } } [Serializable] public class CleanShipCustomItem { public StrVector3 pos; public string name = string.Empty; public CleanShipCustomItem() { pos = new StrVector3(); } } [Serializable] public class StrVector3 { [SerializeField] private float x; [SerializeField] private float y; [SerializeField] private float z; public string X { get { return x.ToString("F2"); } set { x = (float.TryParse(value, out var result) ? result : 0f); } } public string Y { get { return y.ToString("F2"); } set { y = (float.TryParse(value, out var result) ? result : 0f); } } public string Z { get { return z.ToString("F2"); } set { z = (float.TryParse(value, out var result) ? result : 0f); } } public StrVector3(string _x, string _y, string _z) { x = (float.TryParse(_x, out var result) ? result : 0f); y = (float.TryParse(_y, out var result2) ? result2 : 0f); z = (float.TryParse(_z, out var result3) ? result3 : 0f); } public StrVector3(float _x, float _y, float _z) { x = _x; y = _y; z = _z; } public StrVector3() { } public Vector3 ToVector3() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x, y, z); } } public static class CleanShipBehaviour { public static CleanShipConfig CleanShipConfig; private static Coroutine tidyItem_crt; internal static CustomLog Log => Plugin.Log; private static IEnumerator SortCoroutine(Action callBack) { Setting.bCleaning = true; GameObject ship = GameObject.Find("/Environment/HangarShip"); PlayerControllerB player = RoundManager.Instance.playersManager.localPlayerController; GrabbableObject[] componentsInChildren = ((Component)ship.transform).GetComponentsInChildren(); foreach (GrabbableObject item in componentsInChildren) { if (!player.isInHangarShipRoom) { break; } if (item.isHeld || item.heldByPlayerOnServer || (Setting.bOnlyCustom && !IsCustom(item))) { continue; } Vector3 cfgPos = GetTidyTargetPos(item); Vector3 targetPos = item.GetItemFloorPosition(cfgPos); Vector3 offsetTargetPos = GetVector3_OffsetXZ(targetPos, Setting.cleanOffset); if (!(Vector3.Distance(((Component)item).transform.position, targetPos) <= Setting.cleanOffset)) { Log.LogInfo(string.Format("等待丢弃操作结束...{0} 当前准备抓取的物品 {1}", Traverse.Create((object)player).Field("throwingObject").Value, item.itemProperties.itemName)); yield return (object)new WaitUntil((Func)(() => !Traverse.Create((object)player).Field("throwingObject").Value)); Log.LogInfo("开始抓取飞船物品:" + item.itemProperties.itemName); NetworkObjectReference obj = new NetworkObjectReference(((NetworkBehaviour)item).NetworkObject); Traverse.Create((object)player).Field("currentlyGrabbingObject").Value = item; item.InteractItem(); player.twoHanded = item.itemProperties.twoHanded; PlayerControllerB obj2 = player; obj2.carryWeight += Mathf.Clamp(item.itemProperties.weight - 1f, 0f, 10f); item.parentObject = player.localItemHolder; Utility.CallMethod(player, "GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic, obj); Log.LogInfo($"等待抓取操作结束... 当前准备丢弃的物品 {player.currentlyHeldObjectServer}"); yield return (object)new WaitUntil((Func)(() => (Object)(object)player.currentlyHeldObjectServer == (Object)(object)item)); Log.LogInfo("开始丢弃飞船物品:" + item.itemProperties.itemName); player.isHoldingObject = true; player.DiscardHeldObject(true, (NetworkObject)null, offsetTargetPos, false); } } Setting.bCleaning = false; callBack?.Invoke(); tidyItem_crt = null; } private static Vector3 GetTidyTargetPos(GrabbableObject obj) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (Setting.bRandomTidy) { return new Vector3(Random.Range(-3f, 9f), 0.5f, Random.Range(-15.8f, -12.7f)); } if (CleanShipConfig.TryGet(obj.itemProperties.itemName, out var v)) { return v.ToVector3(); } if (obj is Shovel) { return CleanShipConfig.shovelPos.ToVector3(); } if (obj is FlashlightItem) { return CleanShipConfig.lightPos.ToVector3(); } if (obj is StunGrenadeItem) { return CleanShipConfig.stunPos.ToVector3(); } if (obj is SprayPaintItem) { return CleanShipConfig.sprPos.ToVector3(); } if (obj is KeyItem) { return CleanShipConfig.keyPos.ToVector3(); } if (obj is JetpackItem) { return CleanShipConfig.bagPos.ToVector3(); } if (obj is RadarBoosterItem) { return CleanShipConfig.radarPos.ToVector3(); } if (obj is ShotgunItem) { return CleanShipConfig.gunPos.ToVector3(); } if (obj is GunAmmo) { return CleanShipConfig.ammoPos.ToVector3(); } if (obj.itemProperties.twoHanded && obj.itemProperties.isScrap) { return CleanShipConfig.bigItemPos.ToVector3(); } if (!obj.itemProperties.twoHanded && obj.itemProperties.isScrap) { return CleanShipConfig.smallItemPos.ToVector3(); } return CleanShipConfig.otherPos.ToVector3(); } private static bool IsCustom(GrabbableObject obj) { if (CleanShipConfig.TryGet(obj.itemProperties.itemName, out var _)) { return true; } return false; } private static Vector3 GetVector3_OffsetXZ(Vector3 v3, float offset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Random.insideUnitCircle * offset; return new Vector3(v3.x + val.x, v3.y, v3.z + val.y); } public static void StartSort(Action callBack) { if (!((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) && !StartOfRound.Instance.localPlayerController.isPlayerDead) { StopSort(); tidyItem_crt = ((MonoBehaviour)CustomCompanyManager.Instance).StartCoroutine(SortCoroutine(callBack)); } } public static void StopSort() { if (tidyItem_crt != null) { ((MonoBehaviour)CustomCompanyManager.Instance).StopCoroutine(tidyItem_crt); tidyItem_crt = null; } if (Setting.bCleaning) { Setting.bCleaning = false; } } public static bool TryGetShipItemNames(out List names) { names = new List(); if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { return false; } GameObject val = GameObject.Find("/Environment/HangarShip"); PlayerControllerB localPlayerController = RoundManager.Instance.playersManager.localPlayerController; GrabbableObject[] componentsInChildren = ((Component)val.transform).GetComponentsInChildren(); foreach (GrabbableObject val2 in componentsInChildren) { string itemName = val2.itemProperties.itemName; names.Add(itemName); } names = names.Distinct().ToList(); return true; } public static void LoadConfig() { CleanShipConfig = Utility.DeepCopy(CustomCompanyConfig.BehaviourConfig.CleanShipConfig); } public static void SaveConfig() { BehaviourConfig behaviourConfig = CustomCompanyConfig.BehaviourConfig; behaviourConfig.CleanShipConfig = Utility.DeepCopy(CleanShipConfig); CustomCompanyConfig.SaveBehaviourConfig(); } } public static class NoclipBehaviour { public static void Update() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) if (!Setting.bNoclip) { return; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!Object.op_Implicit((Object)(object)localPlayerController)) { return; } Collider component = (Collider)(object)((Component)localPlayerController).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return; } Transform transform = ((Component)localPlayerController).transform; component.enabled = !Object.op_Implicit((Object)(object)transform); if (!component.enabled) { bool isPressed = ((ButtonControl)Keyboard.current.wKey).isPressed; bool isPressed2 = ((ButtonControl)Keyboard.current.aKey).isPressed; bool isPressed3 = ((ButtonControl)Keyboard.current.sKey).isPressed; bool isPressed4 = ((ButtonControl)Keyboard.current.dKey).isPressed; bool isPressed5 = ((ButtonControl)Keyboard.current.spaceKey).isPressed; bool isPressed6 = ((ButtonControl)Keyboard.current.leftCtrlKey).isPressed; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0f, 0f); if (isPressed) { val += transform.forward; } if (isPressed3) { val -= transform.forward; } if (isPressed2) { val -= transform.right; } if (isPressed4) { val += transform.right; } if (isPressed5) { val.y += transform.up.y; } if (isPressed6) { val.y -= transform.up.y; } Transform transform2 = ((Component)localPlayerController).transform; transform2.position += val * (Setting.noclipSpeed * Time.deltaTime); } } } }