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 GhostMode v2.7.1
GhostMode.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; 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 GameNetcodeStuff; using HarmonyLib; using OPJosMod.GhostMode.CustomRpc; using OPJosMod.GhostMode.Enemy.Patches; using OPJosMod.GhostMode.Patches; using OPJosMod.Utils; using Steamworks; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OPJosMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OPJosMod")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("70095872-b952-4e27-bbc4-3d70d0238f39")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace OPJosMod { public static class ConfigVariables { public static bool seeOtherGhosts; public static float waitTimeBetweenInteractions; public static Key startGhostModeButton; public static Key teleportBodyButton; public static Key toggleBrightModeButton; public static Key teleportFrontDoorButton; public static Key switchToSpectateButton; public static Key toggleNoClipButton; public static float noClipSpeed; public static OPnessModes OPness; public static Key teleportShipButton; public static bool enemiesDetectYou; public static bool canPickupScrap; public static bool canPressTeleportButtons; public static Key teleportToPlayerForwardButton; public static Key teleportToPlayerBackwardButton; public static Key noClipForwardButton; public static Key noClipBackwardButton; public static Key noClipLeftButton; public static Key noClipRightButton; public static Key noClipUpButton; public static Key noClipDownButton; } public enum OPnessModes { Limited, Balanced, Unrestricted } } namespace OPJosMod.Utils { public class GeneralUtils { public static bool twoPointsAreClose(Vector3 point1, Vector3 point2, float closeThreshold) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) bool flag = true; float num = Vector3.Distance(point1, point2); if (num <= closeThreshold) { return true; } return false; } public static string simplifyObjectNames(string ogName) { string text = ogName; int num = text.IndexOf("("); if (num != -1) { text = text.Substring(0, num).Trim(); } return text; } } public class ReflectionUtils { public static void InvokeMethod(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void InvokeMethod(object obj, Type forceType, string methodName, object[] parameters) { MethodInfo method = forceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void SetPropertyValue(object obj, string propertyName, object value) { Type type = obj.GetType(); PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); property.SetValue(obj, value); } public static T InvokeMethod<T>(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)method.Invoke(obj, parameters); } public static T GetFieldValue<T>(object obj, string fieldName) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)field.GetValue(obj); } public static void SetFieldValue(object obj, string fieldName, object value) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field.SetValue(obj, value); } } } namespace OPJosMod.GhostMode { public static class GlobalVariables { public static bool ModActivated; } [BepInPlugin("OpJosMod.GhostMode", "GhostMode", "2.7.0")] public class OpJosMod : BaseUnityPlugin { private const string modGUID = "OpJosMod.GhostMode"; private const string modName = "GhostMode"; private const string modVersion = "2.7.0"; private readonly Harmony harmony = new Harmony("OpJosMod.GhostMode"); private static OpJosMod Instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("OpJosMod.GhostMode"); mls.LogInfo((object)"mod has started"); setupConfig(); CompleteRecievedTasks.SetLogSource(mls); PatchesForRPC.SetLogSource(mls); RpcMessageHandler.SetLogSource(mls); PlayerControllerBPatch.SetLogSource(mls); StartOfRoundPatch.SetLogSource(mls); EnemyAIPatch.SetLogSource(mls); HUDManagerPatch.SetLogSource(mls); CentipedeAIPatch.SetLogSource(mls); MouthDogAIPatch.SetLogSource(mls); ForestGiantAIPatch.SetLogSource(mls); SandSpiderAIPatch.SetLogSource(mls); NutcrackerEnemyAIPatch.SetLogSource(mls); StartMatchLeverPatch.SetLogSource(mls); LandminePatch.SetLogSource(mls); FlowermanAIPatch.SetLogSource(mls); CrawlerAIPatch.SetLogSource(mls); TurretPatch.SetLogSource(mls); MaskedPlayerEnemyPatch.SetLogSource(mls); JesterAIPatch.SetLogSource(mls); ShovelPatch.SetLogSource(mls); RadMechAIPatch.SetLogSource(mls); ButlerEnemyAIPatch.SetLogSource(mls); SpikeRoofTrapPatch.SetLogSource(mls); harmony.PatchAll(); } private void setupConfig() { //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: 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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: 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_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0356: 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_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<OPnessModes> val = ((BaseUnityPlugin)this).Config.Bind<OPnessModes>("OP-Ness", "OPness", OPnessModes.Balanced, "(limited, balanced, unrestricted) The three modes of ghost mode. (limited -> almost no interactions allowed.) (balanced -> delays on lots of interactions. completly restricted from a few.) (unrestricted -> no restrictions on what you can interact with at all)"); ConfigEntry<float> val2 = ((BaseUnityPlugin)this).Config.Bind<float>("GhostMode interaction delay", "GhostModeInteractionDelay", 45f, "How long you must wait between interactions when in ghost mode. Set to -1 to remove the ability to interact at all"); ConfigEntry<Key> val3 = ((BaseUnityPlugin)this).Config.Bind<Key>("Start Ghost Mode Button", "StartGhostModeButton", (Key)30, "Button to turn into ghost"); ConfigEntry<bool> val4 = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Grab Scrap", "CanGrabScrap", true, "this setting only has an effect if you are in balanced mode"); ConfigEntry<bool> val5 = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Press Teleport Buttons", "CanPressTeleportButtons", false, "this setting only has an effect if you are in balanced mode"); ConfigEntry<Key> val6 = ((BaseUnityPlugin)this).Config.Bind<Key>("Teleport to Dead Body Button", "TeleportToDeadBodyButton", (Key)65, "Button to teleport to your dead body"); ConfigEntry<Key> val7 = ((BaseUnityPlugin)this).Config.Bind<Key>("Toggle Bright Mode Button", "ToggleBrightModeButton", (Key)16, "Button to toggle on bright mode"); ConfigEntry<Key> val8 = ((BaseUnityPlugin)this).Config.Bind<Key>("Teleport to Front Door Button", "TeleportToFrontDoorButton", (Key)63, "Button to teleport to the front door"); ConfigEntry<Key> val9 = ((BaseUnityPlugin)this).Config.Bind<Key>("Teleport to Ship Button", "TeleportToShipButton", (Key)64, "Button to teleport you to the ship"); ConfigEntry<Key> val10 = ((BaseUnityPlugin)this).Config.Bind<Key>("Switch to Spectate Mode Button", "SwitchToSpectateModeButton", (Key)29, "Button to switch back to specate mode"); ConfigEntry<bool> val11 = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies Detect Ghost", "EnemiesDetectGhost", false, "Enemies are able to detect you as a ghost, true or false"); ConfigEntry<Key> val12 = ((BaseUnityPlugin)this).Config.Bind<Key>("Teleport to Player 1", "TeleportToPlayerForward", (Key)62, "Button to other players forward in the list of players"); ConfigEntry<Key> val13 = ((BaseUnityPlugin)this).Config.Bind<Key>("Teleport to Player 2", "TeleportToPlayerBackward", (Key)61, "Button to teleport you to other players backwards in the list of players"); ConfigEntry<Key> val14 = ((BaseUnityPlugin)this).Config.Bind<Key>("Toggle NoClip Mode Button", "ToggleNoClipModeButton", (Key)40, "Button to enter/leave no clip mode"); ConfigEntry<float> val15 = ((BaseUnityPlugin)this).Config.Bind<float>("NoClip Flight Speed", "NoClipFlightSpeed", 0.27f, "How fast you move while in no clip"); ConfigEntry<Key> val16 = ((BaseUnityPlugin)this).Config.Bind<Key>("NoClip Forward Button", "NoClipForwardButton", (Key)37, "Button to move forward in no clip mode"); ConfigEntry<Key> val17 = ((BaseUnityPlugin)this).Config.Bind<Key>("NoClip Backward Button", "NoClipBackwardButton", (Key)33, "Button to move backwards in no clip mode"); ConfigEntry<Key> val18 = ((BaseUnityPlugin)this).Config.Bind<Key>("NoClip Left Button", "NoClipLeftButton", (Key)15, "Button to move left in no clip mode"); ConfigEntry<Key> val19 = ((BaseUnityPlugin)this).Config.Bind<Key>("NoClip Right Button", "NoClipRightButton", (Key)18, "Button to move right in no clip mode"); ConfigEntry<Key> val20 = ((BaseUnityPlugin)this).Config.Bind<Key>("NoClip Up Button", "NoClipUpButton", (Key)1, "Button to move up in no clip mode"); ConfigEntry<Key> val21 = ((BaseUnityPlugin)this).Config.Bind<Key>("NoClip Down Button", "NoClipDownButton", (Key)51, "Button to move down in no clip mode"); ConfigVariables.waitTimeBetweenInteractions = val2.Value; ConfigVariables.canPickupScrap = val4.Value; ConfigVariables.canPressTeleportButtons = val5.Value; ConfigVariables.startGhostModeButton = val3.Value; ConfigVariables.teleportBodyButton = val6.Value; ConfigVariables.toggleBrightModeButton = val7.Value; ConfigVariables.teleportFrontDoorButton = val8.Value; ConfigVariables.switchToSpectateButton = val10.Value; ConfigVariables.toggleNoClipButton = val14.Value; ConfigVariables.teleportShipButton = val9.Value; ConfigVariables.teleportToPlayerForwardButton = val12.Value; ConfigVariables.teleportToPlayerBackwardButton = val13.Value; ConfigVariables.noClipSpeed = val15.Value; ConfigVariables.OPness = val.Value; ConfigVariables.enemiesDetectYou = val11.Value; ConfigVariables.noClipForwardButton = val16.Value; ConfigVariables.noClipBackwardButton = val17.Value; ConfigVariables.noClipLeftButton = val18.Value; ConfigVariables.noClipRightButton = val19.Value; ConfigVariables.noClipUpButton = val20.Value; ConfigVariables.noClipDownButton = val21.Value; ((BaseUnityPlugin)this).Config.Save(); } } } namespace OPJosMod.GhostMode.Patches { [HarmonyPatch(typeof(Shovel))] internal class ShovelPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("HitShovel")] [HarmonyPrefix] private static bool hitShovelPatch(Shovel __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009b: 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_00fc: 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) if (!PlayerControllerBPatch.isGhostMode) { return true; } if (ConfigVariables.OPness == OPnessModes.Unrestricted) { return true; } try { GameObject val = null; PlayerControllerB fieldValue = ReflectionUtils.GetFieldValue<PlayerControllerB>(__instance, "previousPlayerHeldBy"); RaycastHit[] fieldValue2 = ReflectionUtils.GetFieldValue<RaycastHit[]>(__instance, "objectsHitByShovel"); List<RaycastHit> fieldValue3 = ReflectionUtils.GetFieldValue<List<RaycastHit>>(__instance, "objectsHitByShovelList"); int fieldValue4 = ReflectionUtils.GetFieldValue<int>(__instance, "shovelMask"); fieldValue.activatingItem = false; fieldValue.twoHanded = false; fieldValue2 = Physics.SphereCastAll(((Component)fieldValue.gameplayCamera).transform.position + ((Component)fieldValue.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)fieldValue.gameplayCamera).transform.forward, 1.5f, fieldValue4, (QueryTriggerInteraction)2); fieldValue3 = fieldValue2.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList(); IHittable val3 = default(IHittable); for (int i = 0; i < fieldValue3.Count; i++) { RaycastHit val2 = fieldValue3[i]; if (((Component)((RaycastHit)(ref val2)).transform).TryGetComponent<IHittable>(ref val3)) { mls.LogMessage((object)("Hit object: " + ((Object)((Component)((RaycastHit)(ref val2)).transform).gameObject).name)); val = ((Component)((RaycastHit)(ref val2)).transform).gameObject; } } if ((Object)(object)val != (Object)null && ((Object)val).name.Contains("Player")) { mls.LogMessage((object)"dont actaully hit the player"); return false; } } catch (Exception ex) { mls.LogError((object)ex); return true; } return true; } } [HarmonyPatch(typeof(StartMatchLever))] internal class StartMatchLeverPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("Update")] [HarmonyPrefix] private static void updatePatch(StartMatchLever __instance) { if (PlayerControllerBPatch.isGhostMode && ConfigVariables.OPness != OPnessModes.Unrestricted) { __instance.triggerScript.hoverTip = "Can't use this as ghost!"; __instance.triggerScript.interactable = false; } } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { private static ManualLogSource mls; public static int livingPlayersCount = 0; public static List<string> playerNotes = new List<string>(); public static TextMeshProUGUI mcPlayerNotes; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("Update")] [HarmonyPrefix] private static void updatePatch(HUDManager __instance) { if (PlayerControllerBPatch.isGhostMode && !((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)) { if (livingPlayersCount != RoundManager.Instance.playersManager.livingPlayers) { mls.LogMessage((object)"Adding boxes"); __instance.gameOverAnimator.SetTrigger("gameOver"); ((TMP_Text)__instance.spectatingPlayerText).text = ""; ((TMP_Text)__instance.holdButtonToEndGameEarlyText).text = ""; ((Component)__instance.holdButtonToEndGameEarlyMeter).gameObject.SetActive(false); ((TMP_Text)__instance.holdButtonToEndGameEarlyVotesText).text = ""; updateBoxesSpectateUI(__instance); } FieldInfo field = typeof(HUDManager).GetField("updateSpectateBoxesInterval", BindingFlags.Instance | BindingFlags.NonPublic); float num = (float)field.GetValue(__instance); MethodInfo method = typeof(HUDManager).GetMethod("UpdateSpectateBoxSpeakerIcons", BindingFlags.Instance | BindingFlags.NonPublic); if (num >= 0.35f) { field.SetValue(__instance, 0f); method.Invoke(__instance, null); } else { num += Time.deltaTime; field.SetValue(__instance, num); } livingPlayersCount = RoundManager.Instance.playersManager.livingPlayers; } } public static void updateBoxesSpectateUI(HUDManager __instance) { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB playerScript; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { playerScript = StartOfRound.Instance.allPlayerScripts[i]; if (!playerScript.isPlayerDead) { continue; } FieldInfo field = typeof(HUDManager).GetField("spectatingPlayerBoxes", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<Animator, PlayerControllerB> dictionary = (Dictionary<Animator, PlayerControllerB>)field.GetValue(__instance); FieldInfo field2 = typeof(HUDManager).GetField("yOffsetAmount", BindingFlags.Instance | BindingFlags.NonPublic); float num = (float)field2.GetValue(__instance); FieldInfo field3 = typeof(HUDManager).GetField("boxesAdded", BindingFlags.Instance | BindingFlags.NonPublic); int num2 = (int)field3.GetValue(__instance); if (dictionary.Values.Contains(playerScript)) { GameObject gameObject = ((Component)dictionary.FirstOrDefault((KeyValuePair<Animator, PlayerControllerB> x) => (Object)(object)x.Value == (Object)(object)playerScript).Key).gameObject; if (!gameObject.activeSelf) { RectTransform component = gameObject.GetComponent<RectTransform>(); component.anchoredPosition = new Vector2(component.anchoredPosition.x, num); field3.SetValue(__instance, num2++); gameObject.SetActive(true); field2.SetValue(__instance, num - 70f); } } else { GameObject val = Object.Instantiate<GameObject>(__instance.spectatingPlayerBoxPrefab, __instance.SpectateBoxesContainer, false); val.SetActive(true); RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchoredPosition = new Vector2(component2.anchoredPosition.x, num); field2.SetValue(__instance, num - 70f); field3.SetValue(__instance, num2++); dictionary.Add(val.GetComponent<Animator>(), playerScript); field.SetValue(__instance, dictionary); ((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).text = playerScript.playerUsername; if (!GameNetworkManager.Instance.disableSteam) { HUDManager.FillImageWithSteamProfile(val.GetComponent<RawImage>(), SteamId.op_Implicit(playerScript.playerSteamId), true); } } mls.LogMessage((object)$"boxes count:{dictionary.Count}"); } } [HarmonyPatch("FillEndGameStats")] [HarmonyPrefix] private static void fillEndGameStatsPatchPre(HUDManager __instance, ref EndOfGameStats stats) { } } [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("OnCollideWithPlayer")] [HarmonyPrefix] private static bool onCollideWithPlayerPatch(EnemyAI __instance, ref Collider other) { if (PlayerControllerBPatch.isGhostMode) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (StartOfRound.Instance.localPlayerController.playerClientId == component.playerClientId) { return false; } } return true; } [HarmonyPatch("PlayerIsTargetable")] [HarmonyPrefix] private static void playerIsTargetablePatch(ref bool cannotBeInShip, ref PlayerControllerB playerScript) { if (PlayerControllerBPatch.isGhostMode && ((NetworkBehaviour)playerScript).IsOwner && !ConfigVariables.enemiesDetectYou) { playerScript.isInHangarShipRoom = true; cannotBeInShip = true; } } [HarmonyPatch("GetAllPlayersInLineOfSight")] [HarmonyPostfix] private static void getAllPlayersInLineOfSightPatch(EnemyAI __instance, ref PlayerControllerB[] __result) { if (!PlayerControllerBPatch.isGhostMode || ConfigVariables.enemiesDetectYou) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; ulong playerClientId = StartOfRound.Instance.localPlayerController.playerClientId; if (__result == null || __result.Length == 0) { return; } int num = -1; for (int i = 0; i < __result.Length; i++) { if ((Object)(object)__result[i] == (Object)(object)allPlayerScripts[playerClientId]) { num = i; break; } } if (num == -1) { return; } PlayerControllerB[] array = (PlayerControllerB[])(object)new PlayerControllerB[__result.Length - 1]; int num2 = 0; for (int j = 0; j < __result.Length; j++) { if (j != num) { array[num2] = __result[j]; num2++; } } __result = array; } [HarmonyPatch("KillEnemy")] [HarmonyPrefix] private static bool killEnemyPatch(EnemyAI __instance) { return stopKill(__instance); } [HarmonyPatch("KillEnemyOnOwnerClient")] [HarmonyPrefix] private static bool patchKillEnemyOnOwnerClient(EnemyAI __instance) { return stopKill(__instance); } [HarmonyPatch("CheckLineOfSightForClosestPlayer")] [HarmonyPrefix] private static bool checkLineOfSightForClosestPlayerPatch(EnemyAI __instance) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && getClosestPlayerIncludingGhost(__instance).playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { mls.LogMessage((object)"enemy can't see if player is in line of sight"); return false; } return true; } public static PlayerControllerB getClosestPlayerIncludingGhost(EnemyAI enemy) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = null; PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>(); float num = float.PositiveInfinity; PlayerControllerB[] array2 = array; foreach (PlayerControllerB val2 in array2) { float num2 = Vector3.Distance(((Component)enemy).transform.position, ((Component)val2).transform.position); if (num2 < num) { num = num2; val = val2; } } if (!((Object)(object)val != (Object)null)) { mls.LogError((object)"No EnemyAI found in the scene."); } return val; } public static void makeEnemiesDropFocus(PlayerControllerB player) { mls.LogMessage((object)("enemies dropped focus on " + ((Object)player).name)); EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(); EnemyAI[] array2 = array; foreach (EnemyAI val in array2) { if (val.targetPlayer.playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { val.targetPlayer = null; } } } public static bool ghostOnlyPlayerInFacility() { int num = 0; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && StartOfRound.Instance.allPlayerScripts[i].isInsideFactory && StartOfRound.Instance.allPlayerScripts[i].playerClientId != StartOfRound.Instance.localPlayerController.playerClientId) { num++; } } if (num == 0) { mls.LogMessage((object)"ghost only one in facility"); return true; } return false; } private static bool stopKill(EnemyAI enemy) { mls.LogMessage((object)"enemy ai tried hit killEnemyPatch"); if (PlayerControllerBPatch.isGhostMode && enemy.GetClosestPlayer(false, false, false).playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { mls.LogMessage((object)"enemy ai tried to direclty kill player"); return false; } return true; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPrefix] private static void reviveDeadPlayersPatch(StartOfRound __instance) { mls.LogMessage((object)"revive dead players patch hit in start of round class"); PlayerControllerBPatch.resetGhostModeVars(__instance.localPlayerController); } [HarmonyPatch("OnPlayerConnectedClientRpc")] [HarmonyPrefix] private static void onPlayerConnectedClientRpcPatch(StartOfRound __instance, ref ulong clientId) { mls.LogMessage((object)$"player connected patch hit in start of round class, clientId: {clientId}"); if ((Object)(object)__instance.localPlayerController == (Object)null) { PlayerControllerBPatch.resetGhostModeVars(null); } } [HarmonyPatch("ShipLeave")] [HarmonyPrefix] public static void shipLeavePatch(StartOfRound __instance) { mls.LogMessage((object)"rekill player locally called from start of round, because ship is taking off"); if (PlayerControllerBPatch.isGhostMode) { PlayerControllerBPatch.resetGhostModeVars(__instance.localPlayerController); PlayerControllerBPatch.setToSpectatemode(__instance.localPlayerController); } } [HarmonyPatch("StartGame")] [HarmonyPrefix] public static void startGamePatch(StartOfRound __instance) { mls.LogMessage((object)"rekill player locally called from start of round, because level is starting"); if (PlayerControllerBPatch.isGhostMode) { PlayerControllerBPatch.resetGhostModeVars(__instance.localPlayerController); } } [HarmonyPatch("UpdatePlayerVoiceEffects")] [HarmonyPrefix] public static bool updatePlayerVoiceEffectsPatch(StartOfRound __instance) { if (PlayerControllerBPatch.isGhostMode) { for (int i = 0; i < __instance.allPlayerScripts.Length; i++) { PlayerControllerB val = __instance.allPlayerScripts[i]; if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController) { continue; } if (val.voicePlayerState == null || val.currentVoiceChatIngameSettings._playerState == null || (Object)(object)val.currentVoiceChatAudioSource == (Object)null || (Object)(object)val.currentVoiceChatIngameSettings == (Object)null) { __instance.RefreshPlayerVoicePlaybackObjects(); if (val.voicePlayerState == null || (Object)(object)val.currentVoiceChatAudioSource == (Object)null) { continue; } } AudioSource currentVoiceChatAudioSource = StartOfRound.Instance.allPlayerScripts[i].currentVoiceChatAudioSource; if (__instance.allPlayerScripts[i].isPlayerDead) { val.currentVoiceChatIngameSettings.set2D = true; currentVoiceChatAudioSource.volume = 1f; ((Behaviour)((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>()).enabled = false; ((Behaviour)((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>()).enabled = false; currentVoiceChatAudioSource.panStereo = 0f; } else { val.currentVoiceChatIngameSettings.set2D = false; currentVoiceChatAudioSource.volume = 0.8f; } } return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { private static ManualLogSource mls; public static bool allowKill = true; public static bool isGhostMode = false; private static float lastTimeJumped = Time.time; private static Vector3 deathLocation; private static int consecutiveDeathExceptions = 0; private static int maxConsecutiveDeathExceptions = 3; private static float exceptionCooldownTime = 2f; private static float lastExceptionTime = 0f; private static Vector3[] lastSafeLocations = (Vector3[])(object)new Vector3[10]; private static int safeLocationsIndex = 0; private static float timeWhenSafe = Time.time; private static Ray interactRay; private static RaycastHit hit; private static int interactableObjectsMask = 832; private static bool isTogglingBrightMode = false; private static Coroutine togglingBrightModeCoroutine; private static bool isBrightModeOn = false; private static LightType OGnightVisionType; private static float OGnightVisionIntensity; private static float OGnightVisionRange; private static float OGnightVisionShadowStrength; private static float OGnightVisionBounceIntensity; private static float OGnightVisionInnerSpotAngle; private static float OGnightVisionSpotAngle; private static bool setupValuesYet = false; private static float maxSpeed = 10f; private static int tpPlayerIndex = 0; private static Coroutine tpCoroutine; private static bool isTeleporting = false; private static bool isTogglingCollisions = false; private static Coroutine togglingCollisionsCoroutine; private static bool collisionsOn = true; public static float lastInteractedTime = Time.time; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } public static void resetGhostModeVars(PlayerControllerB __instance) { try { mls.LogMessage((object)"hit reset ghost vars function"); allowKill = true; isGhostMode = false; isTogglingBrightMode = false; consecutiveDeathExceptions = 0; lastSafeLocations = (Vector3[])(object)new Vector3[10]; timeWhenSafe = Time.time; tpPlayerIndex = 0; tpCoroutine = null; isTeleporting = false; isTogglingCollisions = false; isTogglingBrightMode = false; isBrightModeOn = false; collisionsOn = true; if ((Object)(object)__instance != (Object)null) { ((MonoBehaviour)__instance).StopAllCoroutines(); if ((Object)(object)__instance.nightVision != (Object)null) { ((Component)__instance.nightVision).gameObject.SetActive(true); } FieldInfo field = typeof(PlayerControllerB).GetField("isJumping", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PlayerControllerB).GetField("playerSlidingTimer", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field3 = typeof(PlayerControllerB).GetField("isFallingFromJump", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field4 = typeof(PlayerControllerB).GetField("sprintMultiplier", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null && field2 != null && field3 != null && field4 != null) { field2.SetValue(__instance, 0f); field.SetValue(__instance, false); field3.SetValue(__instance, false); __instance.fallValue = 0f; __instance.fallValueUncapped = 0f; field4.SetValue(__instance, 1f); } else { mls.LogError((object)"private fields not found"); } setNightVisionMode(__instance, 0); __instance.hasBegunSpectating = false; StartOfRound.Instance.SwitchCamera(GameNetworkManager.Instance.localPlayerController.gameplayCamera); HUDManager.Instance.HideHUD(false); ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = ""; HUDManager.Instance.RemoveSpectateUI(); showAliveUI(__instance, show: true); } } catch (Exception arg) { mls.LogMessage((object)$"error durign resetign ghost values: {arg}"); } } private static void setNightVisionMode(PlayerControllerB __instance, int mode) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) switch (mode) { case 0: mls.LogMessage((object)"setting default night vision values"); __instance.nightVision.type = OGnightVisionType; __instance.nightVision.intensity = OGnightVisionIntensity; __instance.nightVision.range = OGnightVisionRange; __instance.nightVision.shadowStrength = OGnightVisionShadowStrength; __instance.nightVision.bounceIntensity = OGnightVisionBounceIntensity; __instance.nightVision.innerSpotAngle = OGnightVisionInnerSpotAngle; __instance.nightVision.spotAngle = OGnightVisionSpotAngle; break; case 1: __instance.nightVision.type = (LightType)2; __instance.nightVision.intensity = 44444f; __instance.nightVision.range = 99999f; __instance.nightVision.shadowStrength = 0f; __instance.nightVision.bounceIntensity = 5555f; __instance.nightVision.innerSpotAngle = 999f; __instance.nightVision.spotAngle = 9999f; break; } } private static void showAliveUI(PlayerControllerB __instance, bool show) { ((Component)HUDManager.Instance.Clock.canvasGroup).gameObject.SetActive(show); ((Component)HUDManager.Instance.selfRedCanvasGroup).gameObject.SetActive(show); ((Component)__instance.sprintMeterUI).gameObject.SetActive(show); ((Component)HUDManager.Instance.weightCounter).gameObject.SetActive(show); if (!show) { TextMeshProUGUI[] controlTipLines = HUDManager.Instance.controlTipLines; foreach (TextMeshProUGUI val in controlTipLines) { ((TMP_Text)val).text = ""; } } } private static Vector3 getTeleportLocation(PlayerControllerB __instance) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0048: Unknown result type (might be due to invalid IL or missing references) Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(0f, 0f, 0f); if ((Object)(object)__instance.deadBody != (Object)null) { position = ((Component)__instance.deadBody).transform.position; return position; } position = deathLocation; return position; } private static void ChangeAudioListenerToObject(PlayerControllerB __instance, GameObject addToObject) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) ((Component)__instance.activeAudioListener).transform.SetParent(addToObject.transform); ((Component)__instance.activeAudioListener).transform.localEulerAngles = Vector3.zero; ((Component)__instance.activeAudioListener).transform.localPosition = Vector3.zero; StartOfRound.Instance.audioListener = __instance.activeAudioListener; } [HarmonyPatch("KillPlayer")] [HarmonyPrefix] private static bool patchKillPlayer(PlayerControllerB __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (__instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { if (!allowKill) { if (time - lastExceptionTime > exceptionCooldownTime) { consecutiveDeathExceptions = 0; } consecutiveDeathExceptions++; lastExceptionTime = time; if (consecutiveDeathExceptions >= maxConsecutiveDeathExceptions) { mls.LogMessage((object)"Too many consecutive death exceptions. Stuck in death loop."); Vector3 position = lastSafeLocations[(safeLocationsIndex - 9 + lastSafeLocations.Length) % lastSafeLocations.Length]; ((Component)__instance).transform.position = position; } mls.LogMessage((object)"Didn't allow kill, player should be dead on server already"); return false; } allowKill = false; deathLocation = ((Component)__instance).transform.position; consecutiveDeathExceptions = 0; mls.LogMessage((object)"called kill player"); savePostGameNotes(); } mls.LogMessage((object)"kill patch was called as, __instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId"); return true; } private static void savePostGameNotes() { } [HarmonyPatch("Update")] [HarmonyPostfix] private static void updatePatch(PlayerControllerB __instance, ref Light ___nightVision) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) if (!setupValuesYet && allowKill) { mls.LogMessage((object)"setting default night vision values"); setupValuesYet = true; OGnightVisionType = __instance.nightVision.type; OGnightVisionIntensity = __instance.nightVision.intensity; OGnightVisionRange = __instance.nightVision.range; OGnightVisionShadowStrength = __instance.nightVision.shadowStrength; OGnightVisionBounceIntensity = __instance.nightVision.bounceIntensity; OGnightVisionInnerSpotAngle = __instance.nightVision.innerSpotAngle; OGnightVisionSpotAngle = __instance.nightVision.spotAngle; } if (Time.time - timeWhenSafe >= 1f) { lastSafeLocations[safeLocationsIndex] = ((Component)__instance).transform.position; safeLocationsIndex = (safeLocationsIndex + 1) % lastSafeLocations.Length; timeWhenSafe = Time.time; } if (allowKill) { return; } __instance.sprintMeter = 1f; if (__instance.isSprinting) { FieldInfo field = typeof(PlayerControllerB).GetField("sprintMultiplier", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(__instance); if (value is float) { if ((float)value < maxSpeed) { float num = (float)value * 1.015f; field.SetValue(__instance, num); } } else { mls.LogError((object)"current spritnMultiplier isn't a float?"); } } else { mls.LogError((object)"private field not found"); } } if (!isGhostMode) { try { if (((ButtonControl)Keyboard.current[ConfigVariables.startGhostModeButton]).wasPressedThisFrame) { mls.LogMessage((object)"attempting to revive"); reviveDeadPlayer(__instance); } } catch { } } else { listenForGhostHotkeys(__instance); } if (__instance.playersManager.livingPlayers == 0 || StartOfRound.Instance.shipIsLeaving) { HUDManager.Instance.DisplayTip("Ship is leaving", "just wait", false, false, "LC_Tip1"); if (isGhostMode) { setToSpectatemode(__instance); } resetGhostModeVars(__instance); } if (__instance.criticallyInjured) { __instance.criticallyInjured = false; __instance.bleedingHeavily = false; HUDManager.Instance.UpdateHealthUI(100, false); } } private static void listenForGhostHotkeys(PlayerControllerB __instance) { //IL_0094: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_0582: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) if (StartOfRound.Instance.localPlayerController.inTerminalMenu || StartOfRound.Instance.localPlayerController.isTypingChat) { return; } if (!collisionsOn) { handleNoClipControls(__instance); } try { if (((ButtonControl)Keyboard.current[ConfigVariables.toggleNoClipButton]).wasPressedThisFrame && !isTogglingCollisions) { isTogglingCollisions = true; togglingCollisionsCoroutine = ((MonoBehaviour)__instance).StartCoroutine(toggleCollisions(__instance)); } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.teleportBodyButton]).wasPressedThisFrame) { mls.LogMessage((object)"attempt to tp to dead body"); string message = "(Teleported to: your dead body)"; tpCoroutine = ((MonoBehaviour)__instance).StartCoroutine(specialTeleportPlayer(__instance, ((Component)__instance.deadBody).transform.position, message)); } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.teleportFrontDoorButton]).wasPressedThisFrame) { mls.LogMessage((object)"attempt to tp to front door"); string message2 = "(Teleported to: Front Door)"; tpCoroutine = ((MonoBehaviour)__instance).StartCoroutine(specialTeleportPlayer(__instance, RoundManager.FindMainEntrancePosition(true, true), message2)); } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.teleportShipButton]).wasPressedThisFrame) { mls.LogMessage((object)"attempt to tp to ship"); string message3 = "(Teleported to: Ship)"; tpCoroutine = ((MonoBehaviour)__instance).StartCoroutine(specialTeleportPlayer(__instance, RoundManager.Instance.playersManager.playerSpawnPositions[0].position, message3)); } } catch { } try { InputAction val = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false); if (val == null || !collisionsOn) { return; } if (val.IsPressed()) { __instance.fallValue = __instance.jumpForce; __instance.fallValueUncapped = __instance.jumpForce; } else if (val.WasReleasedThisFrame()) { ReflectionUtils.SetPropertyValue(__instance, "isJumping", false); ReflectionUtils.SetPropertyValue(__instance, "isFallingFromJump", true); } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.switchToSpectateButton]).wasPressedThisFrame) { mls.LogMessage((object)"attempt to switch back to spectate mode"); setToSpectatemode(__instance); } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.teleportToPlayerBackwardButton]).wasPressedThisFrame) { if (isTeleporting) { return; } isTeleporting = true; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { tpPlayerIndex = (tpPlayerIndex - 1 + allPlayerScripts.Length) % allPlayerScripts.Length; mls.LogMessage((object)$"tp index:{tpPlayerIndex}"); if (!__instance.playersManager.allPlayerScripts[tpPlayerIndex].isPlayerDead && __instance.playersManager.allPlayerScripts[tpPlayerIndex].isPlayerControlled && __instance.playersManager.allPlayerScripts[tpPlayerIndex].playerClientId != StartOfRound.Instance.localPlayerController.playerClientId) { string text = "(Teleported to:" + __instance.playersManager.allPlayerScripts[tpPlayerIndex].playerUsername + ")"; mls.LogMessage((object)$"tp index:{tpPlayerIndex} playerName:{text}"); tpCoroutine = ((MonoBehaviour)__instance).StartCoroutine(specialTeleportPlayer(__instance, ((Component)__instance.playersManager.allPlayerScripts[tpPlayerIndex]).transform.position, text)); return; } } } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.teleportToPlayerForwardButton]).wasPressedThisFrame) { if (isTeleporting) { return; } isTeleporting = true; PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts; for (int j = 0; j < allPlayerScripts2.Length; j++) { tpPlayerIndex = (tpPlayerIndex + 1) % allPlayerScripts2.Length; mls.LogMessage((object)$"tp index:{tpPlayerIndex}"); if (!__instance.playersManager.allPlayerScripts[tpPlayerIndex].isPlayerDead && __instance.playersManager.allPlayerScripts[tpPlayerIndex].isPlayerControlled && __instance.playersManager.allPlayerScripts[tpPlayerIndex].playerClientId != StartOfRound.Instance.localPlayerController.playerClientId) { string text2 = "(Teleported to:" + __instance.playersManager.allPlayerScripts[tpPlayerIndex].playerUsername + ")"; mls.LogMessage((object)$"tp index:{tpPlayerIndex} playerName:{text2}"); tpCoroutine = ((MonoBehaviour)__instance).StartCoroutine(specialTeleportPlayer(__instance, ((Component)__instance.playersManager.allPlayerScripts[tpPlayerIndex]).transform.position, text2)); return; } } } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.toggleBrightModeButton]).wasPressedThisFrame && !isTogglingBrightMode) { isTogglingBrightMode = true; togglingBrightModeCoroutine = ((MonoBehaviour)__instance).StartCoroutine(toggleBrightMode(__instance)); } } catch { } } [HarmonyPatch("Interact_performed")] [HarmonyPrefix] private static bool interact_performedPatch(PlayerControllerB __instance) { if (!isGhostMode) { return true; } if (((NetworkBehaviour)__instance).IsOwner && !__instance.isPlayerDead && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) { if (!canUse(__instance)) { return false; } if (shouldHaveDelay(__instance)) { if (!(Time.time - lastInteractedTime > ConfigVariables.waitTimeBetweenInteractions)) { return false; } lastInteractedTime = Time.time; } } return true; } private static bool shouldHaveDelay(PlayerControllerB __instance, bool showDebug = true) { if (!isGhostMode || ConfigVariables.OPness == OPnessModes.Unrestricted) { return false; } if ((Object)(object)__instance.hoveringOverTrigger != (Object)null && (Object)(object)((Component)__instance.hoveringOverTrigger).gameObject != (Object)null) { string text = GeneralUtils.simplifyObjectNames(((Object)((Component)__instance.hoveringOverTrigger).gameObject).name); if (showDebug) { mls.LogMessage((object)("tried to interact with: " + text)); } string[] source = new string[6] { "Cube", "EntranceTeleportA", "StartGameLever", "TerminalScript", "ButtonGlass", "Trigger" }; if (source.Contains(text)) { return false; } } else if (showDebug) { mls.LogMessage((object)"faliled to find interacted with name"); } return true; } private static bool canUse(PlayerControllerB __instance) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if (!isGhostMode || ConfigVariables.OPness == OPnessModes.Unrestricted) { return true; } if (ConfigVariables.OPness == OPnessModes.Limited) { return false; } List<string> list = new List<string> { "LadderTrigger", "RagdollGrabbableObject" }; if (!ConfigVariables.canPressTeleportButtons) { list.Add("RedButton"); } if ((Object)(object)__instance.hoveringOverTrigger != (Object)null && (Object)(object)((Component)__instance.hoveringOverTrigger).gameObject != (Object)null) { string item = GeneralUtils.simplifyObjectNames(((Object)((Component)__instance.hoveringOverTrigger).gameObject).name); if (list.Contains(item)) { return false; } } Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward); RaycastHit val2 = default(RaycastHit); Physics.Raycast(val, ref val2, __instance.grabDistance, interactableObjectsMask); Collider collider = ((RaycastHit)(ref val2)).collider; GrabbableObject val3 = ((collider != null) ? ((Component)collider).GetComponent<GrabbableObject>() : null); if ((Object)(object)val3 != (Object)null) { string item2 = GeneralUtils.simplifyObjectNames(((Object)val3).name); if (list.Contains(item2) || !ConfigVariables.canPickupScrap) { return false; } } return true; } [HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")] [HarmonyPostfix] private static void setHoverTipAndCurrentInteractTriggerPatch(PlayerControllerB __instance) { if (!isGhostMode) { return; } if (shouldHaveDelay(__instance, showDebug: false)) { float num = lastInteractedTime; float waitTimeBetweenInteractions = ConfigVariables.waitTimeBetweenInteractions; float num2 = waitTimeBetweenInteractions - (Time.time - num); if (Time.time - num <= waitTimeBetweenInteractions && ((TMP_Text)__instance.cursorTip).text != "") { ((TMP_Text)__instance.cursorTip).text = $"Wait: {(int)num2}"; } } if (!canUse(__instance) && ((TMP_Text)__instance.cursorTip).text != "") { ((TMP_Text)__instance.cursorTip).text = "Can't use as a ghost!"; } } private static bool IsPlayerNearGround(PlayerControllerB __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) interactRay = new Ray(((Component)__instance).transform.position, Vector3.down); return Physics.Raycast(interactRay, 0.15f, StartOfRound.Instance.allPlayersCollideWithMask, (QueryTriggerInteraction)1); } private static void PlayerHitGroundEffects(PlayerControllerB __instance) { //IL_01bd: 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) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) __instance.GetCurrentMaterialStandingOn(); if (__instance.fallValue < -9f) { if (__instance.fallValue < -16f) { __instance.movementAudio.PlayOneShot(StartOfRound.Instance.playerHitGroundHard, 1f); WalkieTalkie.TransmitOneShotAudio(__instance.movementAudio, StartOfRound.Instance.playerHitGroundHard, 1f); } else if (__instance.fallValue < -2f) { __instance.movementAudio.PlayOneShot(StartOfRound.Instance.playerHitGroundSoft, 1f); } __instance.LandFromJumpServerRpc(__instance.fallValue < -16f); } if (__instance.takingFallDamage && !__instance.jetpackControls && !__instance.disablingJetpackControls && !__instance.isSpeedCheating && allowKill) { Debug.Log((object)$"Fall damage: {__instance.fallValueUncapped}"); if (__instance.fallValueUncapped < -48.5f) { __instance.DamagePlayer(100, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else if (__instance.fallValueUncapped < -45f) { __instance.DamagePlayer(80, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else if (__instance.fallValueUncapped < -40f) { __instance.DamagePlayer(50, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else { __instance.DamagePlayer(30, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } } if (__instance.fallValue < -16f) { RoundManager.Instance.PlayAudibleNoise(((Component)__instance).transform.position, 7f, 0.5f, 0, false, 0); } } [HarmonyPatch("DamagePlayer")] [HarmonyPrefix] private static void damagePlayerPatch(PlayerControllerB __instance, ref int damageNumber) { if (!allowKill) { __instance.health = 100; __instance.criticallyInjured = false; __instance.bleedingHeavily = false; int num = 100 - damageNumber; __instance.DamagePlayerServerRpc(-num, __instance.health); } } [HarmonyPatch("DamagePlayer")] [HarmonyPostfix] private static void damagePlayerPostPatch(PlayerControllerB __instance, ref int damageNumber) { if (!allowKill) { HUDManager.Instance.UpdateHealthUI(100, false); } } private static void handleNoClipControls(PlayerControllerB __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) //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_0121: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01bf: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: 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) try { if (((ButtonControl)Keyboard.current[ConfigVariables.noClipForwardButton]).isPressed) { Quaternion rotation = ((Component)__instance).transform.rotation; Vector3 val = rotation * Vector3.forward; ((Vector3)(ref val)).Normalize(); Transform transform = ((Component)__instance).transform; transform.position += val * ConfigVariables.noClipSpeed; } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.noClipLeftButton]).isPressed) { Quaternion rotation2 = ((Component)__instance).transform.rotation; Quaternion val2 = Quaternion.AngleAxis(-90f, Vector3.up); Vector3 val3 = val2 * rotation2 * Vector3.forward; ((Vector3)(ref val3)).Normalize(); Transform transform2 = ((Component)__instance).transform; transform2.position += val3 * ConfigVariables.noClipSpeed; } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.noClipRightButton]).isPressed) { Quaternion rotation3 = ((Component)__instance).transform.rotation; Quaternion val4 = Quaternion.AngleAxis(90f, Vector3.up); Vector3 val5 = val4 * rotation3 * Vector3.forward; ((Vector3)(ref val5)).Normalize(); Transform transform3 = ((Component)__instance).transform; transform3.position += val5 * ConfigVariables.noClipSpeed; } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.noClipBackwardButton]).isPressed) { Quaternion rotation4 = ((Component)__instance).transform.rotation; Vector3 val6 = rotation4 * Vector3.back; ((Vector3)(ref val6)).Normalize(); Transform transform4 = ((Component)__instance).transform; transform4.position += val6 * ConfigVariables.noClipSpeed; } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.noClipUpButton]).isPressed) { Vector3 up = Vector3.up; Transform transform5 = ((Component)__instance).transform; transform5.position += up * ConfigVariables.noClipSpeed; } } catch { } try { if (((ButtonControl)Keyboard.current[ConfigVariables.noClipDownButton]).isPressed) { Vector3 val7 = -Vector3.up; Transform transform6 = ((Component)__instance).transform; transform6.position += val7 * ConfigVariables.noClipSpeed; } } catch { } } private static void reviveDeadPlayer(PlayerControllerB __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) //IL_010f: Unknown result type (might be due to invalid IL or missing references) try { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; ulong playerClientId = StartOfRound.Instance.localPlayerController.playerClientId; Vector3 teleportLocation = getTeleportLocation(allPlayerScripts[playerClientId]); mls.LogMessage((object)$"Reviving player {playerClientId}"); allPlayerScripts[playerClientId].velocityLastFrame = new Vector3(0f, 0f, 0f); allPlayerScripts[playerClientId].isSprinting = false; allPlayerScripts[playerClientId].ResetPlayerBloodObjects(allPlayerScripts[playerClientId].isPlayerDead); allPlayerScripts[playerClientId].isClimbingLadder = false; allPlayerScripts[playerClientId].ResetZAndXRotation(); ((Collider)allPlayerScripts[playerClientId].thisController).enabled = true; allPlayerScripts[playerClientId].health = 100; allPlayerScripts[playerClientId].disableLookInput = false; if (allPlayerScripts[playerClientId].isPlayerDead) { allPlayerScripts[playerClientId].isPlayerDead = false; allPlayerScripts[playerClientId].isPlayerControlled = true; allPlayerScripts[playerClientId].isInElevator = true; allPlayerScripts[playerClientId].isInHangarShipRoom = true; allPlayerScripts[playerClientId].isInsideFactory = false; StartOfRound.Instance.SetPlayerObjectExtrapolate(false); ((Component)allPlayerScripts[playerClientId]).transform.position = teleportLocation; allPlayerScripts[playerClientId].setPositionOfDeadPlayer = false; allPlayerScripts[playerClientId].DisablePlayerModel(StartOfRound.Instance.allPlayerObjects[playerClientId], true, true); ((Behaviour)allPlayerScripts[playerClientId].helmetLight).enabled = false; allPlayerScripts[playerClientId].Crouch(false); allPlayerScripts[playerClientId].criticallyInjured = false; if ((Object)(object)allPlayerScripts[playerClientId].playerBodyAnimator != (Object)null) { allPlayerScripts[playerClientId].playerBodyAnimator.SetBool("Limp", false); } allPlayerScripts[playerClientId].bleedingHeavily = false; allPlayerScripts[playerClientId].activatingItem = false; allPlayerScripts[playerClientId].twoHanded = false; allPlayerScripts[playerClientId].inSpecialInteractAnimation = false; allPlayerScripts[playerClientId].disableSyncInAnimation = false; allPlayerScripts[playerClientId].inAnimationWithEnemy = null; allPlayerScripts[playerClientId].holdingWalkieTalkie = false; allPlayerScripts[playerClientId].speakingToWalkieTalkie = false; allPlayerScripts[playerClientId].isSinking = false; allPlayerScripts[playerClientId].isUnderwater = false; allPlayerScripts[playerClientId].sinkingValue = 0f; allPlayerScripts[playerClientId].statusEffectAudio.Stop(); allPlayerScripts[playerClientId].DisableJetpackControlsLocally(); allPlayerScripts[playerClientId].health = 100; if (((NetworkBehaviour)allPlayerScripts[playerClientId]).IsOwner) { HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false); allPlayerScripts[playerClientId].hasBegunSpectating = false; HUDManager.Instance.RemoveSpectateUI(); HUDManager.Instance.gameOverAnimator.SetTrigger("revive"); allPlayerScripts[playerClientId].hinderedMultiplier = 1f; allPlayerScripts[playerClientId].isMovementHindered = 0; allPlayerScripts[playerClientId].sourcesCausingSinking = 0; allPlayerScripts[playerClientId].reverbPreset = StartOfRound.Instance.shipReverb; } } SoundManager.Instance.earsRingingTimer = 0f; allPlayerScripts[playerClientId].voiceMuffledByEnemy = false; SoundManager.Instance.playerVoicePitchTargets[playerClientId] = 1f; SoundManager.Instance.SetPlayerPitch(1f, (int)playerClientId); PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; localPlayerController.bleedingHeavily = false; localPlayerController.criticallyInjured = false; localPlayerController.playerBodyAnimator.SetBool("Limp", false); localPlayerController.health = 100; HUDManager.Instance.UpdateHealthUI(100, false); localPlayerController.spectatedPlayerScript = null; ((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false; StartOfRound.Instance.SetSpectateCameraToGameOverMode(false, localPlayerController); isGhostMode = true; ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = ""; ((TMP_Text)HUDManager.Instance.holdButtonToEndGameEarlyText).text = ""; ((Component)HUDManager.Instance.holdButtonToEndGameEarlyMeter).gameObject.SetActive(false); ((TMP_Text)HUDManager.Instance.holdButtonToEndGameEarlyVotesText).text = ""; showAliveUI(localPlayerController, show: false); FieldInfo field = typeof(PlayerControllerB).GetField("sprintMultiplier", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(localPlayerController, 1f); } HUDManagerPatch.updateBoxesSpectateUI(HUDManager.Instance); if (!ConfigVariables.enemiesDetectYou) { EnemyAIPatch.makeEnemiesDropFocus(__instance); } } catch (Exception ex) { mls.LogError((object)ex); } } public static void rekillPlayerLocally(PlayerControllerB __instance) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) mls.LogMessage((object)"try to rekill player locally"); __instance.DropAllHeldItemsServerRpc(); __instance.DisableJetpackControlsLocally(); __instance.isPlayerDead = true; __instance.isPlayerControlled = false; ((Renderer)__instance.thisPlayerModelArms).enabled = false; __instance.localVisor.position = __instance.playersManager.notSpawnedPosition.position; __instance.DisablePlayerModel(((Component)__instance).gameObject, false, false); __instance.isInsideFactory = false; __instance.IsInspectingItem = false; __instance.inTerminalMenu = false; __instance.twoHanded = false; __instance.carryWeight = 1f; __instance.fallValue = 0f; __instance.fallValueUncapped = 0f; __instance.takingFallDamage = false; __instance.isSinking = false; __instance.isUnderwater = false; StartOfRound.Instance.drowningTimer = 1f; HUDManager.Instance.setUnderwaterFilter = false; __instance.sourcesCausingSinking = 0; __instance.sinkingValue = 0f; __instance.hinderedMultiplier = 1f; __instance.isMovementHindered = 0; __instance.inAnimationWithEnemy = null; HUDManager.Instance.SetNearDepthOfFieldEnabled(true); HUDManager.Instance.HUDAnimator.SetBool("biohazardDamage", false); StartOfRound.Instance.SwitchCamera(StartOfRound.Instance.spectateCamera); } public static void setToSpectatemode(PlayerControllerB __instance) { __instance = StartOfRound.Instance.localPlayerController; showAliveUI(__instance, show: false); rekillPlayerLocally(__instance); __instance.hasBegunSpectating = true; HUDManager.Instance.gameOverAnimator.SetTrigger("gameOver"); isGhostMode = false; ChangeAudioListenerToObject(__instance, ((Component)__instance.playersManager.spectateCamera).gameObject); if (isBrightModeOn) { togglingBrightModeCoroutine = ((MonoBehaviour)__instance).StartCoroutine(toggleBrightMode(__instance)); } } private static IEnumerator specialTeleportPlayer(PlayerControllerB __instance, Vector3 newPos, string message) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (tpCoroutine != null) { ((MonoBehaviour)__instance).StopCoroutine(tpCoroutine); } ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = message; GameNetworkManager.Instance.localPlayerController.TeleportPlayer(newPos, false, 0f, false, true); yield return (object)new WaitForSeconds(1.5f); ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = ""; isTeleporting = false; } private static IEnumerator toggleCollisions(PlayerControllerB __instance) { if (togglingCollisionsCoroutine != null) { ((MonoBehaviour)__instance).StopCoroutine(togglingCollisionsCoroutine); } __instance = StartOfRound.Instance.localPlayerController; yield return (object)new WaitForSeconds(0.1f); if (collisionsOn) { mls.LogMessage((object)"collisions are off"); HUDManager.Instance.DisplayTip("NoClip", "On", false, false, "LC_Tip1"); collisionsOn = false; __instance.playerCollider.enabled = false; } else { mls.LogMessage((object)"collisions are on"); HUDManager.Instance.DisplayTip("NoClip", "Off", false, false, "LC_Tip1"); collisionsOn = true; __instance.playerCollider.enabled = true; } isTogglingCollisions = false; } private static IEnumerator toggleBrightMode(PlayerControllerB __instance) { if (togglingBrightModeCoroutine != null) { ((MonoBehaviour)__instance).StopCoroutine(togglingBrightModeCoroutine); } __instance = StartOfRound.Instance.localPlayerController; yield return (object)new WaitForSeconds(0.1f); if (isBrightModeOn) { mls.LogMessage((object)"turn off bright mode"); isBrightModeOn = false; setNightVisionMode(__instance, 0); __instance.isInsideFactory = false; ((Component)__instance.nightVision).gameObject.SetActive(false); } else { mls.LogMessage((object)"turn on bright mode"); isBrightModeOn = true; setNightVisionMode(__instance, 1); __instance.isInsideFactory = true; ((Component)__instance.nightVision).gameObject.SetActive(true); } isTogglingBrightMode = false; } } } namespace OPJosMod.GhostMode.Enemy.Patches { [HarmonyPatch(typeof(CrawlerAI))] internal class CrawlerAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("Update")] [HarmonyPrefix] private static void updatePatch(CrawlerAI __instance) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && EnemyAIPatch.getClosestPlayerIncludingGhost((EnemyAI)(object)__instance).playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { ((EnemyAI)__instance).currentBehaviourStateIndex = 0; } } } [HarmonyPatch(typeof(FlowermanAI))] internal class FlowermanAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("AvoidClosestPlayer")] [HarmonyPrefix] private static bool avoidClosestPlayerPatch(FlowermanAI __instance) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && EnemyAIPatch.getClosestPlayerIncludingGhost((EnemyAI)(object)__instance).playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { return false; } return true; } [HarmonyPatch("AddToAngerMeter")] [HarmonyPrefix] private static bool addToAngerMeterPatch(FlowermanAI __instance) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou) { bool result = false; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isInsideFactory && val.playerClientId != StartOfRound.Instance.localPlayerController.playerClientId) { result = true; break; } } return result; } return true; } [HarmonyPatch("OnCollideWithPlayer")] [HarmonyPrefix] private static bool onCollideWithPlayerPatch(ref Collider other) { if (PlayerControllerBPatch.isGhostMode) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (StartOfRound.Instance.localPlayerController.playerClientId == component.playerClientId) { return false; } } return true; } } [HarmonyPatch(typeof(ButlerEnemyAI))] internal class ButlerEnemyAIPatch { private static ManualLogSource mls; private static bool dontCallForgetPlayers; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("OnCollideWithPlayer")] [HarmonyPrefix] private static bool onCollideWithPlayerPatch(ref Collider other) { if (PlayerControllerBPatch.isGhostMode) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (StartOfRound.Instance.localPlayerController.playerClientId == component.playerClientId) { return false; } } return true; } [HarmonyPatch("CheckLOS")] [HarmonyPrefix] private static bool patchCheckLOS(ButlerEnemyAI __instance) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou) { bool[] fieldValue = ReflectionUtils.GetFieldValue<bool[]>(__instance, "seenPlayers"); Vector3[] fieldValue2 = ReflectionUtils.GetFieldValue<Vector3[]>(__instance, "lastSeenPlayerPositions"); float[] fieldValue3 = ReflectionUtils.GetFieldValue<float[]>(__instance, "timeOfLastSeenPlayers"); PlayerControllerB fieldValue4 = ReflectionUtils.GetFieldValue<PlayerControllerB>(__instance, "watchingPlayer"); int num = 0; float num2 = 10000f; int num3 = -1; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (StartOfRound.Instance.allPlayerScripts[i].isPlayerDead || !StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled) { fieldValue[i] = false; continue; } if (((EnemyAI)__instance).CheckLineOfSightForPosition(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, 110f, 60, 2f, (Transform)null)) { num++; fieldValue2[i] = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position; fieldValue[i] = true; fieldValue3[i] = Time.realtimeSinceStartup; } else if (fieldValue[i]) { num++; } if (fieldValue[i]) { float num4 = Vector3.Distance(((EnemyAI)__instance).eye.position, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position); if (num4 < num2) { num2 = num4; num3 = i; } } } if (((EnemyAI)__instance).currentBehaviourStateIndex == 2) { return true; } if (num3 != -1) { fieldValue4 = StartOfRound.Instance.allPlayerScripts[num3]; if (((EnemyAI)__instance).currentBehaviourStateIndex != 2 && (Object)(object)fieldValue4 != (Object)null && fieldValue4.playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { dontCallForgetPlayers = true; return false; } } } return true; } [HarmonyPatch("ForgetSeenPlayers")] [HarmonyPrefix] private static bool patchForgetSeenPlayers(ButlerEnemyAI __instance) { if (dontCallForgetPlayers) { return false; } return true; } [HarmonyPatch("Update")] [HarmonyPostfix] private static void patchUpdate(ButlerEnemyAI __instance) { dontCallForgetPlayers = false; } } [HarmonyPatch(typeof(SpikeRoofTrap))] internal class SpikeRoofTrapPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("OnTriggerStay")] [HarmonyPrefix] private static bool patchOnTriggerStay(SpikeRoofTrap __instance, ref Collider other) { if (PlayerControllerBPatch.isGhostMode) { if (!__instance.trapActive || !__instance.slammingDown || Time.realtimeSinceStartup - __instance.timeSinceMovingUp < 0.75f) { return true; } PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController && !component.isPlayerDead) { return false; } } return true; } } [HarmonyPatch(typeof(RadMechAI))] internal class RadMechAIPatch { private static ManualLogSource mls; private static int visibleThreatsMask = 524296; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("OnCollideWithPlayer")] [HarmonyPrefix] private static bool onCollideWithPlayerPatch(ref Collider other) { if (PlayerControllerBPatch.isGhostMode) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (StartOfRound.Instance.localPlayerController.playerClientId == component.playerClientId) { return false; } } return true; } [HarmonyPatch("CheckSightForThreat")] [HarmonyPrefix] private static bool patchCheckSightForThreat(RadMechAI __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_017f: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01fa: Unknown result type (might be due to invalid IL or missing references) if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou) { Collider fieldValue = ReflectionUtils.GetFieldValue<Collider>(__instance, "targetedThreatCollider"); int num = Physics.OverlapSphereNonAlloc(((EnemyAI)__instance).eye.position + ((EnemyAI)__instance).eye.forward * 58f + -((EnemyAI)__instance).eye.up * 10f, 60f, RoundManager.Instance.tempColliderResults, visibleThreatsMask, (QueryTriggerInteraction)2); Collider val = null; RaycastHit val2 = default(RaycastHit); IVisibleThreat val3 = default(IVisibleThreat); for (int i = 0; i < num; i++) { if ((Object)(object)RoundManager.Instance.tempColliderResults[i] == (Object)(object)__instance.ownCollider) { continue; } if ((Object)(object)RoundManager.Instance.tempColliderResults[i] == (Object)(object)fieldValue && ((EnemyAI)__instance).currentBehaviourStateIndex == 1) { val = RoundManager.Instance.tempColliderResults[i]; continue; } float num2 = Vector3.Distance(((EnemyAI)__instance).eye.position, ((Component)RoundManager.Instance.tempColliderResults[i]).transform.position); float num3 = Vector3.Angle(((Component)RoundManager.Instance.tempColliderResults[i]).transform.position - ((EnemyAI)__instance).eye.position, ((EnemyAI)__instance).eye.forward); if (num2 > 2f && num3 > __instance.fov) { continue; } if (Physics.Linecast(((Component)__instance).transform.position + Vector3.up * 0.7f, ((Component)RoundManager.Instance.tempColliderResults[i]).transform.position + Vector3.up * 0.5f, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { if (((EnemyAI)__instance).debugEnemyAI) { Debug.DrawRay(((RaycastHit)(ref val2)).point, Vector3.up * 0.5f, Color.magenta, ((EnemyAI)__instance).AIIntervalTime); } continue; } EnemyAI component = ((Component)((Component)RoundManager.Instance.tempColliderResults[i]).transform).GetComponent<EnemyAI>(); if (((Object)(object)component != (Object)null && ((object)component).GetType() == typeof(RadMechAI)) || !((Component)((Component)RoundManager.Instance.tempColliderResults[i]).transform).TryGetComponent<IVisibleThreat>(ref val3)) { continue; } float visibility = val3.GetVisibility(); if (!(visibility < 0.2f) && (!(visibility <= 0.58f) || !(num2 > 30f)) && val3 is PlayerControllerB) { PlayerControllerB val4 = (PlayerControllerB)(object)((val3 is PlayerControllerB) ? val3 : null); if ((Object)(object)val4 != (Object)null && val4.playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { return false; } } } } return true; } } [HarmonyPatch(typeof(Landmine))] internal class LandminePatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("OnTriggerEnter")] [HarmonyPrefix] private static bool onTriggerEnterPatch(ref Collider other) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && ((Component)other).CompareTag("Player")) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (!((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && (Object)(object)component != (Object)null && !component.isPlayerDead) { mls.LogMessage((object)"ghost stepped on mine, do nothing"); return false; } } return true; } [HarmonyPatch("OnTriggerExit")] [HarmonyPrefix] private static bool onTriggerExitPatch(ref Collider other) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && ((Component)other).CompareTag("Player")) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null && !component.isPlayerDead && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { mls.LogMessage((object)"ghost stepped off mine, do nothing"); return false; } } return true; } } [HarmonyPatch(typeof(MaskedPlayerEnemy))] internal class MaskedPlayerEnemyPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } } [HarmonyPatch(typeof(JesterAI))] internal class JesterAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("Update")] [HarmonyPrefix] private static void updatePatch(JesterAI __instance) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && (((EnemyAI)__instance).currentBehaviourStateIndex == 2 || ((EnemyAI)__instance).currentBehaviourStateIndex == 1) && EnemyAIPatch.ghostOnlyPlayerInFacility() && EnemyAIPatch.getClosestPlayerIncludingGhost((EnemyAI)(object)__instance).playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { mls.LogMessage((object)"swaping jester back to state 0"); ((EnemyAI)__instance).SwitchToBehaviourState(1); } } } [HarmonyPatch(typeof(Turret))] internal class TurretPatch { private static ManualLogSource mls; private static RaycastHit hit; private static Ray shootRay; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch(typeof(Turret), "CheckForPlayersInLineOfSight")] [HarmonyPrefix] private static bool checkForPlayersInLineOfSightPatch(Turret __instance, ref float radius, ref bool angleRangeCheck) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0054: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Invalid comparison between Unknown and I4 //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Invalid comparison between Unknown and I4 //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou) { bool fieldValue = ReflectionUtils.GetFieldValue<bool>(__instance, "enteringBerserkMode"); Vector3 val = __instance.aimPoint.forward; val = Quaternion.Euler(0f, (float)(int)(0f - __instance.rotationRange) / radius, 0f) * val; float num = __instance.rotationRange / radius * 2f; for (int i = 0; i <= 6; i++) { shootRay = new Ray(__instance.centerPoint.position, val); if (Physics.Raycast(shootRay, ref hit, 30f, 1051400, (QueryTriggerInteraction)1)) { if (((Component)((RaycastHit)(ref hit)).transform).CompareTag("Player")) { PlayerControllerB component = ((Component)((RaycastHit)(ref hit)).transform).GetComponent<PlayerControllerB>(); if (component.playerClientId == StartOfRound.Instance.localPlayerController.playerClientId) { return false; } if (!((Object)(object)component == (Object)null)) { if (angleRangeCheck && Vector3.Angle(((Component)component).transform.position + Vector3.up * 1.75f - __instance.centerPoint.position, __instance.forwardFacingPos.forward) > __instance.rotationRange) { return true; } return Object.op_Implicit((Object)(object)component); } continue; } if (((int)__instance.turretMode == 2 || ((int)__instance.turretMode == 3 && !fieldValue)) && ((Component)((RaycastHit)(ref hit)).transform).tag.StartsWith("PlayerRagdoll")) { Rigidbody component2 = ((Component)((RaycastHit)(ref hit)).transform).GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.AddForce(((Vector3)(ref val)).normalized * 42f, (ForceMode)1); } } } val = Quaternion.Euler(0f, num / 6f, 0f) * val; } } return true; } } [HarmonyPatch(typeof(NutcrackerEnemyAI))] internal class NutcrackerEnemyAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("SwitchTargetToPlayer")] [HarmonyPrefix] private static bool switchTargetToPlayerPatch(NutcrackerEnemyAI __instance, ref int playerId) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && (int)StartOfRound.Instance.localPlayerController.playerClientId == playerId) { mls.LogMessage((object)"kept nutcracker from switching target to current player"); __instance.StopInspection(); ((EnemyAI)__instance).currentBehaviourStateIndex = 0; return false; } return true; } } [HarmonyPatch(typeof(SandSpiderAI))] internal class SandSpiderAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("TriggerChaseWithPlayer")] [HarmonyPrefix] private static bool triggerChaseWithPlayerPatch(ref PlayerControllerB playerScript) { if (PlayerControllerBPatch.isGhostMode && StartOfRound.Instance.localPlayerController.playerClientId == playerScript.playerClientId && !ConfigVariables.enemiesDetectYou) { mls.LogMessage((object)"spider supposed to trigger chase with player"); return false; } return true; } } [HarmonyPatch(typeof(ForestGiantAI))] internal class ForestGiantAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("OnCollideWithPlayer")] [HarmonyPrefix] private static bool onCollideWithPlayerPatch(ref Collider other) { if (PlayerControllerBPatch.isGhostMode) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (StartOfRound.Instance.localPlayerController.playerClientId == component.playerClientId) { return false; } } return true; } } [HarmonyPatch(typeof(MouthDogAI))] internal class MouthDogAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("DetectNoise")] [HarmonyPrefix] private static bool detectNoisePatch(ref Vector3 noisePosition) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; ulong playerClientId = StartOfRound.Instance.localPlayerController.playerClientId; PlayerControllerB val = allPlayerScripts[playerClientId]; if (GeneralUtils.twoPointsAreClose(noisePosition, ((Component)val).transform.position, 5f)) { mls.LogMessage((object)"noise was close to you, so don't detect this noise"); return false; } } return true; } } [HarmonyPatch(typeof(CentipedeAI))] internal class CentipedeAIPatch { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("Update")] [HarmonyPrefix] private static bool updatePrePatch(CentipedeAI __instance) { if (PlayerControllerBPatch.isGhostMode && !ConfigVariables.enemiesDetectYou && EnemyAIPatch.getClosestPlayerIncludingGhost((EnemyAI)(object)__instance).playerClientId == StartOfRound.Instance.localPlayerController.playerClientId && ((EnemyAI)__instance).currentBehaviourStateIndex == 1) { return false; } return true; } } } namespace OPJosMod.GhostMode.CustomRpc { public static class CompleteRecievedTasks { private static ManualLogSource mls; public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } public static void ModActivated(string modName) { if (mls.SourceName == modName) { mls.LogMessage((object)"Mod Activated"); GlobalVariables.ModActivated = true; } } public static void TurnOffGhostMode(string clientID) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown if (!int.TryParse(clientID, out var result) || (int)StartOfRound.Instance.localPlayerController.playerClientId != result || PlayerControllerBPatch.allowKill) { return; } mls.LogMessage((object)"Revived on Other Client, turning off ghost mode."); PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; localPlayerController.TeleportPlayer(((Component)localPlayerController.deadBody).transform.position, false, 0f, false, true); int livingPlayers = RoundManager.Instance.playersManager.allPlayerScripts.Where((PlayerControllerB x) => !x.playerUsername.Contains("Player") && !x.isPlayerDead).ToList().Count(); StartOfRound.Instance.livingPlayers = livingPlayers; RagdollGrabbableObject val = null; float num = float.MaxValue; RagdollGrabbableObject[] array = Object.FindObjectsOfType<RagdollGrabbableObject>(); RagdollGrabbableObject[] array2 = array; foreach (RagdollGrabbableObject val2 in array2) { float num2 = Vector3.Distance(((Component)val2).transform.position, ((Component)localPlayerController).transform.position); if (num2 < num) { val = val2; num = num2; } } if ((Object)(object)val != (Object)null) { if (!((GrabbableObject)val).isHeld) { if (((NetworkBehaviour)StartOfRound.Instance).IsServer) { if (((NetworkBehaviour)val).NetworkObject.IsSpawned) { ((NetworkBehaviour)val).NetworkObject.Despawn(true); } else { Object.Destroy((Object)((Component)val).gameObject); } } } else if (((GrabbableObject)val).isHeld && (Object)((GrabbableObject)val).playerHeldBy != (Object)null) { ((GrabbableObject)val).playerHeldBy.DropAllHeldItems(true, false); } if ((Object)(object)val.ragdoll != (Object)n