Please disclose if your mod was created primarily 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 ImprovedLethalThings v1.0.4
BepInEx/plugins/ImprovedLethalThings.dll
Decompiled 3 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using ImprovedLethalThings.NetcodePatcher; using ImprovedLethalThings.Networking; using ImprovedLethalThings.Patches; using ImprovedLethalThings.Util; using ImprovedLethalThings.patches; using LethalCompanyInputUtils.Api; using LethalCompanyInputUtils.BindingPathEnums; using LethalThings; using LethalThings.MonoBehaviours; using Microsoft.CodeAnalysis; using On; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ImprovedLethalThings")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Mod for Lethal Company")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3")] [assembly: AssemblyProduct("ImprovedLethalThings")] [assembly: AssemblyTitle("ImprovedLethalThings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ImprovedLethalThings { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("HQ_Team.ImprovedLethalThings", "ImprovedLethalThings", "1.0.3")] public class ImprovedLethalThings : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Action<Harmony> <0>__TryApply; public static hook_Awake <1>__StartOfRound_Awake; } public static ImprovedLethalThings instance; public ConfigFile config; public static ManualLogSource Log; public void Awake() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Expected O, but got Unknown Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("HQ_Team.ImprovedLethalThings"); Action<Harmony>[] array3 = new Action<Harmony>[1] { RocketLauncherReflection.TryApply }; Action<Harmony>[] array4 = array3; foreach (Action<Harmony> action in array4) { try { action(val); } catch { } } val.PatchAll(typeof(HackingToolPatch)); val.PatchAll(typeof(HandheldRadarPatch)); val.PatchAll(typeof(PingerPatch)); val.PatchAll(typeof(RocketLauncherReloadInput)); val.PatchAll(typeof(RocketLauncherReloadTip)); val.PatchAll(typeof(HackingToolTipUtil)); val.PatchAll(typeof(MissilePatch)); val.PatchAll(typeof(FlareControllerPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalThings Improved!"); ConfigEntry<bool> val2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Hacking Tool", "EnableEnhancedHackGame", true, "Enable the custom hacking minigame from EnhancedLethalThings."); HackingToolPatch.ToggleEnhancedHackGame = val2.Value; ConfigEntry<float> val3 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "ConnectionTime", HackingToolPatch.ConnectionTime, "How long it will take to connect to a target, in seconds."); HackingToolPatch.ConnectionTime = val3.Value; ConfigEntry<float> val4 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "Battery", HackingToolPatch.HackBattery, "Battery size."); HackingToolPatch.HackBattery = val4.Value; ConfigEntry<int> val5 = ((BaseUnityPlugin)this).Config.Bind<int>("Hacking Tool", "AnswerNumber", HackingToolPatch.HackCount, "The length of hacking tool answer. Maximum of 9."); HackingToolPatch.HackCount = Math.Max(1, val5.Value); ConfigEntry<float> val6 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "HackDistance", HackingToolPatch.MaxHackDistance, "Hacking distance range"); HackingToolPatch.MaxHackDistance = val6.Value; ConfigEntry<float> val7 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "HackSpreadDistance", HackingToolPatch.HackSpreadDistance, "Distance in which the hack can be spread to other hackable objects."); HackingToolPatch.HackSpreadDistance = val7.Value; ConfigEntry<float> val8 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "DoorCooldown", HackingToolPatch.DoorCooldownTime, "Cooldown duration for hacked doors before they can be hacked again, in seconds."); HackingToolPatch.DoorCooldownTime = val8.Value; ConfigEntry<float> val9 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "TurretDisableTime", HackingToolPatch.TurretDisableTime, "How long turrets stay disabled when hacked, in seconds."); HackingToolPatch.TurretDisableTime = val9.Value; ConfigEntry<float> val10 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "SpikeDisableTime", 10f, "How long spikes stay disabled when hacked, in seconds."); HackingToolPatch.SpikeDisableTime = val10.Value; ConfigEntry<bool> val11 = ((BaseUnityPlugin)this).Config.Bind<bool>("Hacking Tool", "LandmineExplodeOnHack", HackingToolPatch.LandmineExplodeOnHack, "If true, hacked landmines will explode; if false, they will be disabled temporarily instead."); HackingToolPatch.LandmineExplodeOnHack = val11.Value; ConfigEntry<float> val12 = ((BaseUnityPlugin)this).Config.Bind<float>("Hacking Tool", "LandmineDisableTime", HackingToolPatch.LandmineDisableTime, "How long hacked landmines stay disabled when not exploded, in seconds."); HackingToolPatch.LandmineDisableTime = val12.Value; ConfigEntry<float> val13 = ((BaseUnityPlugin)this).Config.Bind<float>("Handheld Radar", "Battery", HandheldRadarPatch.RadarCapacity, "Battery size."); HandheldRadarPatch.RadarCapacity = val13.Value; ConfigEntry<int> val14 = ((BaseUnityPlugin)this).Config.Bind<int>("Pinger", "MaxUses", PingerPatch.MaxUses, "How many pings before the tool is exhausted."); PingerPatch.MaxUses = val14.Value; ConfigEntry<float> val15 = ((BaseUnityPlugin)this).Config.Bind<float>("Pinger", "PingDuration", PingerPatch.PingDuration, "How long the ping marker lasts before fading."); PingerPatch.PingDuration = val15.Value; ConfigEntry<float> val16 = ((BaseUnityPlugin)this).Config.Bind<float>("Pinger", "PingRange", PingerPatch.PingRange, "Maximum detection range of the Pinger scan node."); PingerPatch.PingRange = val16.Value; _ = HackToolInputBindings._instance; HackToolInputBindings._instance.PowerToggle.performed += OnPowerToggle; HackToolInputBindings._instance.ModeToggle.performed += OnModeToggle; object obj2 = <>O.<1>__StartOfRound_Awake; if (obj2 == null) { hook_Awake val17 = StartOfRound_Awake; <>O.<1>__StartOfRound_Awake = val17; obj2 = (object)val17; } StartOfRound.Awake += (hook_Awake)obj2; } private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self) { NetworkManager singleton = NetworkManager.Singleton; object obj; if (singleton == null) { obj = null; } else { NetworkConfig networkConfig = singleton.NetworkConfig; if (networkConfig == null) { obj = null; } else { NetworkPrefabs prefabs = networkConfig.Prefabs; obj = ((prefabs != null) ? prefabs.Prefabs : null); } } IReadOnlyList<NetworkPrefab> readOnlyList = (IReadOnlyList<NetworkPrefab>)obj; if (readOnlyList != null) { foreach (NetworkPrefab item in readOnlyList) { if (!((Object)(object)item?.Prefab == (Object)null) && (Object)(object)item.Prefab.GetComponent<RocketLauncher>() != (Object)null && (Object)(object)item.Prefab.GetComponent<RocketLauncherReload>() == (Object)null) { item.Prefab.AddComponent<RocketLauncherReload>(); } } } orig.Invoke(self); } private void OnPowerToggle(CallbackContext ctx) { GrabbableObject obj = GameNetworkManager.Instance?.localPlayerController?.currentlyHeldObjectServer; HackingTool val = (HackingTool)(object)((obj is HackingTool) ? obj : null); if ((Object)(object)val != (Object)null) { HackingToolPatch.TogglePower(val); } } private void OnModeToggle(CallbackContext ctx) { GrabbableObject obj = GameNetworkManager.Instance?.localPlayerController?.currentlyHeldObjectServer; HackingTool val = (HackingTool)(object)((obj is HackingTool) ? obj : null); if ((Object)(object)val != (Object)null) { HackingToolPatch.ToggleHackMode(val); } } } public static class PluginInfo { public const string PLUGIN_GUID = "HQ_Team.ImprovedLethalThings"; public const string PLUGIN_NAME = "ImprovedLethalThings"; public const string PLUGIN_VERSION = "1.0.3"; } public static class MyPluginInfo { public const string PLUGIN_GUID = "ImprovedLethalThings"; public const string PLUGIN_NAME = "ImprovedLethalThings"; public const string PLUGIN_VERSION = "1.0.3"; } } namespace ImprovedLethalThings.Util { [HarmonyPatch] public static class HackingToolTipUtil { public static void UpdateHackingToolTips() { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null) && instance.controlTipLines != null) { for (int i = 0; i < instance.controlTipLines.Length; i++) { ((TMP_Text)instance.controlTipLines[i]).text = ""; } string text = ((Keyboard.current != null) ? ((InputControl)Keyboard.current.gKey).displayName : "G"); string bindingDisplayString = InputActionRebindingExtensions.GetBindingDisplayString(HackToolInputBindings._instance.PowerToggle, (DisplayStringOptions)0, (string)null); string bindingDisplayString2 = InputActionRebindingExtensions.GetBindingDisplayString(HackToolInputBindings._instance.ModeToggle, (DisplayStringOptions)0, (string)null); string[] array = new string[4] { "Drop Hacking Tool : [" + text + "]", "Turn on : [" + bindingDisplayString + "]", "Switch modes : [" + bindingDisplayString2 + "]", "Select target : [LMB]" }; int num = Mathf.Min(array.Length, instance.controlTipLines.Length); for (int j = 0; j < num; j++) { ((TMP_Text)instance.controlTipLines[j]).text = array[j]; } } } public static void ClearHackingToolTips() { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null) && instance.controlTipLines != null) { for (int i = 0; i < instance.controlTipLines.Length; i++) { ((TMP_Text)instance.controlTipLines[i]).text = ""; } } } [HarmonyPatch(typeof(HackingTool), "EquipItem")] [HarmonyPostfix] private static void EquipItem_Postfix(HackingTool __instance) { if (!((GrabbableObject)__instance).isHeld) { return; } if (!((Object)(object)__instance == (Object)null)) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!((Object)(object)localPlayerController == (Object)null) && !((Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)(object)__instance) && ((NetworkBehaviour)__instance).IsOwner) { UpdateHackingToolTips(); } } } [HarmonyPatch(typeof(GrabbableObject), "PocketItem")] [HarmonyPostfix] private static void PocketItem_Postfix(GrabbableObject __instance) { HackingTool val = (HackingTool)(object)((__instance is HackingTool) ? __instance : null); if ((Object)(object)val == (Object)null) { return; } if (!((GrabbableObject)val).isHeld) { ClearHackingToolTips(); return; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!((Object)(object)localPlayerController == (Object)null)) { if ((Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)(object)val) { ClearHackingToolTips(); } else if (((NetworkBehaviour)val).IsOwner) { UpdateHackingToolTips(); } } } } public class HackToolInputBindings : LcInputActions { public static readonly HackToolInputBindings _instance = new HackToolInputBindings(); public InputAction PowerToggle => ((LcInputActions)this).Asset["hacking_tool_power_toggle"]; public InputAction ModeToggle => ((LcInputActions)this).Asset["hacking_tool_mode_toggle"]; public override void CreateInputActions(in InputActionMapBuilder builder) { builder.NewActionBinding().WithActionId("hacking_tool_power_toggle").WithActionType((InputActionType)1) .WithKeyboardControl((KeyboardControl)37) .WithBindingName("Hacking Tool Power Toggle") .Finish(); builder.NewActionBinding().WithActionId("hacking_tool_mode_toggle").WithActionType((InputActionType)1) .WithKeyboardControl((KeyboardControl)25) .WithBindingName("Hacking Tool Mode Toggle") .Finish(); } } internal static class RocketLauncherReflection { private static readonly FieldInfo currentAmmoField = typeof(RocketLauncher).GetField("currentAmmo", BindingFlags.Instance | BindingFlags.NonPublic); public static void TryApply(Harmony h) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(RocketLauncher), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(RocketLauncherReflection).GetMethod("ValidateAmmoField")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void ValidateAmmoField(RocketLauncher __instance) { if (!(currentAmmoField == null)) { currentAmmoField.GetValue(__instance); } } } } namespace ImprovedLethalThings.Patches { public class HackingToolPatch { [CompilerGenerated] private sealed class <ReEnableLandmineAfterDelay>d__32 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Landmine lm; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReEnableLandmineAfterDelay>d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)lm == (Object)null || lm.hasExploded) { return false; } lm.ToggleMine(true); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ReEnableSpikesAfterDelay>d__31 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SpikeRoofTrap spikes; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReEnableSpikesAfterDelay>d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)spikes == (Object)null) { return false; } if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { spikes.ToggleSpikesEnabled(true); } else { spikes.ToggleSpikesServerRpc(true); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ReEnableTurretAfterDelay>d__30 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Turret turret; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReEnableTurretAfterDelay>d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)turret == (Object)null) { return false; } if (((NetworkBehaviour)turret).IsHost) { turret.ToggleTurretClientRpc(true); } else { turret.ToggleTurretServerRpc(true); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ResetCooldownAfterDelay>d__29 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TerminalAccessibleObject obj; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetCooldownAfterDelay>d__29(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)obj != (Object)null) { taoInCooldownField.SetValue(obj, false); taoCooldownTimerField.SetValue(obj, 0f); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static int HackCount = 8; public static float MaxHackDistance = 15f; public static float HackSpreadDistance = 20f; public static float ConnectionTime = 8f; public static float HackBattery = 200f; public static float TurretDisableTime = 15f; public static float DoorCooldownTime = 5f; public static float SpikeDisableTime = 10f; public static bool ToggleEnhancedHackGame = true; public static bool LandmineExplodeOnHack = true; public static float LandmineDisableTime = 10f; private static readonly FieldRef<TerminalAccessibleObject, bool> inCooldownRef = AccessTools.FieldRefAccess<TerminalAccessibleObject, bool>("inCooldown"); private static readonly FieldRef<TerminalAccessibleObject, bool> isPoweredOnRef = AccessTools.FieldRefAccess<TerminalAccessibleObject, bool>("isPoweredOn"); private static readonly FieldInfo taoInCooldownField = AccessTools.Field(typeof(TerminalAccessibleObject), "inCooldown"); private static readonly FieldInfo taoCooldownTimerField = AccessTools.Field(typeof(TerminalAccessibleObject), "currentCooldownTimer"); private static readonly FieldInfo taoRadarTextField = AccessTools.Field(typeof(TerminalAccessibleObject), "mapRadarText"); private static readonly FieldInfo taoRadarBoxField = AccessTools.Field(typeof(TerminalAccessibleObject), "mapRadarBox"); private static readonly FieldInfo hackingToolSelectedTargetField = AccessTools.Field(typeof(HackingTool), "selectedTarget"); private static readonly FieldInfo hackingToolCurrentHackField = AccessTools.Field(typeof(HackingTool), "currentHack"); private static readonly FieldInfo hackingToolCurrentHackAnswerField = AccessTools.Field(typeof(HackingTool), "currentHackAnswer"); private static readonly FieldInfo hackingToolAnswerStringField = AccessTools.Field(typeof(HackingTool), "answerString"); private static readonly List<TerminalAccessibleObject> cachedTAOs = new List<TerminalAccessibleObject>(); private static readonly List<SpikeRoofTrap> cachedSpikes = new List<SpikeRoofTrap>(); private static readonly List<Landmine> cachedLandmines = new List<Landmine>(); private static float lastCacheRefreshTime = 0f; private const float CacheRefreshInterval = 2f; private static float lastToggleTime = 0f; private static void RefreshCachesIfNeeded() { if (!(Time.time - lastCacheRefreshTime < 2f)) { lastCacheRefreshTime = Time.time; cachedTAOs.Clear(); cachedSpikes.Clear(); cachedLandmines.Clear(); cachedTAOs.AddRange(Object.FindObjectsOfType<TerminalAccessibleObject>()); cachedSpikes.AddRange(Object.FindObjectsOfType<SpikeRoofTrap>()); cachedLandmines.AddRange(Object.FindObjectsOfType<Landmine>()); } } private static bool CheckNotAccessable(TerminalAccessibleObject obj) { return inCooldownRef.Invoke(obj) || !isPoweredOnRef.Invoke(obj); } private static void StopTurret(Turret turret) { if (!((Object)(object)turret == (Object)null)) { if (((NetworkBehaviour)turret).IsHost) { turret.ToggleTurretClientRpc(false); } else { turret.ToggleTurretServerRpc(false); } ((MonoBehaviour)turret).StartCoroutine(ReEnableTurretAfterDelay(turret, TurretDisableTime)); } } [IteratorStateMachine(typeof(<ResetCooldownAfterDelay>d__29))] private static IEnumerator ResetCooldownAfterDelay(TerminalAccessibleObject obj, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetCooldownAfterDelay>d__29(0) { obj = obj, delay = delay }; } [IteratorStateMachine(typeof(<ReEnableTurretAfterDelay>d__30))] private static IEnumerator ReEnableTurretAfterDelay(Turret turret, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReEnableTurretAfterDelay>d__30(0) { turret = turret, delay = delay }; } [IteratorStateMachine(typeof(<ReEnableSpikesAfterDelay>d__31))] private static IEnumerator ReEnableSpikesAfterDelay(SpikeRoofTrap spikes, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReEnableSpikesAfterDelay>d__31(0) { spikes = spikes, delay = delay }; } [IteratorStateMachine(typeof(<ReEnableLandmineAfterDelay>d__32))] private static IEnumerator ReEnableLandmineAfterDelay(Landmine lm, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReEnableLandmineAfterDelay>d__32(0) { lm = lm, delay = delay }; } private static void ResetNearbyTerminalObjects(Vector3 origin, float delay) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>(); foreach (TerminalAccessibleObject val in array) { if (Vector3.Distance(((Component)val).transform.position, origin) <= MaxHackDistance) { ((MonoBehaviour)val).StartCoroutine(ResetCooldownAfterDelay(val, delay)); } } } [HarmonyPatch(typeof(HackingTool), "SwitchHackState")] [HarmonyPrefix] public static void SwitchHackState_Prefix(HackingTool __instance, ref HackState state, ref TerminalAccessibleObject ___selectedTarget) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 bool isTurretMode = IsTurretMode(__instance.hackUpdateTime); if (((NetworkBehaviour)__instance).IsOwner && (int)state == 5 && (Object)(object)___selectedTarget != (Object)null && (int)__instance.hackState.Value != (int)state) { HackingRangeServerRpc(((Component)___selectedTarget).transform.position, isTurretMode); } } [ServerRpc(RequireOwnership = false)] private static void HackingRangeServerRpc(Vector3 position, bool isTurretMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) HackingRangeClientRpc(position, isTurretMode); } [ClientRpc] private static void HackingRangeClientRpc(Vector3 position, bool isTurretMode) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: 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_0168: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) RefreshCachesIfNeeded(); foreach (TerminalAccessibleObject cachedTAO in cachedTAOs) { if ((Object)(object)cachedTAO == (Object)null || Vector3.Distance(((Component)cachedTAO).transform.position, position) >= MaxHackDistance) { continue; } bool flag = (Object)(object)((Component)cachedTAO).GetComponentInParent<Turret>() != (Object)null; bool flag2 = (Object)(object)((Component)cachedTAO).GetComponentInParent<Landmine>() != (Object)null; Transform val = (((Object)(object)((Component)cachedTAO).transform.parent != (Object)null && (Object)(object)((Component)cachedTAO).transform.parent.parent != (Object)null) ? ((Component)cachedTAO).transform.parent.parent : null); bool flag3 = (Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponentInChildren<SpikeRoofTrap>() != (Object)null; if (isTurretMode) { if (!flag && !flag2 && !flag3) { continue; } taoInCooldownField.SetValue(cachedTAO, true); taoCooldownTimerField.SetValue(cachedTAO, TurretDisableTime); object? value = taoRadarTextField.GetValue(cachedTAO); TextMeshProUGUI val2 = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null); object? value2 = taoRadarBoxField.GetValue(cachedTAO); Image val3 = (Image)((value2 is Image) ? value2 : null); if (Object.op_Implicit((Object)(object)val2)) { ((Graphic)val2).color = Color.red; } if (Object.op_Implicit((Object)(object)val3)) { ((Graphic)val3).color = Color.red; } Turret componentInParent = ((Component)cachedTAO).GetComponentInParent<Turret>(); if ((Object)(object)componentInParent != (Object)null) { StopTurret(componentInParent); ResetNearbyTerminalObjects(((Component)cachedTAO).transform.position, TurretDisableTime); } Landmine componentInParent2 = ((Component)cachedTAO).GetComponentInParent<Landmine>(); if ((Object)(object)componentInParent2 != (Object)null && !componentInParent2.hasExploded) { if (LandmineExplodeOnHack) { if (((NetworkBehaviour)componentInParent2).IsHost) { componentInParent2.ExplodeMineClientRpc(); } else { componentInParent2.ExplodeMineServerRpc(); } } else if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { componentInParent2.ToggleMine(false); ((MonoBehaviour)componentInParent2).StartCoroutine(ReEnableLandmineAfterDelay(componentInParent2, LandmineDisableTime)); } else { DisableLandmineServerRpc(((Component)componentInParent2).transform.position); } ResetNearbyTerminalObjects(((Component)cachedTAO).transform.position, LandmineDisableTime); } SpikeRoofTrap val4 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<SpikeRoofTrap>() : null); if ((Object)(object)val4 != (Object)null) { if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { val4.ToggleSpikesEnabled(false); ((MonoBehaviour)val4).StartCoroutine(ReEnableSpikesAfterDelay(val4, SpikeDisableTime)); } else { DisableSpikesServerRpc(((Component)val4).transform.position); } ((MonoBehaviour)cachedTAO).StartCoroutine(ResetCooldownAfterDelay(cachedTAO, SpikeDisableTime)); ResetNearbyTerminalObjects(((Component)cachedTAO).transform.position, SpikeDisableTime); } } else if (!(flag || flag2 || flag3)) { taoInCooldownField.SetValue(cachedTAO, false); AccessTools.Method(typeof(TerminalAccessibleObject), "CallFunctionFromTerminal", (Type[])null, (Type[])null).Invoke(cachedTAO, null); taoInCooldownField.SetValue(cachedTAO, true); taoCooldownTimerField.SetValue(cachedTAO, DoorCooldownTime); object? value3 = taoRadarTextField.GetValue(cachedTAO); TextMeshProUGUI val5 = (TextMeshProUGUI)((value3 is TextMeshProUGUI) ? value3 : null); object? value4 = taoRadarBoxField.GetValue(cachedTAO); Image val6 = (Image)((value4 is Image) ? value4 : null); if (Object.op_Implicit((Object)(object)val5)) { ((Graphic)val5).color = Color.red; } if (Object.op_Implicit((Object)(object)val6)) { ((Graphic)val6).color = Color.red; } ((MonoBehaviour)cachedTAO).StartCoroutine(ResetCooldownAfterDelay(cachedTAO, DoorCooldownTime)); } } } [ServerRpc(RequireOwnership = false)] private static void DisableSpikesServerRpc(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) DisableSpikesClientRpc(position); } [ClientRpc] private static void DisableSpikesClientRpc(Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) RefreshCachesIfNeeded(); foreach (SpikeRoofTrap cachedSpike in cachedSpikes) { if (!(Vector3.Distance(((Component)cachedSpike).transform.position, position) > MaxHackDistance)) { cachedSpike.ToggleSpikesEnabled(false); ((MonoBehaviour)cachedSpike).StartCoroutine(ReEnableSpikesAfterDelay(cachedSpike, SpikeDisableTime)); ResetNearbyTerminalObjects(position, SpikeDisableTime); } } } [ServerRpc(RequireOwnership = false)] private static void DisableLandmineServerRpc(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) DisableLandmineClientRpc(position); } [ClientRpc] private static void DisableLandmineClientRpc(Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) RefreshCachesIfNeeded(); foreach (Landmine cachedLandmine in cachedLandmines) { if (!(Vector3.Distance(((Component)cachedLandmine).transform.position, position) > MaxHackDistance) && !cachedLandmine.hasExploded) { cachedLandmine.ToggleMine(false); ((MonoBehaviour)cachedLandmine).StartCoroutine(ReEnableLandmineAfterDelay(cachedLandmine, LandmineDisableTime)); ResetNearbyTerminalObjects(position, LandmineDisableTime); } } } [HarmonyPatch(typeof(HackingTool), "SwitchHackState")] [HarmonyPostfix] public static void SwitchHackState_Postfix(HackingTool __instance, ref HackState state, ref TerminalAccessibleObject ___selectedTarget) { if ((int)state == 1) { if (IsDoorMode(__instance.hackUpdateTime)) { ((TMP_Text)__instance.targetString).text = "No door"; } else { ((TMP_Text)__instance.targetString).text = "No turret/mine/spikes"; } } if ((int)state == 2) { __instance.connectionTime = ConnectionTime; } __instance.maxHackDistance = MaxHackDistance; __instance.hackCount = HackCount; } private static bool IsTurretMode(float f) { return 10000f <= f && f < 20000f; } private static bool IsDoorMode(float f) { return 20000f <= f; } private static float RealUpdateTime(float f) { return (f > 20000f) ? (f - 20000f) : ((f > 10000f) ? (f - 10000f) : f); } public static void TogglePower(HackingTool tool) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0046: Invalid comparison between Unknown and I4 if (!((NetworkBehaviour)tool).IsOwner || Time.time - lastToggleTime < 0.25f) { return; } lastToggleTime = Time.time; HackState value = tool.hackState.Value; if ((int)value == 0) { tool.SwitchHackState((HackState)1); tool.PlaySoundByID("turnOn"); if ((Object)(object)tool.backLight != (Object)null) { ((Behaviour)tool.backLight).enabled = true; } return; } tool.SwitchHackState((HackState)0); tool.PlaySoundByID("turnOff"); if ((Object)(object)tool.backLight != (Object)null) { ((Behaviour)tool.backLight).enabled = false; } hackingToolSelectedTargetField?.SetValue(tool, null); } [HarmonyPatch(typeof(HackingTool), "ItemInteractLeftRight")] [HarmonyPrefix] private static bool DisableOriginalPowerInput(HackingTool __instance, bool right) { if (!((NetworkBehaviour)__instance).IsOwner) { return true; } if (!right) { return false; } return true; } public static void ToggleHackMode(HackingTool instance) { if (!((Object)(object)instance == (Object)null) && instance.turnedOn) { instance.hackUpdateTime = (IsDoorMode(instance.hackUpdateTime) ? 10000f : 20000f); } } [HarmonyPatch(typeof(HackingTool), "Update")] [HarmonyPrefix] private static void Update_Prefix(HackingTool __instance, ref TerminalAccessibleObject ___selectedTarget, ref float ___hackUpdateTimer) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) if (__instance.hackUpdateTime < 10000f) { __instance.hackUpdateTime = 10000f; } else if (__instance.hackUpdateTime >= 20000f) { __instance.hackUpdateTime = 20000f; } if ((int)__instance.hackState.Value != 1) { return; } bool flag = IsDoorMode(__instance.hackUpdateTime); ___hackUpdateTimer = 0f; __instance.hackUpdateTime += Time.deltaTime; if (RealUpdateTime(__instance.hackUpdateTime) > 2f) { __instance.hackUpdateTime = (flag ? 20000f : 10000f); return; } TerminalAccessibleObject val = null; float num = __instance.maxHackDistance; int num2 = 0; RefreshCachesIfNeeded(); foreach (TerminalAccessibleObject cachedTAO in cachedTAOs) { if ((Object)(object)cachedTAO == (Object)null || CheckNotAccessable(cachedTAO)) { continue; } Landmine componentInParent = ((Component)cachedTAO).GetComponentInParent<Landmine>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.hasExploded) { continue; } bool flag2 = (Object)(object)((Component)cachedTAO).GetComponentInParent<Turret>() != (Object)null; bool flag3 = (Object)(object)((Component)cachedTAO).GetComponentInParent<Landmine>() != (Object)null; Transform val2 = (((Object)(object)((Component)cachedTAO).transform.parent != (Object)null && (Object)(object)((Component)cachedTAO).transform.parent.parent != (Object)null) ? ((Component)cachedTAO).transform.parent.parent : null); bool flag4 = (Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponentInChildren<SpikeRoofTrap>() != (Object)null; bool flag5 = flag2 || flag3 || flag4; if (!(flag && flag5) && (flag || flag5)) { float num3 = Vector3.Distance(((Component)cachedTAO).transform.position, ((Component)__instance).transform.position); if (num3 < __instance.maxHackDistance) { num2++; } if (num3 < num) { num = num3; val = cachedTAO; } } } if ((Object)(object)val != (Object)null) { ___selectedTarget = val; if (flag) { ((TMP_Text)__instance.targetString).text = "Door\n" + val.objectCode; return; } string text = ((num2 <= 1) ? "" : $"+{num2}"); string text2 = (((Object)(object)((Component)val).GetComponentInParent<Turret>() != (Object)null) ? "Turret" : (((Object)(object)((Component)val).GetComponentInParent<Landmine>() != (Object)null) ? "Mine" : "Spikes")); ((TMP_Text)__instance.targetString).text = text2 + "\n" + val.objectCode + "\n" + text; } else { ___selectedTarget = null; ((TMP_Text)__instance.targetString).text = (flag ? "No door" : "No turret/mine/spikes"); } } [HarmonyPatch(typeof(HackingTool), "GenerateHack")] [HarmonyPrefix] private static bool GenerateHack_Prefix(ref HackingTool __instance, ref string ___answerString) { if (!ToggleEnhancedHackGame) { return true; } if (___answerString.Length == 0) { int num = Random.Range((int)Math.Pow(10.0, HackCount - 1), (int)Math.Pow(10.0, HackCount) - 1); ((TMP_Text)__instance.hackString).text = num.ToString(); __instance.currentHackAnswer = (int)char.GetNumericValue(((TMP_Text)__instance.hackString).text[0]); } else { __instance.currentHackAnswer = (int)char.GetNumericValue(((TMP_Text)__instance.hackString).text[__instance.currentHack]); } return false; } [HarmonyPatch(typeof(HackingTool), "ItemActivate")] [HarmonyPrefix] private static void ItemActivate_Prefix(ref HackingTool __instance) { ((GrabbableObject)__instance).itemProperties.batteryUsage = HackBattery; } [HarmonyPatch(typeof(HackingTool), "SwitchHackState")] [HarmonyPostfix] private static void SwitchHackState_HackingUI(HackingTool __instance, HackState state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)state == 3) { __instance.hackCount = HackCount; __instance.GenerateHack(); ((TMP_Text)__instance.progressString).text = string.Join("", Enumerable.Repeat("_", __instance.hackCount)); } } [HarmonyPatch(typeof(HackingTool), "DiscardItem")] [HarmonyPrefix] private static bool DiscardItem_Prefix(HackingTool __instance) { if (!((NetworkBehaviour)__instance).IsOwner) { hackingToolSelectedTargetField?.SetValue(__instance, null); hackingToolCurrentHackField?.SetValue(__instance, 1); hackingToolCurrentHackAnswerField?.SetValue(__instance, 0); hackingToolAnswerStringField?.SetValue(__instance, ""); if ((Object)(object)__instance.backLight != (Object)null) { ((Behaviour)__instance.backLight).enabled = false; } return false; } return true; } [HarmonyPatch(typeof(HackingTool), "PlaySoundByID")] [HarmonyPrefix] private static bool PreventNonOwnerSounds(HackingTool __instance) { return ((NetworkBehaviour)__instance).IsOwner; } } public class HandheldRadarPatch { public static float RadarCapacity = 200f; [HarmonyPatch(typeof(HandheldRadar), "Start")] [HarmonyPostfix] private static void Start_Postfix(HandheldRadar __instance) { ((GrabbableObject)__instance).itemProperties.requiresBattery = true; ((GrabbableObject)__instance).itemProperties.batteryUsage = RadarCapacity; } } [HarmonyPatch(typeof(Missile))] public static class MissilePatch { private static float checkRadius = 0.6f; private static int layerMask = LayerMask.GetMask(new string[1] { "Enemies" }); [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void FixedUpdate_Postfix(Missile __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, checkRadius, layerMask); Collider[] array2 = array; foreach (Collider val in array2) { if ((Object)(object)((Component)val).GetComponent<EnemyAICollisionDetect>() != (Object)null || ((Component)val).CompareTag("Enemy")) { if (((NetworkBehaviour)__instance).IsHost) { __instance.Boom(); __instance.BoomClientRpc(); } else { __instance.BoomServerRpc(); } break; } } } [HarmonyPrefix] [HarmonyPatch("CreateExplosion")] private static bool CreateExplosion_Prefix(Missile __instance) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (((NetworkBehaviour)val2).OwnerClientId == ((NetworkBehaviour)__instance).OwnerClientId) { val = val2; break; } } float num = (float)__instance.damage * 2f; float num2 = __instance.maxDistance * 1.25f; float num3 = Mathf.Max(__instance.minDistance, 1.5f); Utilities.CreateExplosion(((Component)__instance).transform.position, true, (int)num, num3, num2, 10, (CauseOfDeath)3, val); return false; } [HarmonyPrefix] [HarmonyPatch(typeof(Debug), "Log", new Type[] { typeof(object) })] private static bool PreventMissileSpam(object message) { if (message is string text && text.StartsWith("Time alive:")) { return false; } return true; } } public static class PingerBatteryControl { public static bool AllowDrain; } [HarmonyPatch(typeof(Pinger))] public static class PingerPatch { [HarmonyPatch(typeof(Pinger))] public static class PingerScreenStripPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(Pinger __instance) { if ((Object)(object)__instance == (Object)null) { return; } MeshRenderer mainObjectRenderer = ((GrabbableObject)__instance).mainObjectRenderer; if (!((Object)(object)mainObjectRenderer == (Object)null)) { Material[] materials = ((Renderer)mainObjectRenderer).materials; if (materials != null && materials.Length != 0 && materials.Length > 1) { Material[] materials2 = (Material[])(object)new Material[1] { materials[0] }; ((Renderer)mainObjectRenderer).materials = materials2; } } } } [CompilerGenerated] private sealed class <WaitForPing_Postfix>d__5 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; public Pinger __instance; private float <drain>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForPing_Postfix>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; PingerBatteryControl.AllowDrain = true; <>2__current = result; <>1__state = 1; return true; case 1: { <>1__state = -1; PingerBatteryControl.AllowDrain = false; if (((GrabbableObject)__instance).insertedBattery == null || MaxUses <= 0) { return false; } <drain>5__1 = 1f / (float)MaxUses; Battery insertedBattery = ((GrabbableObject)__instance).insertedBattery; insertedBattery.charge -= <drain>5__1; ((GrabbableObject)__instance).insertedBattery.charge = Mathf.Clamp01(((GrabbableObject)__instance).insertedBattery.charge); ((GrabbableObject)__instance).insertedBattery.empty = ((GrabbableObject)__instance).insertedBattery.charge <= 0f; return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static int MaxUses = 11; public static float PingDuration = 8f; public static float PingRange = 80f; [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(Pinger __instance) { __instance.pingTime = PingDuration; ((GrabbableObject)__instance).itemProperties.requiresBattery = true; Traverse val = Traverse.Create((object)__instance); if (val.Field("maxPingDistance").FieldExists()) { val.Field("maxPingDistance").SetValue((object)PingRange); } else if (val.Field("pingRange").FieldExists()) { val.Field("pingRange").SetValue((object)PingRange); } } [IteratorStateMachine(typeof(<WaitForPing_Postfix>d__5))] [HarmonyPostfix] [HarmonyPatch("WaitForPing")] private static IEnumerator WaitForPing_Postfix(IEnumerator result, Pinger __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForPing_Postfix>d__5(0) { result = result, __instance = __instance }; } } [HarmonyPatch(typeof(GrabbableObject), "Update")] public static class GrabbableObject_Update_Patch { private static void Prefix(GrabbableObject __instance) { Pinger val = (Pinger)(object)((__instance is Pinger) ? __instance : null); if (val != null) { ((GrabbableObject)val).itemProperties.batteryUsage = float.MaxValue; } } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal static class RocketLauncherReloadInput { private static float nextReloadTime; private static int FindMissileSlot(PlayerControllerB p) { for (int i = 0; i < p.ItemSlots.Length; i++) { GrabbableObject val = p.ItemSlots[i]; if ((Object)(object)val != (Object)null && (Object)(object)val.itemProperties != (Object)null && val.itemProperties.itemName == "Missile") { return i; } } return -1; } private static void Postfix(PlayerControllerB __instance) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner || !((ButtonControl)Keyboard.current.rKey).wasPressedThisFrame) { return; } GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null || (Object)(object)currentlyHeldObjectServer.itemProperties == (Object)null || currentlyHeldObjectServer.itemProperties.itemName != "Rocket Launcher") { return; } RocketLauncher component = ((Component)currentlyHeldObjectServer).GetComponent<RocketLauncher>(); if ((Object)(object)component == (Object)null) { return; } RocketLauncherReload component2 = ((Component)component).GetComponent<RocketLauncherReload>(); if (!((Object)(object)component2 == (Object)null)) { int ammoSlot = FindMissileSlot(__instance); if (!(Time.unscaledTime < nextReloadTime)) { nextReloadTime = Time.unscaledTime + 0.5f; component2.RequestReloadServerRpc(ammoSlot); } } } } } namespace ImprovedLethalThings.patches { [HarmonyPatch(typeof(FlareController))] public static class FlareControllerPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] public static void EnableFlareShadows(FlareController __instance) { Light componentInChildren = ((Component)__instance).GetComponentInChildren<Light>(); if (!((Object)(object)componentInChildren == (Object)null)) { componentInChildren.shadows = (LightShadows)2; componentInChildren.shadowStrength = 1f; componentInChildren.shadowBias = 0.05f; componentInChildren.shadowNormalBias = 0.4f; } } } } namespace ImprovedLethalThings.Networking { public class RocketLauncherReload : NetworkBehaviour { private static readonly FieldInfo currentAmmoField = typeof(RocketLauncher).GetField("currentAmmo", BindingFlags.Instance | BindingFlags.NonPublic); [ServerRpc(RequireOwnership = false)] public void RequestReloadServerRpc(int ammoSlot, ServerRpcParams rpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2278487666u, rpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, ammoSlot); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2278487666u, rpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (((NetworkBehaviour)this).IsServer) { RocketLauncher component = ((Component)this).GetComponent<RocketLauncher>(); if (!((Object)(object)component == (Object)null) && currentAmmoField?.GetValue(component) is NetworkVariable<int> val2 && val2.Value < component.maxAmmo) { ulong senderClientId = rpcParams.Receive.SenderClientId; ConfirmReloadClientRpc(ammoSlot, new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(senderClientId) } }); } } } [ClientRpc] private void ConfirmReloadClientRpc(int ammoSlot, ClientRpcParams _params = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3248320239u, _params, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, ammoSlot); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3248320239u, _params, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; RocketLauncher component = ((Component)this).GetComponent<RocketLauncher>(); if ((Object)(object)component == (Object)null) { return; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null || ammoSlot < 0 || ammoSlot >= localPlayerController.ItemSlots.Length) { return; } GrabbableObject val2 = localPlayerController.ItemSlots[ammoSlot]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2.itemProperties == (Object)null || val2.itemProperties.itemName != "Missile" || !(currentAmmoField?.GetValue(component) is NetworkVariable<int> val3) || val3.Value >= component.maxAmmo) { return; } ReloadServerRpc(); localPlayerController.DestroyItemInSlotAndSync(ammoSlot); AudioSource val4 = ((Component)localPlayerController).GetComponent<AudioSource>() ?? ((Component)localPlayerController).gameObject.AddComponent<AudioSource>(); AssetBundle val5 = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle b) => ((Object)b).name == "improvedlethalthingsassets")); if ((Object)(object)val5 != (Object)null) { AudioClip val6 = val5.LoadAsset<AudioClip>("Assets/LethalCompany/Mods/plugins/MisideItems/Content/Items/Missile/reload.wav"); if ((Object)(object)val6 != (Object)null) { val4.PlayOneShot(val6); } } } [ServerRpc(RequireOwnership = false)] private void ReloadServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2070766885u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2070766885u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; RocketLauncher component = ((Component)this).GetComponent<RocketLauncher>(); if (!((Object)(object)component == (Object)null) && currentAmmoField?.GetValue(component) is NetworkVariable<int> val3) { SyncAmmoClientRpc(ammo: val3.Value = Mathf.Clamp(val3.Value + 1, 0, component.maxAmmo), rocketNetId: ((NetworkBehaviour)component).NetworkObjectId); } } } [ClientRpc] private void SyncAmmoClientRpc(ulong rocketNetId, int ammo) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0071: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2330922952u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, rocketNetId); BytePacker.WriteValueBitPacked(val2, ammo); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2330922952u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(rocketNetId, out var value)) { RocketLauncher component = ((Component)value).GetComponent<RocketLauncher>(); if (!((Object)(object)component == (Object)null) && currentAmmoField?.GetValue(component) is NetworkVariable<int> val3) { val3.Value = ammo; } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2278487666u, new RpcReceiveHandler(__rpc_handler_2278487666), "RequestReloadServerRpc"); ((NetworkBehaviour)this).__registerRpc(3248320239u, new RpcReceiveHandler(__rpc_handler_3248320239), "ConfirmReloadClientRpc"); ((NetworkBehaviour)this).__registerRpc(2070766885u, new RpcReceiveHandler(__rpc_handler_2070766885), "ReloadServerRpc"); ((NetworkBehaviour)this).__registerRpc(2330922952u, new RpcReceiveHandler(__rpc_handler_2330922952), "SyncAmmoClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2278487666(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int ammoSlot = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref ammoSlot); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((RocketLauncherReload)(object)target).RequestReloadServerRpc(ammoSlot, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3248320239(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int ammoSlot = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref ammoSlot); ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((RocketLauncherReload)(object)target).ConfirmReloadClientRpc(ammoSlot, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2070766885(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((RocketLauncherReload)(object)target).ReloadServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2330922952(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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) //IL_0043: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong rocketNetId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref rocketNetId); int ammo = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref ammo); target.__rpc_exec_stage = (__RpcExecStage)1; ((RocketLauncherReload)(object)target).SyncAmmoClientRpc(rocketNetId, ammo); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "RocketLauncherReload"; } } [HarmonyPatch(typeof(HUDManager), "ChangeControlTipMultiple")] internal static class RocketLauncherReloadTip { private static void Prefix(ref string[] allLines, bool holdingItem, Item itemProperties) { if (holdingItem && !((Object)(object)itemProperties == (Object)null) && !(itemProperties.itemName != "Rocket Launcher")) { if (allLines == null) { allLines = new string[1] { "Reload : [R]" }; return; } string[] array = new string[allLines.Length + 1]; allLines.CopyTo(array, 0); array[^1] = "Reload : [R]"; allLines = array; } } } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { return !_moveNextCalled && (_moveNextCalled = true); } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { return (!EqualityComparer<T>.Default.Equals(_item, (T)value)) ? (-1) : 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return (!EqualityComparer<T>.Default.Equals(_item, item)) ? (-1) : 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace ImprovedLethalThings.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }