using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TAIGU")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("QuickOrganization")] [assembly: AssemblyTitle("QuickOrganization")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace QuickOrganization { public static class CustomLog { private static ManualLogSource _logger; public static void Init(ManualLogSource logger) { _logger = logger; } public static void Info(string msg) { if (_logger != null) { _logger.LogInfo((object)("[TAIGU] " + msg)); } } public static void Warn(string msg) { if (_logger != null) { _logger.LogWarning((object)("[TAIGU] " + msg)); } } public static void Error(string msg) { if (_logger != null) { _logger.LogError((object)("[TAIGU] " + msg)); } } } [HarmonyPatch(typeof(Transform), "SetParent", new Type[] { typeof(Transform), typeof(bool) })] public static class SetParentPatch { public static bool Prefix(Transform __instance, Transform parent) { if ((Object)(object)QuickOrganizationManager.Instance != (Object)null && (Object)(object)parent != (Object)null && ((Object)parent).name == "ElevatorTransform") { CustomLog.Warn("Blocked SetParent to ElevatorTransform for: " + ((Object)__instance).name); return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static class ConnectClientPatch { public static void Postfix() { try { QuickOrganizationManager.CreateInstance(); CustomLog.Info("Manager initialized via ConnectClientToPlayerObject"); } catch (Exception ex) { CustomLog.Error("Failed to create manager: " + ex.Message); } } } [BepInPlugin("TAIGU.QuickOrganization", "TAIGU.QuickOrganization", "1.1.0")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "TAIGU.QuickOrganization"; public const string PluginName = "TAIGU.QuickOrganization"; public const string PluginVersion = "1.1.0"; private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown CustomLog.Init(((BaseUnityPlugin)this).Logger); CustomLog.Info("Loading TAIGU QuickOrganization Mod V1.1.0"); QuickOrganizationConfig.LoadConfig(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("TAIGU.QuickOrganization"); try { val.PatchAll(); CustomLog.Info("All Harmony patches applied successfully"); } catch (Exception ex) { CustomLog.Error("Failed to apply patches: " + ex); } CustomLog.Info("TAIGU QuickOrganization loaded successfully!"); } } public static class QuickOrganizationConfig { private static ConfigEntry _menuKey; public static string MenuKeyName { get { if (_menuKey == null) { return "Equals"; } return _menuKey.Value; } } public static void LoadConfig(ConfigFile configFile) { _menuKey = configFile.Bind("General", "MenuKey", "Equals", "Key to toggle the organization menu. Use Unity Key enum names: Equals, Minus, F1, F2, etc."); CustomLog.Info("Config loaded. MenuKey = " + _menuKey.Value); } public static Key GetKeyEnum() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) string menuKeyName = MenuKeyName; if (Enum.TryParse(menuKeyName, ignoreCase: true, out Key result)) { return result; } CustomLog.Warn("Invalid key name: " + menuKeyName + ", falling back to Equals"); return (Key)14; } } public class QuickOrganizationManager : MonoBehaviour { public class CustomItemEntry { public string name = ""; public float x; public float z; } public static QuickOrganizationManager Instance; private bool _isOpen; private Rect _windowRect = new Rect(150f, 80f, 520f, 600f); private Vector2 _scrollPos; private List _shipItems = new List(); private bool _isOrganizing; private string _statusMsg = "就绪"; private Font _chineseFont; private float _bigItemX = -3.3f; private float _bigItemZ = -15.8f; private float _smallItemX = -3.3f; private float _smallItemZ = -12.7f; private float _shovelX = 5f; private float _shovelZ = -16f; private float _lightX = 2.9f; private float _lightZ = -15.6f; private float _stunX = -4.3f; private float _stunZ = -14f; private float _sprX = 2.9f; private float _sprZ = -12.7f; private float _keyX = 9.5f; private float _keyZ = -16f; private float _bagX = 5f; private float _bagZ = -11.7f; private float _radarX = -0.8f; private float _radarZ = -12.7f; private float _gunX = 10f; private float _gunZ = -11.9f; private float _ammoX = 9f; private float _ammoZ = -11.9f; private float _otherX = 6.8f; private float _otherZ = -11.9f; private List _customItems = new List(); private string _newCustomName = ""; private float _newCustomX; private float _newCustomZ; private bool _showCustomSection; private string ConfigPath { get { string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "Roaming", "com.coze.coding", "configs"); Directory.CreateDirectory(text); return Path.Combine(text, "QuickOrganization_positions.cfg"); } } public static void CreateInstance() { //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_0028: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("QuickOrganizationManager"); Instance = val.AddComponent(); Object.DontDestroyOnLoad((Object)val); CustomLog.Info("QuickOrganizationManager 已创建"); } } private void Start() { try { _chineseFont = Font.CreateDynamicFontFromOSFont("Microsoft YaHei", 14); if ((Object)(object)_chineseFont == (Object)null) { _chineseFont = Font.CreateDynamicFontFromOSFont("SimHei", 14); } CustomLog.Info("中文字体加载: " + (((Object)(object)_chineseFont != (Object)null) ? "成功" : "失败")); } catch (Exception ex) { CustomLog.Warn("中文字体加载异常: " + ex.Message); } LoadPositions(); } private void Update() { //IL_0008: 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) if (Keyboard.current == null) { return; } Key keyEnum = QuickOrganizationConfig.GetKeyEnum(); KeyControl val = Keyboard.current[keyEnum]; if (val != null && ((ButtonControl)val).wasPressedThisFrame) { _isOpen = !_isOpen; CustomLog.Info("菜单切换: " + _isOpen); if (_isOpen) { RefreshShipItems(); } } } private void OnGUI() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (_isOpen) { if ((Object)(object)_chineseFont != (Object)null) { GUI.skin.font = _chineseFont; } _windowRect = GUILayout.Window(952371, _windowRect, new WindowFunction(DrawWindow), "TAIGU 快速整理", Array.Empty()); } } private void DrawWindow(int id) { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("状态: " + _statusMsg, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); if (GUILayout.Button("保存配置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { SavePositions(); } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("刷新物品列表", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { RefreshShipItems(); } if (GUILayout.Button(_isOrganizing ? "整理中..." : "整理飞船", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }) && !_isOrganizing) { RefreshShipItems(); ((MonoBehaviour)this).StartCoroutine(OrganizeCoroutine()); } if (GUILayout.Button("关闭", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(30f) })) { _isOpen = false; } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.Label("飞船内物品: " + _shipItems.Count + " 件", Array.Empty()); _scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(420f) }); GUILayout.Label("--- 物品位置配置 ---", Array.Empty()); GUILayout.Space(3f); DrawPositionRow("大件废料位置", ref _bigItemX, ref _bigItemZ); DrawPositionRow("小件废料位置", ref _smallItemX, ref _smallItemZ); DrawPositionRow("铲子位置", ref _shovelX, ref _shovelZ); DrawPositionRow("手电筒位置", ref _lightX, ref _lightZ); DrawPositionRow("震撼闪光弹位置", ref _stunX, ref _stunZ); DrawPositionRow("喷漆罐位置", ref _sprX, ref _sprZ); DrawPositionRow("钥匙位置", ref _keyX, ref _keyZ); DrawPositionRow("喷气背包位置", ref _bagX, ref _bagZ); DrawPositionRow("雷达位置", ref _radarX, ref _radarZ); DrawPositionRow("霰弹枪位置", ref _gunX, ref _gunZ); DrawPositionRow("霰弹枪子弹位置", ref _ammoX, ref _ammoZ); DrawPositionRow("其他物品位置", ref _otherX, ref _otherZ); GUILayout.Space(8f); _showCustomSection = GUILayout.Toggle(_showCustomSection, "▼ 自定义物品列表", Array.Empty()); if (_showCustomSection) { for (int num = _customItems.Count - 1; num >= 0; num--) { CustomItemEntry customItemEntry = _customItems[num]; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("名称", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); customItemEntry.name = GUILayout.TextField(customItemEntry.name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); GUILayout.Label("x:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); customItemEntry.x = ParseFloat(GUILayout.TextField(customItemEntry.x.ToString("F2"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })); GUILayout.Label("z:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); customItemEntry.z = ParseFloat(GUILayout.TextField(customItemEntry.z.ToString("F2"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })); if (GUILayout.Button("应用玩家位置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { ApplyPlayerPosition(ref customItemEntry.x, ref customItemEntry.z); } if (GUILayout.Button("删除", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { _customItems.RemoveAt(num); } GUILayout.EndHorizontal(); } GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("名称", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); _newCustomName = GUILayout.TextField(_newCustomName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); GUILayout.Label("x:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); _newCustomX = ParseFloat(GUILayout.TextField(_newCustomX.ToString("F2"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })); GUILayout.Label("z:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); _newCustomZ = ParseFloat(GUILayout.TextField(_newCustomZ.ToString("F2"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })); if (GUILayout.Button("应用玩家位置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { ApplyPlayerPosition(ref _newCustomX, ref _newCustomZ); } GUILayout.EndHorizontal(); if (GUILayout.Button("添加自定义物品", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }) && !string.IsNullOrEmpty(_newCustomName)) { _customItems.Add(new CustomItemEntry { name = _newCustomName, x = _newCustomX, z = _newCustomZ }); _newCustomName = ""; _newCustomX = 0f; _newCustomZ = 0f; } } GUILayout.Space(8f); GUILayout.Label("--- 物品清单 ---", Array.Empty()); foreach (GrabbableObject shipItem in _shipItems) { if (!((Object)(object)shipItem == (Object)null) && !((Object)(object)shipItem.itemProperties == (Object)null)) { GUILayout.Label(" · " + shipItem.itemProperties.itemName, Array.Empty()); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.DragWindow(); } private void DrawPositionRow(string label, ref float x, ref float z) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); GUILayout.Label("x:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); x = ParseFloat(GUILayout.TextField(x.ToString("F2"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })); GUILayout.Label("z:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); z = ParseFloat(GUILayout.TextField(z.ToString("F2"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })); if (GUILayout.Button("应用玩家当前位置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { ApplyPlayerPosition(ref x, ref z); } GUILayout.EndHorizontal(); } private float ParseFloat(string text) { if (float.TryParse(text, out var result)) { return result; } return 0f; } private void ApplyPlayerPosition(ref float x, ref float z) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val != (Object)null) { Vector3 position = ((Component)val).transform.position; x = position.x; z = position.z; CustomLog.Info($"应用玩家位置: x={x:F2}, z={z:F2}"); } else { CustomLog.Warn("无法获取玩家位置"); } } private void RefreshShipItems() { _shipItems.Clear(); GameObject val = GameObject.Find("/Environment/HangarShip"); if ((Object)(object)val == (Object)null) { CustomLog.Warn("未找到飞船 (HangarShip)"); _statusMsg = "错误: 未找到飞船"; return; } GrabbableObject[] componentsInChildren = val.GetComponentsInChildren(); foreach (GrabbableObject val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.itemProperties != (Object)null) { _shipItems.Add(val2); } } _statusMsg = "已找到 " + _shipItems.Count + " 件物品"; CustomLog.Info("刷新物品列表: " + _shipItems.Count + " 件"); } private Vector3 GetTargetPosition(GrabbableObject obj) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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) if ((Object)(object)obj == (Object)null || (Object)(object)obj.itemProperties == (Object)null) { return new Vector3(_otherX, 0.5f, _otherZ); } foreach (CustomItemEntry customItem in _customItems) { if (!string.IsNullOrEmpty(customItem.name) && customItem.name.Equals(obj.itemProperties.itemName, StringComparison.OrdinalIgnoreCase)) { return new Vector3(customItem.x, 0.5f, customItem.z); } } if (obj is Shovel) { return new Vector3(_shovelX, 0.5f, _shovelZ); } if (obj is FlashlightItem) { return new Vector3(_lightX, 0.5f, _lightZ); } if (obj is StunGrenadeItem) { return new Vector3(_stunX, 0.5f, _stunZ); } if (obj is SprayPaintItem) { return new Vector3(_sprX, 0.5f, _sprZ); } if (obj is KeyItem) { return new Vector3(_keyX, 0.5f, _keyZ); } if (obj is JetpackItem) { return new Vector3(_bagX, 0.5f, _bagZ); } if (obj is RadarBoosterItem) { return new Vector3(_radarX, 0.5f, _radarZ); } if (obj is ShotgunItem) { return new Vector3(_gunX, 0.5f, _gunZ); } if (obj is GunAmmo) { return new Vector3(_ammoX, 0.5f, _ammoZ); } if (obj.itemProperties.twoHanded && obj.itemProperties.isScrap) { return new Vector3(_bigItemX, 0.5f, _bigItemZ); } if (!obj.itemProperties.twoHanded && obj.itemProperties.isScrap) { return new Vector3(_smallItemX, 0.5f, _smallItemZ); } return new Vector3(_otherX, 0.5f, _otherZ); } private Vector3 AddRandomOffset(Vector3 pos, float offset) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Random.insideUnitCircle * offset; return new Vector3(pos.x + val.x, pos.y, pos.z + val.y); } private unsafe IEnumerator OrganizeCoroutine() { _isOrganizing = true; _statusMsg = "正在整理..."; PlayerControllerB player = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)player == (Object)null) { _statusMsg = "错误: 未找到本地玩家"; _isOrganizing = false; yield break; } GameObject val = GameObject.Find("/Environment/HangarShip"); if ((Object)(object)val == (Object)null) { _statusMsg = "错误: 未找到飞船"; _isOrganizing = false; yield break; } if (!player.isInHangarShipRoom) { _statusMsg = "错误: 玩家不在飞船内"; _isOrganizing = false; yield break; } List allItems = (from i in val.GetComponentsInChildren() where (Object)(object)i != (Object)null && (Object)(object)i.itemProperties != (Object)null && !i.isHeld && !i.heldByPlayerOnServer select i).ToList(); CustomLog.Info("开始整理: " + allItems.Count + " 件物品"); int processed = 0; NetworkObjectReference val2 = default(NetworkObjectReference); foreach (GrabbableObject item in allItems) { if ((Object)(object)item == (Object)null || (Object)(object)item.itemProperties == (Object)null) { continue; } if (!player.isInHangarShipRoom) { _statusMsg = "整理中断: 玩家离开飞船"; break; } processed++; _statusMsg = $"整理中 [{processed}/{allItems.Count}]: {item.itemProperties.itemName}"; Vector3 targetPosition = GetTargetPosition(item); Vector3 itemFloorPosition = item.GetItemFloorPosition(targetPosition); Vector3 offsetPos = AddRandomOffset(itemFloorPosition, 0.5f); if (Vector3.Distance(((Component)item).transform.position, targetPosition) <= 0.5f) { CustomLog.Info("物品已在目标位置附近: " + item.itemProperties.itemName); continue; } yield return (object)new WaitUntil((Func)delegate { FieldInfo field3 = typeof(PlayerControllerB).GetField("throwingObject", BindingFlags.Instance | BindingFlags.NonPublic); return !(field3 != null) || !(bool)field3.GetValue(player); }); CustomLog.Info("抓取物品: " + item.itemProperties.itemName); bool flag = false; try { FieldInfo field = typeof(PlayerControllerB).GetField("currentlyGrabbingObject", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(player, item); } item.InteractItem(); player.twoHanded = item.itemProperties.twoHanded; FieldInfo field2 = typeof(PlayerControllerB).GetField("carryWeight", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { float num = (float)field2.GetValue(player); field2.SetValue(player, num + Mathf.Clamp(item.itemProperties.weight - 1f, 0f, 10f)); } item.parentObject = player.localItemHolder; MethodInfo method = typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { ((NetworkObjectReference)(ref val2))..ctor(((NetworkBehaviour)item).NetworkObject); method.Invoke(player, new object[1] { val2 }); } flag = true; } catch (Exception ex) { CustomLog.Error("抓取物品失败 [" + item.itemProperties.itemName + "]: " + ex.Message); } if (flag) { yield return (object)new WaitUntil((Func)(() => (Object)(object)player.currentlyHeldObjectServer == (Object)(object)item)); string itemName = item.itemProperties.itemName; Vector3 val3 = offsetPos; CustomLog.Info("放置物品: " + itemName + " 到 " + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString()); player.isHoldingObject = true; player.DiscardHeldObject(true, (NetworkObject)null, offsetPos, false); yield return (object)new WaitForSeconds(0.3f); } } _statusMsg = $"整理完成! 共处理 {processed} 件物品"; _isOrganizing = false; CustomLog.Info("整理完成: " + processed + " 件物品"); } private void SavePositions() { try { using (StreamWriter streamWriter = new StreamWriter(ConfigPath, append: false)) { streamWriter.WriteLine("bigItem=" + _bigItemX + "," + _bigItemZ); streamWriter.WriteLine("smallItem=" + _smallItemX + "," + _smallItemZ); streamWriter.WriteLine("shovel=" + _shovelX + "," + _shovelZ); streamWriter.WriteLine("light=" + _lightX + "," + _lightZ); streamWriter.WriteLine("stun=" + _stunX + "," + _stunZ); streamWriter.WriteLine("spray=" + _sprX + "," + _sprZ); streamWriter.WriteLine("key=" + _keyX + "," + _keyZ); streamWriter.WriteLine("bag=" + _bagX + "," + _bagZ); streamWriter.WriteLine("radar=" + _radarX + "," + _radarZ); streamWriter.WriteLine("gun=" + _gunX + "," + _gunZ); streamWriter.WriteLine("ammo=" + _ammoX + "," + _ammoZ); streamWriter.WriteLine("other=" + _otherX + "," + _otherZ); streamWriter.WriteLine("customCount=" + _customItems.Count); for (int i = 0; i < _customItems.Count; i++) { streamWriter.WriteLine("custom" + i + "=" + _customItems[i].name + "," + _customItems[i].x + "," + _customItems[i].z); } } _statusMsg = "配置已保存!"; CustomLog.Info("位置配置已保存到: " + ConfigPath); } catch (Exception ex) { _statusMsg = "保存失败: " + ex.Message; CustomLog.Error("保存配置失败: " + ex.Message); } } private void LoadPositions() { try { if (!File.Exists(ConfigPath)) { CustomLog.Info("未找到配置文件,使用默认位置"); return; } using (StreamReader streamReader = new StreamReader(ConfigPath)) { string text; while ((text = streamReader.ReadLine()) != null) { string[] array = text.Split('='); if (array.Length != 2) { continue; } string text2 = array[0].Trim(); string text3 = array[1].Trim(); switch (text2) { case "bigItem": ParseVec2(text3, out _bigItemX, out _bigItemZ); continue; case "smallItem": ParseVec2(text3, out _smallItemX, out _smallItemZ); continue; case "shovel": ParseVec2(text3, out _shovelX, out _shovelZ); continue; case "light": ParseVec2(text3, out _lightX, out _lightZ); continue; case "stun": ParseVec2(text3, out _stunX, out _stunZ); continue; case "spray": ParseVec2(text3, out _sprX, out _sprZ); continue; case "key": ParseVec2(text3, out _keyX, out _keyZ); continue; case "bag": ParseVec2(text3, out _bagX, out _bagZ); continue; case "radar": ParseVec2(text3, out _radarX, out _radarZ); continue; case "gun": ParseVec2(text3, out _gunX, out _gunZ); continue; case "ammo": ParseVec2(text3, out _ammoX, out _ammoZ); continue; case "other": ParseVec2(text3, out _otherX, out _otherZ); continue; } if (text2.StartsWith("custom") && text2 != "customCount") { string[] array2 = text3.Split(','); if (array2.Length >= 3 && float.TryParse(array2[1], out var result) && float.TryParse(array2[2], out var result2)) { _customItems.Add(new CustomItemEntry { name = array2[0], x = result, z = result2 }); } } } } CustomLog.Info("位置配置已加载,自定义物品: " + _customItems.Count + " 个"); } catch (Exception ex) { CustomLog.Error("加载配置失败: " + ex.Message); } } private void ParseVec2(string val, out float x, out float z) { x = 0f; z = 0f; string[] array = val.Split(','); if (array.Length >= 2) { float.TryParse(array[0], out x); float.TryParse(array[1], out z); } } } }