Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChatCommands v1.1.7
ChatCommands.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChatCommands.Patches; using GameNetcodeStuff; using HarmonyLib; using TMPro; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ChatCommands")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ChatCommands")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d9d7c116-3da7-4a2a-8b87-f83dac82c4cb")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ChatCommands { public class Commands { public static string SetCustomDeadline(string text) { string[] array = text.Split(new char[1] { ' ' }); if (array.Length > 1) { if (int.TryParse(array[1], out var result)) { ChatCommands.CustomDeadline = result; ChatCommands.msgtitle = "Deadline"; ChatCommands.msgbody = "Deadline set to: " + ChatCommands.CustomDeadline; } else { ChatCommands.CustomDeadline = int.MinValue; ChatCommands.msgtitle = "Deadline"; ChatCommands.msgbody = "Deadline set to default"; } } else { ChatCommands.CustomDeadline = int.MinValue; ChatCommands.msgtitle = "Deadline"; ChatCommands.msgbody = "Deadline set to default"; } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string Teleport(string text) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(new char[1] { ' ' }); if (array.Length > 1) { string value = array[1].ToLower(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array2 = allPlayerScripts; foreach (PlayerControllerB val in array2) { if (val.playerUsername.ToLower().Contains(value)) { GameNetworkManager.Instance.localPlayerController.beamUpParticle.Play(); GameNetworkManager.Instance.localPlayerController.beamOutBuildupParticle.Play(); GameNetworkManager.Instance.localPlayerController.TeleportPlayer(((Component)val).transform.position, false, 0f, false, true); ChatCommands.msgtitle = "Teleported"; ChatCommands.msgbody = "Teleported to Player:" + val.playerUsername; } } } else { Terminal val2 = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val2 != (Object)null) { GameNetworkManager.Instance.localPlayerController.beamUpParticle.Play(); GameNetworkManager.Instance.localPlayerController.beamOutBuildupParticle.Play(); GameNetworkManager.Instance.localPlayerController.TeleportPlayer(((Component)val2).transform.position, false, 0f, false, true); ChatCommands.msgtitle = "Teleported"; ChatCommands.msgbody = "Teleported to Terminal"; } } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string SpawnEnemyFunc(string text) { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) ChatCommands.msgtitle = "Spawned Enemies"; string[] array = text.Split(new char[1] { ' ' }); if ((Object)(object)ChatCommands.currentLevel == (Object)null || ChatCommands.levelEnemySpawns == null || ChatCommands.currentLevel.Enemies == null) { ChatCommands.msgtitle = "Command"; ChatCommands.msgbody = (((Object)(object)ChatCommands.currentLevel == (Object)null) ? "Unable to send command since currentLevel is null." : "Unable to send command since levelEnemySpawns is null."); HUDManager.Instance.DisplayTip(ChatCommands.msgtitle, ChatCommands.msgbody, true, false, "LC_Tip1"); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } if (array.Length < 2) { ChatCommands.msgtitle = "Command Error"; ChatCommands.msgbody = "Missing Arguments For Spawn\n'/spawnenemy <name> (amount=<amount>) (state=<state>) (position={random, @me, @<playername>})"; HUDManager.Instance.DisplayTip(ChatCommands.msgtitle, ChatCommands.msgbody, true, false, "LC_Tip1"); ChatCommands.mls.LogWarning((object)"Missing Arguments For Spawn\n'/spawnenemy <name> (amount=<amount>) (state=<state>) (position={random, @me, @<playername>})"); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } int num = 1; string text2 = "alive"; Vector3 location = Vector3.zero; string text3 = "random"; IEnumerable<string> enumerable = array.Skip(2); foreach (string item in enumerable) { string[] array2 = item.Split(new char[1] { '=' }); switch (array2[0]) { case "a": case "amount": num = int.Parse(array2[1]); ChatCommands.mls.LogInfo((object)$"{num}"); break; case "s": case "state": text2 = array2[1]; ChatCommands.mls.LogInfo((object)text2); break; case "p": case "position": text3 = array2[1]; ChatCommands.mls.LogInfo((object)text3); break; } } if (text3.StartsWith("@")) { if (text3 == "@me") { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array3 = allPlayerScripts; foreach (PlayerControllerB val in array3) { ChatCommands.mls.LogInfo((object)("Checking Playername " + val.playerUsername)); if (val.playerUsername.ToLower().Contains(ChatCommands.playerwhocalled.ToLower())) { ChatCommands.mls.LogInfo((object)("Found player " + val.playerUsername)); location = ((Component)val).transform.position; ChatCommands.msgbody = ChatCommands.msgbody + "@" + val.playerUsername; break; } } } else { string value = text3.Substring(1); PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts; bool flag = false; PlayerControllerB[] array4 = allPlayerScripts2; foreach (PlayerControllerB val2 in array4) { if (val2.playerUsername.ToLower().Contains(value)) { ChatCommands.mls.LogInfo((object)("Found player " + val2.playerUsername)); location = ((Component)val2).transform.position; ChatCommands.msgbody = ChatCommands.msgbody + "@" + val2.playerUsername; flag = true; break; } } if (!flag) { ChatCommands.mls.LogWarning((object)"Player not found"); ChatCommands.DisplayChatMessage("Player not found, spawning in random position"); } } } else if (text3 != "random") { ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'"); text3 = "random"; } if (array.Length > 1) { bool flag2 = false; string text4 = ""; foreach (SpawnableEnemyWithRarity enemy in ChatCommands.currentLevel.Enemies) { if (!enemy.enemyType.enemyName.ToLower().Contains(array[1].ToLower())) { continue; } try { flag2 = true; text4 = enemy.enemyType.enemyName; if (text3 == "random") { ChatCommands.SpawnEnemy(enemy, num, inside: true, new Vector3(0f, 0f, 0f)); } else { ChatCommands.SpawnEnemy(enemy, num, inside: true, location); } ChatCommands.mls.LogInfo((object)("Spawned " + enemy.enemyType.enemyName)); } catch { ChatCommands.mls.LogInfo((object)"Could not spawn enemy"); } ChatCommands.msgbody = "Spawned: " + text4; break; } if (!flag2) { foreach (SpawnableEnemyWithRarity outsideEnemy in ChatCommands.currentLevel.OutsideEnemies) { if (!outsideEnemy.enemyType.enemyName.ToLower().Contains(array[1].ToLower())) { continue; } try { flag2 = true; text4 = outsideEnemy.enemyType.enemyName; ChatCommands.mls.LogInfo((object)outsideEnemy.enemyType.enemyName); ChatCommands.mls.LogInfo((object)("The index of " + outsideEnemy.enemyType.enemyName + " is " + ChatCommands.currentLevel.OutsideEnemies.IndexOf(outsideEnemy))); if (text3 == "random") { ChatCommands.SpawnEnemy(outsideEnemy, num, inside: false, new Vector3(0f, 0f, 0f)); } else { ChatCommands.SpawnEnemy(outsideEnemy, num, inside: false, location); } ChatCommands.mls.LogInfo((object)("Spawned " + outsideEnemy.enemyType.enemyName)); } catch (Exception ex) { ChatCommands.mls.LogInfo((object)"Could not spawn enemy"); ChatCommands.mls.LogInfo((object)("The game tossed an error: " + ex.Message)); } ChatCommands.msgbody = "Spawned " + num + " " + text4 + ((num > 1) ? "s" : ""); break; } } } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string ToggleLights() { BreakerBox val = Object.FindObjectOfType<BreakerBox>(); if ((Object)(object)val != (Object)null) { ChatCommands.msgtitle = "Light Change"; if (val.isPowerOn) { ChatCommands.currentRound.TurnBreakerSwitchesOff(); ChatCommands.currentRound.TurnOnAllLights(false); val.isPowerOn = false; ChatCommands.msgbody = "Turned the lights off"; } else { ChatCommands.currentRound.PowerSwitchOnClientRpc(); ChatCommands.msgbody = "Turned the lights on"; } } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string SpawnMapObj(string text) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0201: 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) string[] array = text.Substring(1).Split(new char[1] { ' ' }); if (array.Length < 2) { ChatCommands.mls.LogWarning((object)"Missing Arguments For Spawn\n'/spawnmapobj <name> (amount=<amount>) (position={random, @me, @<playername>})"); ChatCommands.msgtitle = "Command Error"; ChatCommands.msgbody = "Missing Arguments For Spawn\n'/spawnmapobj <name> (amount=<amount>) (position={random, @me, @<playername>})"; HUDManager.Instance.DisplayTip(ChatCommands.msgtitle, ChatCommands.msgbody, true, false, "LC_Tip1"); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } string text2 = array[1].ToLower(); int num = 1; Vector3 val = Vector3.zero; string text3 = "random"; IEnumerable<string> enumerable = array.Skip(2); foreach (string item in enumerable) { string[] array2 = item.Split(new char[1] { '=' }); switch (array2[0]) { case "a": case "amount": num = int.Parse(array2[1]); ChatCommands.mls.LogInfo((object)$"Amount {num}"); break; case "p": case "position": text3 = array2[1]; ChatCommands.mls.LogInfo((object)text3); if (text3.StartsWith("@")) { if (text3 == "@me") { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array3 = allPlayerScripts; foreach (PlayerControllerB val2 in array3) { ChatCommands.mls.LogInfo((object)("Checking Playername " + val2.playerUsername)); if (val2.playerUsername.ToLower().Contains(ChatCommands.playerwhocalled.ToLower())) { ChatCommands.mls.LogInfo((object)("Found player " + val2.playerUsername)); val = ((Component)val2).transform.position; ChatCommands.msgbody = ChatCommands.msgbody + "@" + val2.playerUsername; break; } } break; } string value = text3.Substring(1); PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts; bool flag = false; PlayerControllerB[] array4 = allPlayerScripts2; foreach (PlayerControllerB val3 in array4) { if (val3.playerUsername.ToLower().Contains(value)) { val = ((Component)val3).transform.position; ChatCommands.msgbody = ChatCommands.msgbody + "@" + val3.playerUsername; flag = true; break; } } if (!flag) { ChatCommands.mls.LogWarning((object)"Player not found"); ChatCommands.DisplayChatMessage("Player not found, spawning in random position"); } } else if (text3 != "random") { ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'"); text3 = "random"; } break; } } Vector3 val4; if (text2 == "mine") { if (ChatCommands.mine == -1) { ChatCommands.mls.LogWarning((object)"Mine not found"); ChatCommands.msgtitle = "Command Error"; ChatCommands.msgbody = "Mine not spawnable on map"; return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } for (int k = 0; k < num; k++) { if (text3 == "random") { } ManualLogSource mls = ChatCommands.mls; val4 = val; mls.LogInfo((object)("Spawning mine at position:" + ((object)(Vector3)(ref val4)).ToString())); GameObject val5 = Object.Instantiate<GameObject>(ChatCommands.currentRound.currentLevel.spawnableMapObjects[ChatCommands.mine].prefabToSpawn, val, Quaternion.identity, ChatCommands.currentRound.mapPropsContainer.transform); val5.GetComponent<NetworkObject>().Spawn(true); ChatCommands.msgtitle = "Spawned mine"; val4 = val; ChatCommands.msgbody = "Spawned mine at position:" + ((object)(Vector3)(ref val4)).ToString(); } } else if (text2 == "turret") { if (ChatCommands.turret == -1) { ChatCommands.mls.LogWarning((object)"Turret not found"); ChatCommands.msgtitle = "Command Error"; ChatCommands.msgbody = "Turret not spawnable on map"; return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } for (int l = 0; l < num; l++) { if (text3 == "random") { } ManualLogSource mls2 = ChatCommands.mls; val4 = val; mls2.LogInfo((object)("Spawning turret at position:" + ((object)(Vector3)(ref val4)).ToString())); GameObject val6 = Object.Instantiate<GameObject>(ChatCommands.currentRound.currentLevel.spawnableMapObjects[ChatCommands.turret].prefabToSpawn, val, Quaternion.identity, ChatCommands.currentRound.mapPropsContainer.transform); val6.GetComponent<NetworkObject>().Spawn(true); ChatCommands.msgtitle = "Spawned turret"; val4 = val; ChatCommands.msgbody = "Spawned turret at position:" + ((object)(Vector3)(ref val4)).ToString(); } } return ChatCommands.msgtitle + "/" + ChatCommands.msgbody; } public static string SpawnScrapFunc(string text) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Substring(1).Split(new char[1] { ' ' }); if (array.Length < 2) { ChatCommands.mls.LogWarning((object)"Missing Arguments For Spawn\n'/spawnscrap <name> (amount=<amount>) (position={random, @me, @<playername>})"); ChatCommands.msgtitle = "Command Error"; ChatCommands.msgbody = "Missing Arguments For Spawn\n'/spawnscrap <name> (amount=<amount>) (position={random, @me, @<playername>})"; HUDManager.Instance.DisplayTip(ChatCommands.msgtitle, ChatCommands.msgbody, true, false, "LC_Tip1"); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } string text2 = array[1].ToLower(); int num = 1; Vector3 val = Vector3.zero; string text3 = "random"; int num2 = 1000; IEnumerable<string> enumerable = array.Skip(2); foreach (string item in enumerable) { string[] array2 = item.Split(new char[1] { '=' }); switch (array2[0]) { case "v": case "value": num2 = int.Parse(array2[1]); ChatCommands.mls.LogInfo((object)$"Value {num2}"); break; case "a": case "amount": num = int.Parse(array2[1]); ChatCommands.mls.LogInfo((object)$"Amount {num}"); break; case "p": case "position": text3 = array2[1]; ChatCommands.mls.LogInfo((object)text3); if (text3.StartsWith("@")) { if (text3 == "@me") { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array3 = allPlayerScripts; foreach (PlayerControllerB val2 in array3) { ChatCommands.mls.LogInfo((object)("Checking Playername " + val2.playerUsername)); if (val2.playerUsername.ToLower().Contains(ChatCommands.playerwhocalled.ToLower())) { ChatCommands.mls.LogInfo((object)("Found player " + val2.playerUsername)); val = ((Component)val2).transform.position; ChatCommands.msgbody = ChatCommands.msgbody + "@" + val2.playerUsername; break; } } break; } string value = text3.Substring(1); PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts; bool flag = false; PlayerControllerB[] array4 = allPlayerScripts2; foreach (PlayerControllerB val3 in array4) { if (val3.playerUsername.ToLower().Contains(value)) { val = ((Component)val3).transform.position; ChatCommands.msgbody = ChatCommands.msgbody + "@" + val3.playerUsername; flag = true; break; } } if (!flag) { ChatCommands.mls.LogWarning((object)"Player not found"); ChatCommands.DisplayChatMessage("Player not found, spawning in random position"); } } else if (text3 != "random") { ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'"); text3 = "random"; } break; } } Vector3 val6; if (text2 == "gun") { for (int k = 0; k < ChatCommands.currentRound.currentLevel.Enemies.Count(); k++) { if (((Object)ChatCommands.currentRound.currentLevel.Enemies[k].enemyType).name == "Nutcracker") { GameObject val4 = Object.Instantiate<GameObject>(ChatCommands.currentRound.currentLevel.Enemies[k].enemyType.enemyPrefab, new Vector3(float.MinValue, float.MinValue, float.MinValue), Quaternion.identity); NutcrackerEnemyAI component = val4.GetComponent<NutcrackerEnemyAI>(); ChatCommands.mls.LogInfo((object)("Spawning " + num + " gun" + ((num > 1) ? "s" : ""))); for (int l = 0; l < num; l++) { GameObject val5 = Object.Instantiate<GameObject>(component.gunPrefab, val, Quaternion.identity, ChatCommands.currentRound.spawnedScrapContainer); GrabbableObject component2 = val5.GetComponent<GrabbableObject>(); component2.startFallingPosition = val; component2.targetFloorPosition = component2.GetItemFloorPosition(val); component2.SetScrapValue(num2); ((NetworkBehaviour)component2).NetworkObject.Spawn(false); } ChatCommands.msgtitle = "Spawned gun"; string[] obj = new string[8] { "Spawned ", num.ToString(), " gun", (num > 1) ? "s" : "", "with value of:", num2.ToString(), "\n at position: ", null }; val6 = val; obj[7] = ((object)(Vector3)(ref val6)).ToString(); ChatCommands.msgbody = string.Concat(obj); break; } } } int num3 = ChatCommands.currentRound.currentLevel.spawnableScrap.Count(); bool flag2 = false; for (int m = 0; m < num3; m++) { Item scrap = ChatCommands.currentRound.currentLevel.spawnableScrap[m].spawnableItem; if (!(((Object)scrap.spawnPrefab).name.ToLower() == text2)) { continue; } GameObject spawnPrefab = scrap.spawnPrefab; bool flag3 = text3 == "random"; List<RandomScrapSpawn> list = null; if (flag3) { RandomScrapSpawn[] source = Object.FindObjectsOfType<RandomScrapSpawn>(); list = ((scrap.spawnPositionTypes != null && scrap.spawnPositionTypes.Count != 0) ? source.Where((RandomScrapSpawn x) => scrap.spawnPositionTypes.Contains(x.spawnableItems) && !x.spawnUsed).ToList() : source.ToList()); } ChatCommands.mls.LogInfo((object)("Spawning " + num + " " + ((Object)spawnPrefab).name + ((num > 1) ? "s" : ""))); for (int n = 0; n < num; n++) { if (flag3) { RandomScrapSpawn val7 = list[ChatCommands.currentRound.AnomalyRandom.Next(0, list.Count)]; val = ChatCommands.currentRound.GetRandomNavMeshPositionInRadiusSpherical(((Component)val7).transform.position, val7.itemSpawnRange, ChatCommands.currentRound.navHit) + Vector3.up * scrap.verticalOffset; } GameObject val8 = Object.Instantiate<GameObject>(spawnPrefab, val, Quaternion.identity, ChatCommands.currentRound.spawnedScrapContainer); GrabbableObject component3 = val8.GetComponent<GrabbableObject>(); component3.startFallingPosition = val; component3.targetFloorPosition = component3.GetItemFloorPosition(val); component3.SetScrapValue(num2); ((NetworkBehaviour)component3).NetworkObject.Spawn(false); ChatCommands.msgtitle = "Spawned " + ((Object)spawnPrefab).name; string[] obj2 = new string[9] { "Spawned ", num.ToString(), " ", ((Object)spawnPrefab).name, (num > 1) ? "s" : "", " with value of:", num2.ToString(), "\n at position: ", null }; val6 = val; obj2[8] = ((object)(Vector3)(ref val6)).ToString(); ChatCommands.msgbody = string.Concat(obj2); } flag2 = true; break; } if (!flag2) { ChatCommands.mls.LogWarning((object)("Could not spawn " + text2)); ChatCommands.msgtitle = "Command Error"; ChatCommands.msgbody = "Could not spawn " + text2 + ".\nHave you checked using /getscrap if the scrap you are trying to spawn\n is even spawnable?"; } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string ChangeWeather(string text) { //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) ChatCommands.msgtitle = "Weather Change"; string[] array = text.Split(new char[1] { ' ' }); if (array.Length > 1) { switch (array[1].ToLower()) { case "rain": ChatCommands.currentRound.timeScript.currentLevelWeather = (LevelWeatherType)1; ChatCommands.mls.LogInfo((object)("tried to change the weather to " + array[1])); break; case "eclipse": ChatCommands.currentRound.timeScript.currentLevelWeather = (LevelWeatherType)5; ChatCommands.mls.LogInfo((object)("tried to change the weather to " + array[1])); break; case "flood": ChatCommands.currentRound.timeScript.currentLevelWeather = (LevelWeatherType)4; ChatCommands.mls.LogInfo((object)("tried to change the weather to " + array[1])); break; case "dust": case "mist": case "fog": ChatCommands.currentRound.timeScript.currentLevelWeather = (LevelWeatherType)0; ChatCommands.mls.LogInfo((object)("tried to change the weather to " + array[1])); break; case "storm": ChatCommands.currentRound.timeScript.currentLevelWeather = (LevelWeatherType)2; ChatCommands.mls.LogInfo((object)("tried to change the weather to " + array[1])); break; case "none": ChatCommands.currentRound.timeScript.currentLevelWeather = (LevelWeatherType)(-1); ChatCommands.mls.LogInfo((object)("tried to change the weather to " + array[1])); break; default: ChatCommands.mls.LogInfo((object)("Couldn't figure out what [ " + array[1] + " ] was.")); ChatCommands.msgbody = "Couldn't figure out what [ " + array[1] + " ] was."; break; } ChatCommands.msgbody = "tried to change the weather to " + array[1]; } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string TerminalFunc() { ChatCommands.usingTerminal = !ChatCommands.usingTerminal; if (ChatCommands.usingTerminal) { ChatCommands.msgtitle = "Began Using Terminal"; ChatCommands.msgbody = " "; Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val == (Object)null) { return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } if (!val.terminalInUse) { val.BeginUsingTerminal(); HUDManager.Instance.ChangeControlTip(0, string.Empty, true); GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = true; } } else { Terminal val2 = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val2 == (Object)null) { return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } val2.QuitTerminal(); GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = false; ChatCommands.msgtitle = "Stopped using terminal"; ChatCommands.msgbody = " "; } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string BuyFunc(string text) { ChatCommands.msgtitle = "Item Buying"; Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val != (Object)null) { List<string> list = new List<string> { "Walkie-Talkie", "Pro Flashlight", "Normal Flashlight", "Shovel", "Lockpicker", "Stun Grenade", "Boom Box", "Inhaler", "Stun Gun", "Jet Pack", "Extension Ladder", "Radar Booster" }; Dictionary<string, int> dictionary = new Dictionary<string, int> { { "Walkie-Talkie", 0 }, { "Pro Flashlight", 4 }, { "Normal Flashlight", 1 }, { "Shovel", 2 }, { "Lockpicker", 3 }, { "Stun Grenade", 5 }, { "Boom Box", 6 }, { "Inhaler", 7 }, { "Stun Gun", 8 }, { "Jet Pack", 9 }, { "Extension Ladder", 10 }, { "Radar Booster", 11 } }; string[] array = text.Split(new char[1] { ' ' }); if (array.Length > 1) { bool flag = false; if (array.Length > 2) { if (!int.TryParse(array[2], out var result)) { ChatCommands.mls.LogInfo((object)("Couldn't parse command [ " + array[2] + " ]")); ChatCommands.DisplayChatError("Couldn't parse command [ " + array[2] + " ]"); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } foreach (string item in list) { if (item.ToLower().Contains(array[1])) { flag = true; List<int> list2 = new List<int>(); for (int i = 0; i < result; i++) { list2.Add(dictionary[item]); } val.BuyItemsServerRpc(list2.ToArray(), val.groupCredits, 0); ChatCommands.msgbody = "Bought " + result + " " + item + "s"; break; } } if (!flag) { ChatCommands.mls.LogInfo((object)("Couldn't figure out what [ " + array[1] + " ] was.")); ChatCommands.DisplayChatError("Couldn't figure out what [ " + array[1] + " ] was."); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } } if (!flag) { bool flag2 = false; foreach (string item2 in list) { if (item2.ToLower().Contains(array[1])) { flag2 = true; int[] array2 = new int[1] { dictionary[item2] }; val.BuyItemsServerRpc(array2, val.groupCredits, 0); ChatCommands.msgbody = "Bought " + 1 + " " + item2; } } if (!flag2) { ChatCommands.mls.LogInfo((object)("Couldn't figure out what [ " + array[1] + " ] was. Trying via int parser.")); } if (!int.TryParse(array[1], out var result2)) { ChatCommands.mls.LogInfo((object)("Couldn't figure out what [ " + array[1] + " ] was. Int parser failed, please try again.")); ChatCommands.DisplayChatError("Couldn't figure out what [ " + array[1] + " ] was. Int parser failed, please try again."); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } int[] array3 = new int[1] { result2 }; val.BuyItemsServerRpc(array3, val.groupCredits, 0); ChatCommands.msgbody = "Bought item with ID [" + result2 + "]"; } } } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetEnemies() { string text = ""; SelectableLevel currentLevel = ChatCommands.currentLevel; ChatCommands.msgtitle = "Enemies:"; if ((Object)(object)currentLevel == (Object)null) { ChatCommands.DisplayChatError("Level is null."); Debug.LogError((object)"newLevel is null."); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } if (ChatCommands.levelEnemySpawns == null) { ChatCommands.DisplayChatError("levelEnemySpawns is null."); Debug.LogError((object)"levelEnemySpawns is null."); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } if (ChatCommands.levelEnemySpawns.TryGetValue(currentLevel, out var value)) { currentLevel.Enemies = value; text += "<color=#FF00FF>Inside: </color><color=#FFFF00>"; ChatCommands.msgbody = "<color=#FF00FF>Inside: </color><color=#FFFF00>"; if (currentLevel.Enemies.Count == 0) { text += "None"; ChatCommands.msgbody += "None"; } else { foreach (SpawnableEnemyWithRarity enemy in currentLevel.Enemies) { ChatCommands.mls.LogInfo((object)("Inside: " + enemy.enemyType.enemyName)); text = text + enemy.enemyType.enemyName + ", "; ChatCommands.msgbody = ChatCommands.msgbody + enemy.enemyType.enemyName + ", "; } } text += "\n</color><color=#FF00FF>Outside: </color>"; ChatCommands.msgbody += "\n</color><color=#FF00FF>Outside: </color>"; if (currentLevel.OutsideEnemies.Count == 0) { text += "None"; ChatCommands.msgbody += "None"; } else { foreach (SpawnableEnemyWithRarity outsideEnemy in currentLevel.OutsideEnemies) { ChatCommands.mls.LogInfo((object)("Outside: " + outsideEnemy.enemyType.enemyName)); text = text + outsideEnemy.enemyType.enemyName + ", "; ChatCommands.msgbody = ChatCommands.msgbody + outsideEnemy.enemyType.enemyName + ", "; } } ChatCommands.DisplayChatMessage(text); } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetScrap() { SelectableLevel currentLevel = ChatCommands.currentLevel; if ((Object)(object)currentLevel == (Object)null) { ChatCommands.DisplayChatError("Level is null."); Debug.LogError((object)"Current Level is null."); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } int num = ChatCommands.currentRound.currentLevel.spawnableScrap.Count(); string text = ((Object)ChatCommands.currentRound.currentLevel.spawnableScrap[0].spawnableItem.spawnPrefab).name; for (int i = 1; i < num; i++) { text += ", "; text += ((Object)ChatCommands.currentRound.currentLevel.spawnableScrap[i].spawnableItem.spawnPrefab).name; } ChatCommands.msgtitle = "Spawnable Scrap"; ChatCommands.msgbody = "listed in chat"; ChatCommands.DisplayChatMessage("Spawnable Scrap: " + text); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string SetHostCmds(string playername) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; bool flag = false; PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (val.playerUsername.ToLower().Contains(playername.ToLower())) { flag = true; break; } } if (!flag) { ChatCommands.mls.LogWarning((object)"Player not found"); ChatCommands.DisplayChatError("Player " + playername + " not found!!!"); ChatCommands.msgtitle = "Set Host Command allowance"; ChatCommands.msgbody = "Player not found! Check your command"; return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } bool flag2 = false; ChatCommands.msgtitle = "Set Host Command allowance"; foreach (AllowedHostPlayer allowedHostPlayer in ChatCommands.AllowedHostPlayers) { if (allowedHostPlayer.Name.ToLower().Contains(playername.ToLower())) { allowedHostPlayer.AllowHostCMD = !allowedHostPlayer.AllowHostCMD; ChatCommands.msgbody = "Host Commands for " + playername + " set to" + allowedHostPlayer.AllowHostCMD; flag2 = true; break; } } if (!flag2) { ChatCommands.AllowedHostPlayers.Add(new AllowedHostPlayer(playername, isActive: true)); ChatCommands.msgbody = "Host Commands for " + playername + " set to true"; } return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetHelp() { ChatCommands.msgtitle = "Available Commands"; ChatCommands.msgbody = "/buy item - Buy an item \n /togglelights - Toggle lights inside building \n /spawn - help for spawning \n /morehelp - see more commands \n /credits - List credits"; ChatCommands.DisplayChatMessage("<color=#FF00FF>" + ChatCommands.msgtitle + "</color>\n" + ChatCommands.msgbody); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetMoreHelp() { ChatCommands.msgtitle = "More Commands"; ChatCommands.msgbody = "/enemies - See all enemies available to spawn. \n /weather weatherName - Attempt to change weather \n /cheats - list cheat commands"; ChatCommands.DisplayChatMessage("<color=#FF00FF>" + ChatCommands.msgtitle + "</color>\n" + ChatCommands.msgbody); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetCredits() { ChatCommands.msgtitle = "Credits"; ChatCommands.msgbody = "ChatCommands by Toemmsen96 and Chrigi"; ChatCommands.DisplayChatMessage("<color=#FF00FF>" + ChatCommands.msgtitle + "</color>\n" + ChatCommands.msgbody); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetCheats() { ChatCommands.msgtitle = "Cheats"; ChatCommands.msgbody = "/god - Toggle GodMode \n /speed - Toggle SpeedHack \n /togglelights - Toggle lights inside building \n /tp - Teleports you to the terminal in your ship, keeping all items on you! \n /tp <playername> teleports you to that player"; ChatCommands.DisplayChatMessage("<color=#FF00FF>" + ChatCommands.msgtitle + "</color>\n" + ChatCommands.msgbody); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static string GetSpawn() { ChatCommands.msgtitle = "How To"; ChatCommands.msgbody = "Spawn an enemy: /spawnenemy or /spweny\nSpawn scrap items: /spawnscrap or /spwscr\nafter that put the name of what you want to spawn\noptions: a=<num> or amount=<num> for how many to spawn\np=<pos> or position=<pos> for position where to spawn\n<pos> can be either @me for your coordinates, @playername for coords of player with specific name or random"; ChatCommands.DisplayChatMessage("<color=#FF00FF>" + ChatCommands.msgtitle + "</color>\n" + ChatCommands.msgbody); return ChatCommands.msgbody + "/" + ChatCommands.msgtitle; } public static bool CheckPrefix(string text) { string text2 = "/"; if (ChatCommands.PrefixSetting.Value != "") { text2 = ChatCommands.PrefixSetting.Value; } if (!text.ToLower().StartsWith(text2.ToLower())) { return false; } return true; } } [BepInPlugin("toemmsen.ChatCommands", "ChatCommands", "1.1.7")] public class ChatCommands : BaseUnityPlugin { private const string modGUID = "toemmsen.ChatCommands"; private const string modName = "ChatCommands"; private const string modVersion = "1.1.7"; private readonly Harmony harmony = new Harmony("toemmsen.ChatCommands"); private static ChatCommands instance; internal static ManualLogSource mls = Logger.CreateLogSource("toemmsen.ChatCommands"); public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns; public static Dictionary<SpawnableEnemyWithRarity, int> enemyRaritys; public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves; internal static SelectableLevel currentLevel; internal static EnemyVent[] currentLevelVents; internal static RoundManager currentRound; internal static bool EnableInfiniteAmmo = false; internal static ConfigEntry<string> PrefixSetting; internal static ConfigEntry<bool> HostSetting; internal static ConfigEntry<bool> SendHostCommandsSetting; internal static bool enableGod; internal static bool EnableInfiniteCredits = false; internal static int CustomDeadline = int.MinValue; internal static bool usingTerminal = false; internal static PlayerControllerB playerRef; internal static bool isHost; internal static bool speedHack; internal static string msgtitle; internal static string msgbody; internal static string NetCommandPrefix = "<size=0>CCMD:"; internal static string NetHostCommandPrefix = "<size=0>CHCMD:"; internal static string NetCommandPostfix = "</size>"; internal static string playerwhocalled; internal static List<AllowedHostPlayer> AllowedHostPlayers = new List<AllowedHostPlayer>(); internal static int mine = -1; internal static int turret = -1; public TextMeshProUGUI chatText; private void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } PrefixSetting = ((BaseUnityPlugin)instance).Config.Bind<string>("Command Settings", "Command Prefix", "/", "An optional prefix for chat commands"); HostSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Has to be Host", true, "(for server host only): determines if clients can also use the host commands"); SendHostCommandsSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Send Host Commands", true, "(for server host only): determines if commands get sent to the clients, so for example god mode is enabled for them too"); mls.LogInfo((object)"ChatCommands loaded"); enemyRaritys = new Dictionary<SpawnableEnemyWithRarity, int>(); levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>(); enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>(); speedHack = false; enableGod = false; harmony.PatchAll(typeof(ChatCommands)); harmony.PatchAll(typeof(global::ChatCommands.Patches.Patches)); mls.LogWarning((object)("\r\n" + " ______ \r\n /_ __/ ____ ___ ____ ___ ____ ___ _____ ___ ____ _____ \r\n / / / __ \\ / _ \\ / __ `__ \\ / __ `__ \\ / ___/ / _ \\ / __ \\ / ___/ \r\n / / / /_/ // __/ / / / / / / / / / / / / (__ ) / __/ / / / / (__ ) \r\n/_/_____\\____/_\\___/ /_/ /_/_/_/ /_/ /_/ /_/_/____/ \\___/ /_/ /_/ /____/ __ \r\n / ____/ / /_ ____ _ / /_ / ____/ ____ ____ ___ ____ ___ ____ _ ____ ____/ / _____\r\n / / / __ \\ / __ `/ / __/ / / / __ \\ / __ `__ \\ / __ `__ \\ / __ `/ / __ \\ / __ / / ___/\r\n/ /___ / / / // /_/ / / /_ / /___ / /_/ / / / / / / / / / / / / // /_/ / / / / // /_/ / (__ ) \r\n\\____/ /_/ /_/ \\__,_/ \\__/ \\____/ \\____/ /_/ /_/ /_/ /_/ /_/ /_/ \\__,_/ /_/ /_/ \\__,_/ /____/ \r\n")); } private static bool ToggleGodMode() { if (isHost) { enableGod = !enableGod; } return enableGod; } private static bool ToggleSpeedHack() { if (isHost) { speedHack = !playerRef.isSpeedCheating; playerRef.isSpeedCheating = speedHack; } return speedHack; } internal static void SpawnEnemy(SpawnableEnemyWithRarity enemy, int amount, bool inside, Vector3 location) { //IL_0013: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_02c3: 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_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) if (!isHost) { return; } if (location.x != 0f && location.y != 0f && location.z != 0f && inside) { try { for (int i = 0; i < amount; i++) { currentRound.SpawnEnemyOnServer(location, 0f, currentLevel.Enemies.IndexOf(enemy)); } return; } catch { mls.LogInfo((object)"Failed to spawn enemies, check your command."); return; } } if (location.x != 0f && location.y != 0f && location.z != 0f && !inside) { try { int j; for (j = 0; j < amount; j++) { Object.Instantiate<GameObject>(currentLevel.OutsideEnemies[currentLevel.OutsideEnemies.IndexOf(enemy)].enemyType.enemyPrefab, location, Quaternion.Euler(Vector3.zero)).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true); } mls.LogInfo((object)$"You wanted to spawn: {amount} enemies"); ManualLogSource obj2 = mls; string text = j.ToString(); Vector3 val = location; obj2.LogInfo((object)("Spawned an enemy. Total Spawned: " + text + "at position:" + ((object)(Vector3)(ref val)).ToString())); return; } catch { mls.LogInfo((object)"Failed to spawn enemies, check your command."); return; } } if (inside) { try { int k; for (k = 0; k < amount; k++) { currentRound.SpawnEnemyOnServer(currentRound.allEnemyVents[Random.Range(0, currentRound.allEnemyVents.Length)].floorNode.position, currentRound.allEnemyVents[k].floorNode.eulerAngles.y, currentLevel.Enemies.IndexOf(enemy)); } mls.LogInfo((object)$"You wanted to spawn: {amount} enemies"); mls.LogInfo((object)("Total Spawned: " + k)); return; } catch { mls.LogInfo((object)"Failed to spawn enemies, check your command."); return; } } int l; for (l = 0; l < amount; l++) { Object.Instantiate<GameObject>(currentLevel.OutsideEnemies[currentLevel.OutsideEnemies.IndexOf(enemy)].enemyType.enemyPrefab, GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length - 1)].transform.position, Quaternion.Euler(Vector3.zero)).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true); } mls.LogInfo((object)$"You wanted to spawn: {amount} enemies"); mls.LogInfo((object)("Total Spawned: " + l)); } internal static bool NonHostCommands(string command) { bool result = true; switch (command.ToLower()) { case "enemies": Commands.GetEnemies(); break; case "getscrap": Commands.GetScrap(); break; case "help": Commands.GetHelp(); break; case "morehelp": Commands.GetMoreHelp(); break; case "credits": Commands.GetCredits(); break; case "cheats": Commands.GetCheats(); break; case "spawn": Commands.GetSpawn(); break; default: result = false; break; } return result; } internal static void ProcessCommandInput(string command) { msgtitle = "default"; msgbody = "<color=#FF0000>ERR</color>: unknown"; string[] array = command.Split(new char[1] { ' ' }); if (NonHostCommands(command)) { return; } if (!isHost) { msgtitle = "Command"; msgbody = "Unable to send command since you are not host."; HUDManager.Instance.DisplayTip(msgtitle, msgbody, false, false, "LC_Tip1"); return; } switch (array[0]) { case "spawnenemy": case "spweny": Commands.SpawnEnemyFunc(command); break; case "spawnscrap": case "spwscr": Commands.SpawnScrapFunc(command); break; case "weather": Commands.ChangeWeather(command); break; case "togglelights": Commands.ToggleLights(); break; case "buy": Commands.BuyFunc(command); break; case "god": msgtitle = "God Mode"; msgbody = "God Mode set to: " + ToggleGodMode(); SendHostCommand(command); break; case "speed": msgtitle = "Speed hack"; msgbody = "Speed hack set to: " + ToggleSpeedHack(); SendHostCommand(command); break; case "deadline": case "dl": Commands.SetCustomDeadline(command); break; case "tp": Commands.Teleport(command); break; case "money": EnableInfiniteCredits = !EnableInfiniteCredits; msgtitle = "Infinite Credits"; msgbody = "Infinite Credits: " + EnableInfiniteCredits; break; case "infammo": case "ammo": EnableInfiniteAmmo = !EnableInfiniteAmmo; msgtitle = "Infinite Ammo"; msgbody = "Infinite Ammo: " + EnableInfiniteAmmo; SendHostCommand(command); break; case "terminal": case "term": Commands.TerminalFunc(); break; case "cohost": case "hostcmd": Commands.SetHostCmds(array[1]); break; case "spawnmapobj": case "spwmapobj": Commands.SpawnMapObj(command); break; default: msgtitle = "Command"; msgbody = "Unknown command: " + array[0]; DisplayChatError(msgbody); break; } HUDManager.Instance.DisplayTip(msgtitle, msgbody, false, false, "LC_Tip1"); } internal static void SendHostCommand(string commandInput) { if (isHost && SendHostCommandsSetting.Value) { string text = NetHostCommandPrefix + commandInput + NetCommandPostfix; HUDManager.Instance.AddTextToChatOnServer(text, -1); } } public static void ProcessNetHostCommand(string commandInput) { if (commandInput.ToLower().Contains("god")) { enableGod = !enableGod; msgtitle = "Host sent command:"; msgbody = "God Mode set to: " + enableGod; } if (commandInput.ToLower().Contains("speed")) { speedHack = !playerRef.isSpeedCheating; playerRef.isSpeedCheating = speedHack; msgtitle = "Host sent command:"; msgbody = "Speed hack set to: " + speedHack; } if (commandInput.ToLower().Contains("infammo") || commandInput.ToLower().Contains("ammo")) { EnableInfiniteAmmo = !EnableInfiniteAmmo; msgtitle = "Host sent command:"; msgbody = "Infinite Ammo: " + EnableInfiniteAmmo; } HUDManager.Instance.DisplayTip(msgtitle, msgbody, false, false, "LC_Tip1"); } public static void ProcessCommand(string commandInput) { ProcessCommandInput(commandInput); HUDManager.Instance.DisplayTip(msgtitle, msgbody, false, false, "LC_Tip1"); } public static void DisplayChatMessage(string chatMessage) { string item = "<color=#FF00FF>ChatCommands</color>: <color=#FFFF00>" + chatMessage + "</color>"; HUDManager.Instance.ChatMessageHistory.Add(item); UpdateChatText(); } public static void DisplayChatError(string errorMessage) { string item = "<color=#FF0000>CCMD: ERROR</color>: <color=#FF0000>" + errorMessage + "</color>"; HUDManager.Instance.ChatMessageHistory.Add(item); UpdateChatText(); } private static void UpdateChatText() { ((TMP_Text)HUDManager.Instance.chatText).text = string.Join("\n", HUDManager.Instance.ChatMessageHistory); } } internal class AllowedHostPlayer { public string Name { get; set; } public bool AllowHostCMD { get; set; } public AllowedHostPlayer(string name, bool isActive) { Name = name; AllowHostCMD = isActive; } } } namespace ChatCommands.Patches { internal class Patches { private static string NetCommandPrefix = ChatCommands.NetCommandPrefix; private static string NetHostCommandPrefix = ChatCommands.NetHostCommandPrefix; private static string NetCommandPostfix = ChatCommands.NetCommandPostfix; private static float defaultJumpForce; private static string nullChatMessage = ""; [HarmonyPatch(typeof(RoundManager), "EnemyCannotBeSpawned")] [HarmonyPrefix] private static bool OverrideCannotSpawn() { return false; } [HarmonyPatch(typeof(RoundManager), "SpawnEnemyFromVent")] [HarmonyPrefix] private static void LogSpawnEnemyFromVent() { ChatCommands.mls.LogInfo((object)"Attempting to spawn an enemy"); } [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] private static void ChatCommandsSubmitted(HUDManager __instance) { string text = __instance.chatTextField.text; string username = GameNetworkManager.Instance.username; ChatCommands.mls.LogInfo((object)("Received chat input: " + text)); if (!string.IsNullOrEmpty(text) && text.ToLower().StartsWith(ChatCommands.PrefixSetting.Value)) { if (!ChatCommands.NonHostCommands(text)) { if (!ChatCommands.isHost) { string text2 = text.Substring(ChatCommands.PrefixSetting.Value.Length); __instance.chatTextField.text = NetCommandPrefix + text + NetCommandPostfix; ChatCommands.mls.LogInfo((object)("Not Host, trying to send command:" + text2)); return; } if (text.ToLower().Contains("p=@me")) { ChatCommands.playerwhocalled = username; ChatCommands.mls.LogInfo((object)("Player who called: " + ChatCommands.playerwhocalled)); } string command = text.Substring(ChatCommands.PrefixSetting.Value.Length); ChatCommands.ProcessCommandInput(command); __instance.chatTextField.text = nullChatMessage; } else { __instance.chatTextField.text = nullChatMessage; } } else { ChatCommands.mls.LogWarning((object)"Invalid input for a command or null chat."); } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] [HarmonyPrefix] private static void ReadChatMessage(HUDManager __instance, ref string chatMessage, ref string nameOfUserWhoTyped) { ChatCommands.mls.LogInfo((object)("Chat Message: " + chatMessage + " sent by: " + nameOfUserWhoTyped)); if (chatMessage.StartsWith(NetCommandPrefix) && ChatCommands.isHost && ChatCommands.HostSetting.Value) { string text = chatMessage.Substring(NetCommandPrefix.Length); string[] array = text.Split(new char[1] { '<' }); string text2 = array[0]; if (text2.ToLower().Contains("p=@me")) { ChatCommands.playerwhocalled = nameOfUserWhoTyped; } ChatCommands.mls.LogInfo((object)("Host, trying to handle command: " + text2)); ChatCommands.DisplayChatMessage(nameOfUserWhoTyped + " sent command: " + ChatCommands.PrefixSetting.Value + text2); ChatCommands.ProcessCommandInput(text2); chatMessage = nullChatMessage; nameOfUserWhoTyped = nullChatMessage; } else if (chatMessage.StartsWith(NetCommandPrefix) && ChatCommands.isHost && !ChatCommands.HostSetting.Value) { ChatCommands.mls.LogWarning((object)"Host, but not allowing commands, checking player for allowance"); foreach (AllowedHostPlayer allowedHostPlayer in ChatCommands.AllowedHostPlayers) { if (allowedHostPlayer.Name.ToLower().Contains(nameOfUserWhoTyped.ToLower())) { ChatCommands.mls.LogInfo((object)"Player is allowed to send commands"); string text3 = chatMessage.Substring(NetCommandPrefix.Length); string[] array2 = text3.Split(new char[1] { '<' }); string text4 = array2[0]; if (text4.ToLower().Contains("p=@me")) { ChatCommands.playerwhocalled = nameOfUserWhoTyped; } ChatCommands.mls.LogInfo((object)("Host, trying to handle command: " + text4)); ChatCommands.DisplayChatMessage(nameOfUserWhoTyped + " sent command: " + ChatCommands.PrefixSetting.Value + text4); ChatCommands.ProcessCommandInput(text4); chatMessage = nullChatMessage; nameOfUserWhoTyped = nullChatMessage; return; } } ChatCommands.DisplayChatMessage("Host, but not allowing commands"); } else if (chatMessage.StartsWith(NetHostCommandPrefix) && !ChatCommands.isHost) { string text5 = chatMessage.Substring(NetHostCommandPrefix.Length); string[] array3 = text5.Split(new char[1] { '<' }); string text6 = array3[0]; ChatCommands.mls.LogInfo((object)("Recieved command from Host, trying to handle command: " + text6)); ChatCommands.ProcessNetHostCommand(text6); } } [HarmonyPatch(typeof(ShotgunItem), "ItemActivate")] [HarmonyPrefix] private static void ItemActivateGunPatch(ref ShotgunItem __instance) { if (ChatCommands.EnableInfiniteAmmo) { __instance.shellsLoaded = 2; } } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPostfix] private static void UpdateNewInfo(ref EnemyVent[] ___allEnemyVents, ref SelectableLevel ___currentLevel) { ChatCommands.currentLevel = ___currentLevel; ChatCommands.currentLevelVents = ___allEnemyVents; HUDManager.Instance.chatTextField.characterLimit = 999; } [HarmonyPatch(typeof(RoundManager), "AdvanceHourAndSpawnNewBatchOfEnemies")] [HarmonyPrefix] private static void UpdateCurrentLevelInfo(ref EnemyVent[] ___allEnemyVents, ref SelectableLevel ___currentLevel) { ChatCommands.currentLevel = ___currentLevel; ChatCommands.currentLevelVents = ___allEnemyVents; } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] private static bool ModifyLevel(ref SelectableLevel newLevel) { //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown ChatCommands.currentRound = RoundManager.Instance; if (!ChatCommands.levelEnemySpawns.ContainsKey(newLevel)) { List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies) { list.Add(enemy); } ChatCommands.levelEnemySpawns.Add(newLevel, list); } ChatCommands.levelEnemySpawns.TryGetValue(newLevel, out var value); newLevel.Enemies = value; foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies) { ChatCommands.mls.LogInfo((object)("Inside: " + enemy2.enemyType.enemyName)); if (!ChatCommands.enemyRaritys.ContainsKey(enemy2)) { ChatCommands.enemyRaritys.Add(enemy2, enemy2.rarity); } ChatCommands.enemyRaritys.TryGetValue(enemy2, out var value2); enemy2.rarity = value2; } foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies) { ChatCommands.mls.LogInfo((object)("Outside: " + outsideEnemy.enemyType.enemyName)); if (!ChatCommands.enemyRaritys.ContainsKey(outsideEnemy)) { ChatCommands.enemyRaritys.Add(outsideEnemy, outsideEnemy.rarity); } ChatCommands.enemyRaritys.TryGetValue(outsideEnemy, out var value3); outsideEnemy.rarity = value3; } foreach (SpawnableEnemyWithRarity enemy3 in newLevel.Enemies) { if (!ChatCommands.enemyPropCurves.ContainsKey(enemy3)) { ChatCommands.enemyPropCurves.Add(enemy3, enemy3.enemyType.probabilityCurve); } AnimationCurve value4 = new AnimationCurve(); ChatCommands.enemyPropCurves.TryGetValue(enemy3, out value4); enemy3.enemyType.probabilityCurve = value4; } return true; } [HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")] [HarmonyPostfix] private static void PatchDeadline(TimeOfDay __instance) { if (ChatCommands.isHost && ChatCommands.CustomDeadline != int.MinValue) { __instance.quotaVariables.deadlineDaysAmount = ChatCommands.CustomDeadline; __instance.timeUntilDeadline = (float)(__instance.quotaVariables.deadlineDaysAmount + ChatCommands.CustomDeadline) * __instance.totalTime; TimeOfDay.Instance.timeUntilDeadline = (int)(TimeOfDay.Instance.totalTime * (float)TimeOfDay.Instance.quotaVariables.deadlineDaysAmount); TimeOfDay.Instance.SyncTimeClientRpc(__instance.globalTime, (int)__instance.timeUntilDeadline); ((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\n " + TimeOfDay.Instance.daysUntilDeadline; } } [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPrefix] private static void SetIsHost() { ChatCommands.mls.LogInfo((object)("Host Status: " + ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)); ChatCommands.isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost; } [HarmonyPatch(typeof(PlayerControllerB), "AllowPlayerDeath")] [HarmonyPrefix] private static bool OverrideDeath() { return !ChatCommands.enableGod; } [HarmonyPatch(typeof(Terminal), "RunTerminalEvents")] [HarmonyPostfix] private static void InfiniteCredits(ref int ___groupCredits) { if (ChatCommands.isHost && ChatCommands.EnableInfiniteCredits) { ___groupCredits = 50000; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void SpeedHackFunc(ref float ___jumpForce, ref float ___sprintMeter, ref float ___sprintMultiplier, ref bool ___isSprinting) { if (ChatCommands.speedHack) { ___jumpForce = 25f; ___sprintMeter = 1f; if (___isSprinting) { ___sprintMultiplier = 10f; } } else { ___jumpForce = defaultJumpForce; } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPrefix] private static void GetPlayerRef(ref PlayerControllerB __instance) { ChatCommands.playerRef = __instance; defaultJumpForce = __instance.jumpForce; ChatCommands.mls.LogInfo((object)("Default Jump Force: " + defaultJumpForce)); } [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] [HarmonyPrefix] private static void GetRoundManagerRef(ref RoundManager __instance) { if (!ChatCommands.isHost) { return; } ChatCommands.mls.LogInfo((object)"Host, getting mine ref..."); int num = ChatCommands.currentRound.currentLevel.spawnableMapObjects.Count(); for (int i = 0; i < num; i++) { if (((Object)ChatCommands.currentRound.currentLevel.spawnableMapObjects[i].prefabToSpawn).name == "Landmine") { ChatCommands.mls.LogInfo((object)("Found Mine Index: " + i)); ChatCommands.mine = i; break; } if (((Object)ChatCommands.currentRound.currentLevel.spawnableMapObjects[i].prefabToSpawn).name == "Turret") { ChatCommands.mls.LogInfo((object)("Found Turret Index: " + i)); ChatCommands.turret = i; break; } } } } }