using System; using System.Collections.Generic; using System.Diagnostics; 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.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("LGUDebugTools")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Debug terminal commands for Lethal Company")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+8c5521e37f37e3d76518a16d04e5d1051842f105")] [assembly: AssemblyProduct("LGUDebugTools")] [assembly: AssemblyTitle("LGUDebugTools")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LGUDebugTools { public class DebugGUI : MonoBehaviour { private bool _visible; private int _tab; private Rect _winRect; private bool _winInitialized; private CursorLockMode _savedLock; private bool _savedVisible; private string _itemFilter = ""; private Vector2 _itemScroll; private string _spawnQty = "1"; private string _enemyFilter = ""; private Vector2 _enemyScroll; private List _enemies; private float _enemyCacheTime; internal static bool GodMode; internal static bool MobIgnore; private bool _nightVision; private float _nvOrigIntensity; private float _nvOrigRange; private string _creditsInput = ""; private string _bxpInput = ""; private bool _stylesOk; private GUIStyle _sWin; private GUIStyle _sLabel; private GUIStyle _sHeader; private GUIStyle _sBtn; private GUIStyle _sTab; private GUIStyle _sTabOn; private GUIStyle _sField; private GUIStyle _sListBtn; private GUIStyle _sCloseBtn; private Texture2D _texBg; private Texture2D _texBtn; private Texture2D _texHover; private Texture2D _texTabOn; private Texture2D _texField; private Texture2D _texBorder; private static readonly Color CG = new Color(0f, 0.784f, 0f); private static readonly Color CBg = new Color(0.02f, 0.02f, 0.02f, 0.97f); private void Update() { if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f9Key).wasPressedThisFrame) { _visible = !_visible; if (_visible) { Open(); } else { Close(); } } if (_nightVision) { PlayerControllerB val = LP(); if ((Object)(object)val?.nightVision != (Object)null) { val.nightVision.intensity = 5000f; val.nightVision.range = 10000f; } } } private void OnGUI() { //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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (_visible) { if (!_winInitialized) { _winRect = new Rect((float)(Screen.width - 500) / 2f, (float)(Screen.height - 600) / 2f, 500f, 600f); _winInitialized = true; } if (!_stylesOk || (Object)(object)_texBg == (Object)null) { BuildStyles(); } GUI.depth = -1000; GUI.DrawTexture(new Rect(((Rect)(ref _winRect)).x - 1f, ((Rect)(ref _winRect)).y - 1f, ((Rect)(ref _winRect)).width + 2f, ((Rect)(ref _winRect)).height + 2f), (Texture)(object)_texBorder); _winRect = GUI.Window(86753, _winRect, new WindowFunction(DrawWin), "", _sWin); } } private void DrawWin(int id) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(10f, 5f, 400f, 25f), "LGUDebugTools v2.0", _sHeader); if (GUI.Button(new Rect(((Rect)(ref _winRect)).width - 30f, 5f, 25f, 25f), "X", _sCloseBtn)) { _visible = false; Close(); return; } float num = ((Rect)(ref _winRect)).width / 3f; string[] array = new string[3] { "Items", "Enemies", "Cheats" }; for (int i = 0; i < 3; i++) { if (GUI.Button(new Rect((float)i * num, 32f, num, 26f), array[i], (i == _tab) ? _sTabOn : _sTab)) { _tab = i; } } GUILayout.BeginArea(new Rect(8f, 62f, ((Rect)(ref _winRect)).width - 16f, ((Rect)(ref _winRect)).height - 70f)); if ((Object)(object)StartOfRound.Instance == (Object)null) { GUILayout.Label("Not in game.", _sLabel, Array.Empty()); } else { try { switch (_tab) { case 0: TabItems(); break; case 1: TabEnemies(); break; case 2: TabCheats(); break; } } catch (Exception ex) { GUILayout.Label("Error: " + ex.Message, _sLabel, Array.Empty()); } } GUILayout.EndArea(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _winRect)).width - 35f, 32f)); } private void TabItems() { //IL_0105: 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_0114: Unknown result type (might be due to invalid IL or missing references) List itemsList = StartOfRound.Instance.allItemsList.itemsList; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", _sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) }); _itemFilter = GUILayout.TextField(_itemFilter, _sField, Array.Empty()); GUILayout.Label("Qty:", _sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }); _spawnQty = GUILayout.TextField(_spawnQty, 3, _sField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); GUILayout.EndHorizontal(); GUILayout.Space(4f); IList list = (string.IsNullOrEmpty(_itemFilter) ? itemsList : itemsList.Where((Item i) => i.itemName.IndexOf(_itemFilter, StringComparison.OrdinalIgnoreCase) >= 0).ToList()); GUILayout.Label($"Items ({list.Count}):", _sLabel, Array.Empty()); _itemScroll = GUILayout.BeginScrollView(_itemScroll, Array.Empty()); foreach (Item item in list) { if (GUILayout.Button(item.itemName, _sListBtn, Array.Empty())) { int result = 1; int.TryParse(_spawnQty, out result); result = Mathf.Clamp(result, 1, 50); DoSpawnItem(item, result); } } GUILayout.EndScrollView(); } private void TabEnemies() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) bool flag = IsHost(); if (!flag) { GUILayout.Label("Host only — enemy spawning requires host authority.", _sLabel, Array.Empty()); GUILayout.Space(4f); } CacheEnemies(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", _sLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) }); _enemyFilter = GUILayout.TextField(_enemyFilter, _sField, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.Space(4f); List list = (string.IsNullOrEmpty(_enemyFilter) ? _enemies : _enemies.Where((EnemyType e) => e.enemyName.IndexOf(_enemyFilter, StringComparison.OrdinalIgnoreCase) >= 0).ToList()); GUILayout.Label($"Enemies ({list.Count}):", _sLabel, Array.Empty()); _enemyScroll = GUILayout.BeginScrollView(_enemyScroll, Array.Empty()); GUI.enabled = flag; foreach (EnemyType item in list) { if (GUILayout.Button(item.enemyName, _sListBtn, Array.Empty())) { DoSpawnEnemy(item); } } GUI.enabled = true; GUILayout.EndScrollView(); } private void TabCheats() { //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(4f); if (GUILayout.Button("God Mode: " + (GodMode ? "ON" : "OFF"), GodMode ? _sTabOn : _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { GodMode = !GodMode; } GUILayout.Space(2f); if (GUILayout.Button("Mob Ignore: " + (MobIgnore ? "ON" : "OFF"), MobIgnore ? _sTabOn : _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { MobIgnore = !MobIgnore; } GUILayout.Space(2f); if (GUILayout.Button("Night Vision: " + (_nightVision ? "ON" : "OFF"), _nightVision ? _sTabOn : _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { _nightVision = !_nightVision; PlayerControllerB val = LP(); if ((Object)(object)val?.nightVision != (Object)null) { if (_nightVision) { _nvOrigIntensity = val.nightVision.intensity; _nvOrigRange = val.nightVision.range; } else { val.nightVision.intensity = _nvOrigIntensity; val.nightVision.range = _nvOrigRange; } } } GUILayout.Space(10f); GUILayout.Label("Set Credits:", _sLabel, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); _creditsInput = GUILayout.TextField(_creditsInput, _sField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); if (GUILayout.Button("Set", _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }) && int.TryParse(_creditsInput, out var result)) { result = Mathf.Clamp(result, 0, 999999); Terminal val2 = Object.FindObjectOfType(); if ((Object)(object)val2 != (Object)null) { val2.groupCredits = result; val2.SyncGroupCreditsServerRpc(result, val2.numberOfItemsInDropship); } } GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.Label("Set BXP:", _sLabel, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); _bxpInput = GUILayout.TextField(_bxpInput, _sField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); if (GUILayout.Button("Set", _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }) && int.TryParse(_bxpInput, out var result2)) { result2 = Mathf.Clamp(result2, 0, 999999); TerminalPatch.ResolveBxpReflection(); if (!TerminalPatch.BxpFailed) { TerminalPatch.SetBxp(result2); } } GUILayout.EndHorizontal(); GUILayout.Space(8f); if (GUILayout.Button("Fulfill Quota", _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { TimeOfDay instance = TimeOfDay.Instance; if ((Object)(object)instance != (Object)null) { int num = instance.profitQuota - instance.quotaFulfilled; instance.quotaFulfilled += Mathf.Max(0, num); instance.SyncNewProfitQuotaClientRpc(instance.profitQuota, instance.quotaFulfilled, instance.timesFulfilledQuota); } } GUILayout.Space(2f); if (GUILayout.Button("Teleport to Entrance", _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { try { PlayerControllerB val3 = LP(); if ((Object)(object)val3 != (Object)null) { EntranceTeleport val4 = ((IEnumerable)Object.FindObjectsOfType()).FirstOrDefault((Func)((EntranceTeleport e) => e.entranceId == 0)); if ((Object)(object)val4?.entrancePoint != (Object)null) { val3.TeleportPlayer(val4.entrancePoint.position, false, 0f, false, true); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Teleport: {arg}"); } } GUILayout.Space(2f); if (!GUILayout.Button("Teleport to Ship", _sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { return; } try { PlayerControllerB val5 = LP(); StartOfRound instance2 = StartOfRound.Instance; if ((Object)(object)val5 != (Object)null && (Object)(object)instance2 != (Object)null) { Vector3 val6 = (((Object)(object)instance2.middleOfShipNode != (Object)null) ? instance2.middleOfShipNode.position : ((instance2.playerSpawnPositions != null && instance2.playerSpawnPositions.Length != 0) ? instance2.playerSpawnPositions[0].position : (((Object)(object)instance2.shipDoorNode != (Object)null) ? ((Component)instance2.shipDoorNode).transform.position : Vector3.zero))); val5.TeleportPlayer(val6, false, 0f, false, true); val5.isInElevator = true; val5.isInHangarShipRoom = true; val5.isInsideFactory = false; } } catch (Exception arg2) { Plugin.Log.LogError((object)$"Teleport ship: {arg2}"); } } private void DoSpawnItem(Item item, int qty) { //IL_002a: 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) //IL_003f: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = LP(); if ((Object)(object)val == (Object)null || (Object)(object)item?.spawnPrefab == (Object)null) { return; } Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 2f + Vector3.up * 0.5f; Vector3 val3 = default(Vector3); for (int i = 0; i < qty; i++) { ((Vector3)(ref val3))..ctor(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); GameObject obj = Object.Instantiate(item.spawnPrefab, val2 + val3, Quaternion.identity); GrabbableObject component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { if (item.isScrap && (Object)(object)RoundManager.Instance != (Object)null) { component.SetScrapValue((int)Random.Range((float)item.minValue * RoundManager.Instance.scrapValueMultiplier, (float)item.maxValue * RoundManager.Instance.scrapValueMultiplier)); } component.fallTime = 0f; } NetworkObject component2 = obj.GetComponent(); if (component2 != null) { component2.Spawn(false); } } } private void DoSpawnEnemy(EnemyType enemy) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!IsHost() || (Object)(object)enemy?.enemyPrefab == (Object)null) { return; } PlayerControllerB val = LP(); if ((Object)(object)val == (Object)null) { return; } try { Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 3f; GameObject obj = Object.Instantiate(enemy.enemyPrefab, val2, Quaternion.identity); NetworkObject componentInChildren = obj.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.Spawn(true); } EnemyAI component = obj.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)RoundManager.Instance != (Object)null) { RoundManager.Instance.SpawnedEnemies.Add(component); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Enemy spawn: {arg}"); } } private void CacheEnemies() { if (_enemies != null && Time.time - _enemyCacheTime < 10f) { return; } _enemyCacheTime = Time.time; HashSet hashSet = new HashSet(); _enemies = new List(); if (StartOfRound.Instance?.levels != null) { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { Collect(val.Enemies, hashSet); Collect(val.OutsideEnemies, hashSet); Collect(val.DaytimeEnemies, hashSet); } } EnemyType[] array = Resources.FindObjectsOfTypeAll(); foreach (EnemyType val2 in array) { if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(val2.enemyName) && hashSet.Add(val2.enemyName)) { _enemies.Add(val2); } } _enemies.Sort((EnemyType a, EnemyType b) => string.Compare(a.enemyName, b.enemyName, StringComparison.OrdinalIgnoreCase)); } private void Collect(List list, HashSet seen) { if (list == null) { return; } foreach (SpawnableEnemyWithRarity item in list) { if ((Object)(object)item?.enemyType != (Object)null && !string.IsNullOrEmpty(item.enemyType.enemyName) && seen.Add(item.enemyType.enemyName)) { _enemies.Add(item.enemyType); } } } private void Open() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _savedLock = Cursor.lockState; _savedVisible = Cursor.visible; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; PlayerControllerB val = LP(); if ((Object)(object)val != (Object)null) { val.disableLookInput = true; } } private void Close() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Cursor.lockState = _savedLock; Cursor.visible = _savedVisible; PlayerControllerB val = LP(); if ((Object)(object)val != (Object)null) { val.disableLookInput = false; } } private void OnDestroy() { if (_visible) { Close(); } if ((Object)(object)_texBg != (Object)null) { Object.Destroy((Object)(object)_texBg); } if ((Object)(object)_texBtn != (Object)null) { Object.Destroy((Object)(object)_texBtn); } if ((Object)(object)_texHover != (Object)null) { Object.Destroy((Object)(object)_texHover); } if ((Object)(object)_texTabOn != (Object)null) { Object.Destroy((Object)(object)_texTabOn); } if ((Object)(object)_texField != (Object)null) { Object.Destroy((Object)(object)_texField); } if ((Object)(object)_texBorder != (Object)null) { Object.Destroy((Object)(object)_texBorder); } } private static PlayerControllerB LP() { return GameNetworkManager.Instance?.localPlayerController; } private static bool IsHost() { if ((Object)(object)NetworkManager.Singleton != (Object)null) { if (!NetworkManager.Singleton.IsHost) { return NetworkManager.Singleton.IsServer; } return true; } return false; } private void BuildStyles() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0142: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_0198: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Expected O, but got Unknown //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Expected O, but got Unknown //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Expected O, but got Unknown //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Expected O, but got Unknown //IL_03ae: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Expected O, but got Unknown if ((Object)(object)_texBg != (Object)null) { Object.Destroy((Object)(object)_texBg); } if ((Object)(object)_texBtn != (Object)null) { Object.Destroy((Object)(object)_texBtn); } if ((Object)(object)_texHover != (Object)null) { Object.Destroy((Object)(object)_texHover); } if ((Object)(object)_texTabOn != (Object)null) { Object.Destroy((Object)(object)_texTabOn); } if ((Object)(object)_texField != (Object)null) { Object.Destroy((Object)(object)_texField); } if ((Object)(object)_texBorder != (Object)null) { Object.Destroy((Object)(object)_texBorder); } _texBg = Tex(CBg); _texBtn = Tex(new Color(0.08f, 0.08f, 0.08f)); _texHover = Tex(new Color(0f, 0.15f, 0f)); _texTabOn = Tex(new Color(0f, 0.12f, 0f)); _texField = Tex(new Color(0.05f, 0.05f, 0.05f)); _texBorder = Tex(CG); GUIStyle val = new GUIStyle(GUI.skin.window); val.normal.background = _texBg; val.normal.textColor = CG; val.onNormal.background = _texBg; val.onNormal.textColor = CG; val.padding = new RectOffset(0, 0, 0, 4); _sWin = val; GUIStyle val2 = new GUIStyle(GUI.skin.label); val2.normal.textColor = CG; val2.fontSize = 14; _sLabel = val2; _sHeader = new GUIStyle(_sLabel) { fontSize = 16, fontStyle = (FontStyle)1 }; GUIStyle val3 = new GUIStyle(GUI.skin.button); val3.normal.background = _texBtn; val3.normal.textColor = CG; val3.hover.background = _texHover; val3.hover.textColor = CG; val3.active.background = _texHover; val3.active.textColor = Color.white; val3.focused.background = _texBtn; val3.focused.textColor = CG; val3.fontSize = 14; val3.alignment = (TextAnchor)4; _sBtn = val3; _sTab = new GUIStyle(_sBtn) { fontStyle = (FontStyle)1 }; GUIStyle val4 = new GUIStyle(_sTab); val4.normal.background = _texTabOn; val4.normal.textColor = CG; val4.hover.background = _texTabOn; val4.hover.textColor = CG; _sTabOn = val4; GUIStyle val5 = new GUIStyle(GUI.skin.textField); val5.normal.background = _texField; val5.normal.textColor = CG; val5.focused.background = _texField; val5.focused.textColor = CG; val5.hover.background = _texField; val5.hover.textColor = CG; val5.fontSize = 14; _sField = val5; _sListBtn = new GUIStyle(_sBtn) { alignment = (TextAnchor)3, padding = new RectOffset(8, 8, 3, 3), margin = new RectOffset(0, 0, 1, 1) }; _sCloseBtn = new GUIStyle(_sBtn) { fontStyle = (FontStyle)1 }; _stylesOk = true; } private static Texture2D Tex(Color c) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, c); val.Apply(); return val; } } [HarmonyPatch(typeof(PlayerControllerB))] internal class GodModePatch { [HarmonyPatch("DamagePlayer")] [HarmonyPrefix] private static bool DamagePrefix(PlayerControllerB __instance) { try { if (DebugGUI.GodMode && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController) { return false; } } catch (Exception arg) { Plugin.Log.LogError((object)$"GodMode DamagePlayer: {arg}"); } return true; } [HarmonyPatch("KillPlayer")] [HarmonyPrefix] private static bool KillPrefix(PlayerControllerB __instance) { try { if (DebugGUI.GodMode && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController) { return false; } } catch (Exception arg) { Plugin.Log.LogError((object)$"GodMode KillPlayer: {arg}"); } return true; } } [HarmonyPatch(typeof(EnemyAI))] internal class MobIgnorePatch { [HarmonyPatch("PlayerIsTargetable")] [HarmonyPrefix] private static bool TargetablePrefix(PlayerControllerB playerScript, ref bool __result) { try { if (DebugGUI.MobIgnore && (Object)(object)playerScript == (Object)(object)GameNetworkManager.Instance.localPlayerController) { __result = false; return false; } } catch (Exception arg) { Plugin.Log.LogError((object)$"MobIgnore: {arg}"); } return true; } } [BepInPlugin("com.y4ngz.lgudebugtools", "LGUDebugTools", "2.0.0")] public class Plugin : BaseUnityPlugin { public const string GUID = "com.y4ngz.lgudebugtools"; public const string NAME = "LGUDebugTools"; public const string VERSION = "2.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.y4ngz.lgudebugtools").PatchAll(); GameObject val = new GameObject("LGUDebugTools_GUI"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LGUDebugTools v2.0.0 loaded. Terminal debug commands + F9 GUI active."); } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { private static Type _currencyManagerType; private static FieldInfo _altCurrencyField; private static PropertyInfo _altCurrencyProp; private static bool _bxpReflResolved; private static bool _bxpReflFailed; internal static bool BxpFailed => _bxpReflFailed; internal static void ResolveBxpReflection() { if (_bxpReflResolved || _bxpReflFailed) { return; } try { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { _currencyManagerType = assemblies[i].GetType("MoreShipUpgrades.Managers.CurrencyManager"); if (_currencyManagerType != null) { break; } } if (_currencyManagerType == null) { Plugin.Log.LogWarning((object)"[BXP] Could not find CurrencyManager type."); _bxpReflFailed = true; return; } Plugin.Log.LogInfo((object)"[BXP] Found CurrencyManager. Dumping members..."); FieldInfo[] fields = _currencyManagerType.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { Plugin.Log.LogInfo((object)("[BXP] Field: " + fieldInfo.FieldType.Name + " " + fieldInfo.Name)); } PropertyInfo[] properties = _currencyManagerType.GetProperties(bindingAttr); foreach (PropertyInfo propertyInfo in properties) { Plugin.Log.LogInfo((object)("[BXP] Property: " + propertyInfo.PropertyType.Name + " " + propertyInfo.Name)); } MethodInfo[] methods = _currencyManagerType.GetMethods(bindingAttr); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name.ToLower().Contains("currency") || methodInfo.Name.ToLower().Contains("alternate")) { Plugin.Log.LogInfo((object)("[BXP] Method: " + methodInfo.ReturnType.Name + " " + methodInfo.Name)); } } _altCurrencyProp = _currencyManagerType.GetProperty("AlternateCurrency", bindingAttr); if (_altCurrencyProp == null) { _altCurrencyProp = _currencyManagerType.GetProperty("CurrencyAmount", bindingAttr); } if (_altCurrencyProp == null) { _altCurrencyField = _currencyManagerType.GetField("AlternateCurrency", bindingAttr) ?? _currencyManagerType.GetField("CurrencyAmount", bindingAttr) ?? _currencyManagerType.GetField("k__BackingField", bindingAttr) ?? _currencyManagerType.GetField("k__BackingField", bindingAttr); } if (_altCurrencyProp == null && _altCurrencyField == null) { Plugin.Log.LogWarning((object)"[BXP] Could not find currency property/field on CurrencyManager."); _bxpReflFailed = true; } else { string text = ((_altCurrencyProp != null) ? ("property '" + _altCurrencyProp.Name + "'") : ("field '" + _altCurrencyField.Name + "'")); Plugin.Log.LogInfo((object)("[BXP] Reflection resolved via " + text + ".")); _bxpReflResolved = true; } } catch (Exception arg) { Plugin.Log.LogError((object)$"[BXP] Reflection failed: {arg}"); _bxpReflFailed = true; } } private static object GetCurrencyManagerInstance() { if (_currencyManagerType == null) { return null; } BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; PropertyInfo property = _currencyManagerType.GetProperty("Instance", bindingAttr); if (property != null) { return property.GetValue(null); } FieldInfo field = _currencyManagerType.GetField("Instance", bindingAttr); if (field != null) { return field?.GetValue(null); } return null; } private static int GetBxp() { object currencyManagerInstance = GetCurrencyManagerInstance(); if (_altCurrencyProp != null) { return (int)_altCurrencyProp.GetValue(_altCurrencyProp.GetMethod.IsStatic ? null : currencyManagerInstance); } if (_altCurrencyField != null) { return (int)_altCurrencyField.GetValue(_altCurrencyField.IsStatic ? null : currencyManagerInstance); } return -1; } internal static void SetBxp(int value) { object currencyManagerInstance = GetCurrencyManagerInstance(); if (_altCurrencyProp != null) { _altCurrencyProp.SetValue(_altCurrencyProp.SetMethod.IsStatic ? null : currencyManagerInstance, value); } else if (_altCurrencyField != null) { _altCurrencyField.SetValue(_altCurrencyField.IsStatic ? null : currencyManagerInstance, value); } } [HarmonyPatch("ParsePlayerSentence")] [HarmonyPrefix] private static bool ParsePrefix(Terminal __instance, ref TerminalNode __result) { string text = __instance.screenText.text; int num = text.LastIndexOf('\n'); string text2 = ((num >= 0) ? text.Substring(num + 1).Trim().ToLower() : text.Trim().ToLower()); if (text2.StartsWith("spawn ")) { string text3 = text2.Substring(6).Trim(); int quantity = 1; string[] array = text3.Split(' '); string itemName; if (array.Length >= 2 && int.TryParse(array[^1], out var result)) { quantity = Mathf.Clamp(result, 1, 50); itemName = string.Join(" ", array.Take(array.Length - 1)); } else { itemName = text3; } __result = SpawnItem(__instance, itemName, quantity); return false; } if (text2.StartsWith("setcredits ")) { if (int.TryParse(text2.Substring(11).Trim(), out var result2)) { result2 = (__instance.groupCredits = Mathf.Clamp(result2, 0, 999999)); __instance.SyncGroupCreditsServerRpc(result2, __instance.numberOfItemsInDropship); __result = CreateNode($"Credits set to ${result2}."); } else { __result = CreateNode("Usage: setcredits \nExample: setcredits 5000"); } return false; } if (text2.StartsWith("setbxp ")) { ResolveBxpReflection(); if (_bxpReflFailed) { __result = CreateNode("Error: Could not access BXP currency.\nMoreShipUpgrades / LGU may not be loaded."); return false; } if (int.TryParse(text2.Substring(7).Trim(), out var result3)) { result3 = Mathf.Clamp(result3, 0, 999999); SetBxp(result3); __result = CreateNode($"BXP set to {result3}."); } else { __result = CreateNode("Usage: setbxp \nExample: setbxp 500"); } return false; } if (text2.StartsWith("addbxp ")) { ResolveBxpReflection(); if (_bxpReflFailed) { __result = CreateNode("Error: Could not access BXP currency.\nMoreShipUpgrades / LGU may not be loaded."); return false; } if (int.TryParse(text2.Substring(7).Trim(), out var result4)) { result4 = Mathf.Max(0, result4); int num2 = Mathf.Clamp(GetBxp() + result4, 0, 999999); SetBxp(num2); __result = CreateNode($"Added {result4} BXP.\nNew balance: {num2} BXP."); } else { __result = CreateNode("Usage: addbxp \nExample: addbxp 200"); } return false; } if (text2 == "getbxp") { ResolveBxpReflection(); if (_bxpReflFailed) { __result = CreateNode("Error: Could not access BXP currency.\nMoreShipUpgrades / LGU may not be loaded."); return false; } int bxp = GetBxp(); __result = CreateNode($"Current BXP: {bxp}"); return false; } if (text2.StartsWith("setquota ")) { if (int.TryParse(text2.Substring(9).Trim(), out var result5)) { result5 = Mathf.Clamp(result5, 0, 999999); TimeOfDay.Instance.profitQuota = result5; TimeOfDay.Instance.SyncNewProfitQuotaClientRpc(TimeOfDay.Instance.profitQuota, TimeOfDay.Instance.quotaFulfilled, TimeOfDay.Instance.timesFulfilledQuota); __result = CreateNode($"Profit quota set to ${result5}.\nCurrently fulfilled: ${TimeOfDay.Instance.quotaFulfilled}"); } else { __result = CreateNode("Usage: setquota \nExample: setquota 200"); } return false; } if (text2.StartsWith("fulfillquota")) { string text4 = text2.Substring(12).Trim(); if (string.IsNullOrEmpty(text4) || !int.TryParse(text4, out var result6)) { result6 = TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled; } result6 = Mathf.Max(0, result6); TimeOfDay instance = TimeOfDay.Instance; instance.quotaFulfilled += result6; TimeOfDay.Instance.SyncNewProfitQuotaClientRpc(TimeOfDay.Instance.profitQuota, TimeOfDay.Instance.quotaFulfilled, TimeOfDay.Instance.timesFulfilledQuota); __result = CreateNode($"Added ${result6} to quota fulfillment.\nQuota: ${TimeOfDay.Instance.quotaFulfilled} / ${TimeOfDay.Instance.profitQuota}"); return false; } if (text2 == "listitems") { List itemsList = StartOfRound.Instance.allItemsList.itemsList; string text5 = "All spawnable items:\n\n"; for (int i = 0; i < itemsList.Count; i++) { text5 = text5 + " " + itemsList[i].itemName + "\n"; } text5 += $"\nTotal: {itemsList.Count} items"; __result = CreateNode(text5); return false; } if (text2 == "debughelp") { __result = CreateNode("=== DEBUG COMMANDS ===\n\nspawn [qty]\n Spawn items at your feet.\n Example: spawn gold bar 5\n\nsetcredits \n Set group credits.\n Example: setcredits 5000\n\nsetbxp \n Set BXP currency to exact amount.\n Example: setbxp 500\n\naddbxp \n Add BXP to current balance.\n Example: addbxp 200\n\ngetbxp\n Show current BXP balance.\n\nsetquota \n Set the profit quota.\n Example: setquota 500\n\nfulfillquota [amount]\n Add to quota fulfillment.\n No amount = fulfill entirely.\n\nlistitems\n List all spawnable item names.\n\ndebughelp\n Show this help text.\n"); return false; } return true; } private static TerminalNode SpawnItem(Terminal terminal, string itemName, int quantity) { //IL_0097: 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) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) List itemsList = StartOfRound.Instance.allItemsList.itemsList; Item val = null; val = ((IEnumerable)itemsList).FirstOrDefault((Func)((Item i) => i.itemName.ToLower() == itemName)); if ((Object)(object)val == (Object)null) { val = ((IEnumerable)itemsList).FirstOrDefault((Func)((Item i) => i.itemName.ToLower().Contains(itemName))); } if ((Object)(object)val == (Object)null) { return CreateNode("Item '" + itemName + "' not found.\nType 'listitems' to see all available items."); } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { return CreateNode("Error: Local player not found."); } Vector3 val2 = ((Component)localPlayerController).transform.position + ((Component)localPlayerController).transform.forward * 2f + Vector3.up * 0.5f; int num = 0; Vector3 val3 = default(Vector3); for (int j = 0; j < quantity; j++) { ((Vector3)(ref val3))..ctor(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); GameObject obj = Object.Instantiate(val.spawnPrefab, val2 + val3, Quaternion.identity); GrabbableObject component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { if (val.isScrap) { component.SetScrapValue((int)Random.Range((float)val.minValue * RoundManager.Instance.scrapValueMultiplier, (float)val.maxValue * RoundManager.Instance.scrapValueMultiplier)); } component.fallTime = 0f; } NetworkObject component2 = obj.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.Spawn(false); } num++; } string arg = (val.isScrap ? " (with random scrap values)" : ""); return CreateNode($"Spawned {num}x {val.itemName}{arg}."); } private static TerminalNode CreateNode(string text) { TerminalNode obj = ScriptableObject.CreateInstance(); obj.displayText = text + "\n\n"; obj.clearPreviousText = true; return obj; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LGUDebugTools"; public const string PLUGIN_NAME = "LGUDebugTools"; public const string PLUGIN_VERSION = "2.0.0"; } }