public static void InitPatch() { if (InitComplete) { return; } try { harmony = Harmony.CreateAndPatchAll(typeof(SkCommandPatcher).Assembly); } catch (Exception ex) { SkCommandProcessor.PrintOut("Something failed, there is a strong possibility another mod blocked this operation.", SkCommandProcessor.LogTo.Console); SkUtilities.Logz(new string[2] { "SkCommandPatcher", "PATCH" }, new string[3] { "PATCH => FAILED. CHECK FOR OTHER MODS BLOCKING PATCHES.\n", ex.Message, ex.StackTrace }, LogType.Error); } finally { InitComplete = true; } }
private void Update() { HandleConsole(); if ((SkConfigEntry.CAllowChatCommandInput != null && SkConfigEntry.CAllowChatCommandInput.Value) || SkConfigEntry.CAllowChatCommandInput == null) { HandleChat(); } if (!anncounced1) { if (Console.instance != null && Player.m_localPlayer == null) { SkCommandProcessor.Announce(); LoadConsoleCustomizations(); anncounced1 = true; } } else if (Player.m_localPlayer != null) { anncounced1 = false; } if (!anncounced2) { if (Chat.instance != null) { SkCommandProcessor.Announce(); LoadConsoleCustomizations(); anncounced2 = true; } } else if (Chat.instance == null) { anncounced2 = false; } if (!SkConfigEntry.CAutoRunComplete) { if (SkConfigEntry.CAutoRun != null && SkConfigEntry.CAutoRun.Value) { if (Player.m_localPlayer != null && Chat.instance != null && Console.instance != null) { try { SkUtilities.Logz(new string[2] { "CMD", "AUTORUN" }, new string[1] { "Command List:" + SkConfigEntry.CAutoRunCommand.Value }); SkCommandProcessor.PrintOut("==> AutoRun enabled! Command line: " + SkConfigEntry.CAutoRunCommand.Value, SkCommandProcessor.LogTo.Console); SkCommandProcessor.ProcessCommands(SkConfigEntry.CAutoRunCommand.Value, SkCommandProcessor.LogTo.Console); } catch (Exception) { SkUtilities.Logz(new string[1] { "Console" }, new string[1] { "AutoRun Failed. Something went wrong. Command line: " + SkConfigEntry.CAutoRunCommand.Value }, LogType.Warning); SkCommandProcessor.PrintOut("==> AutoRun Failed. Something went wrong. Command line: " + SkConfigEntry.CAutoRunCommand.Value, SkCommandProcessor.LogTo.Console); } finally { SkConfigEntry.CAutoRunComplete = true; } } } else { SkConfigEntry.CAutoRunComplete = true; } } if (SkCommandProcessor.bTeleport && Input.GetKeyDown(KeyCode.BackQuote) && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out var hitInfo)) { Vector3 point = hitInfo.point; Player.m_localPlayer.transform.position = point; Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Warp!"); } if (!SkCommandProcessor.bDetectEnemies) { return; } try { List <Character> allCharacters = Character.GetAllCharacters(); if (allCharacters.Count > 0) { foreach (Character item in allCharacters) { if (item != null && !item.IsDead() && !item.IsPlayer()) { if (Vector3.Distance(item.transform.position, Player.m_localPlayer.transform.position) < (float)SkCommandProcessor.bDetectRange) { if (!nearbyCharacters.Contains(item)) { nearbyCharacters.Add(item); } } else if (nearbyCharacters.Contains(item)) { nearbyCharacters.Remove(item); } } else if (nearbyCharacters.Contains(item)) { nearbyCharacters.Remove(item); } } if (nearbyCharacters.Count > 0) { foreach (Character item2 in new List <Character>(nearbyCharacters)) { if (!allCharacters.Contains(item2)) { nearbyCharacters.Remove(item2); } } } } if (nearbyCharacters.Count > 0 && SkCommandProcessor.btDetectEnemiesSwitch) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Enemy nearby!"); SkCommandProcessor.btDetectEnemiesSwitch = false; } else if (nearbyCharacters.Count == 0) { SkCommandProcessor.btDetectEnemiesSwitch = true; } } catch (Exception) { } }