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 EnhancedLethalThings v1.0.2
EnhancedLethalThings.dll
Decompiled 2 years agousing System; 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 GameNetcodeStuff; using HarmonyLib; using LethalThings; using LethalThings.Extensions; using LethalThings.MonoBehaviours; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; 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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("EnhancedLethalThings")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("EnhancedLethalThings")] [assembly: AssemblyFileVersion("1.0.2")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("EnhancedLethalThings")] [assembly: AssemblyTitle("EnhancedLethalThings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EnhancedLethalThings { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("EnhancedLethalThings", "EnhancedLethalThings", "1.0.2")] public class EnhancedLethalThings : BaseUnityPlugin { public class HackingToolPatch { public static int hackCount = 6; private const float SELECTION_TIME_TURRET_MODE_OFFSET = 10000f; private const float SELECTION_TIME_DOOR_MODE_OFFSET = 20000f; public static float maxHackDistance = 30f; public static float HackSpreadDistance = 20f; public static float ConnectionTime = 3f; public static float HackBattery = 2000f; private static bool CheckNotAccessable(TerminalAccessibleObject obj) { Traverse val = Traverse.Create((object)obj); return (val.Field("inCooldown").GetValue() as bool?).Value || !(val.Field("isPoweredOn").GetValue() as bool?).Value; } private static void StopTurret(Turret turret) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) turret.turretMode = (TurretMode)0; ((BaseUnityPlugin)instance).Logger.LogInfo((object)"Turret Off 00"); MethodInfo method = typeof(Turret).GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(turret, Array.Empty<object>()); ((BaseUnityPlugin)instance).Logger.LogInfo((object)"Turret Off 11"); MethodInfo method2 = typeof(Turret).GetMethod("ToggleTurretEnabledLocalClient", BindingFlags.Instance | BindingFlags.NonPublic); method2.Invoke(turret, new object[1] { false }); ((BaseUnityPlugin)instance).Logger.LogInfo((object)"Turret Off 22"); } [HarmonyPatch(typeof(HackingTool), "SwitchHackState")] [HarmonyPrefix] public static void SwitchHackState_Patch(HackingTool __instance, ref HackState state, ref TerminalAccessibleObject ___selectedTarget) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 if (((NetworkBehaviour)__instance).IsOwner && (int)state == 5 && (Object)(object)___selectedTarget != (Object)null && (int)__instance.hackState.Value != (int)state && IsTurretMode(__instance.hackUpdateTime)) { HackingRangeServerRpc(((Component)___selectedTarget).transform.position); } if ((int)state == 2) { __instance.connectionTime = ConnectionTime; } } [ServerRpc] private static void HackingRangeServerRpc(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) HackingRangeClientRpc(position); } [ClientRpc] private static void HackingRangeClientRpc(Vector3 position) { //IL_004f: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>(); TerminalAccessibleObject[] array2 = array; foreach (TerminalAccessibleObject val in array2) { if (!((Object)(object)val == (Object)null) && ((Object)null != (Object)(object)((Component)val).GetComponentInParent<Turret>() || (Object)null != (Object)(object)((Component)val).GetComponentInParent<Landmine>()) && Vector3.Distance(((Component)val).transform.position, position) < maxHackDistance) { ((BaseUnityPlugin)instance).Logger.LogDebug((object)("Terminal Off " + val.objectCode)); Traverse val2 = Traverse.Create((object)val); val2.Field("inCooldown").SetValue((object)true); object value = val2.Field("mapRadarText").GetValue(); TextMeshProUGUI val3 = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null); object value2 = val2.Field("mapRadarBox").GetValue(); Image val4 = (Image)((value2 is Image) ? value2 : null); val2.Field("currentCooldownTimer").SetValue((object)100000f); ((Graphic)val3).color = Color.red; ((Graphic)val4).color = Color.red; Turret componentInParent = ((Component)val).GetComponentInParent<Turret>(); if ((Object)(object)componentInParent != (Object)null) { StopTurret(componentInParent); ((BaseUnityPlugin)instance).Logger.LogDebug((object)("Turret Off " + val.objectCode)); } Landmine componentInParent2 = ((Component)val).GetComponentInParent<Landmine>(); if ((Object)(object)componentInParent2 != (Object)null) { ((BaseUnityPlugin)instance).Logger.LogDebug((object)("Landmine Off " + val.objectCode)); componentInParent2.ToggleMineEnabledLocalClient(false); componentInParent2.hasExploded = true; componentInParent2.mineAnimator.SetTrigger("detonate"); } } } } [HarmonyPatch(typeof(Landmine), "Detonate")] [HarmonyPrefix] public static bool Detonate_Patch(Landmine __instance, ref bool ___mineActivated) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!___mineActivated) { __instance.mineAudio.pitch = Random.Range(0.93f, 1.07f); __instance.mineAudio.PlayOneShot(__instance.mineDetonate, 1f); SpawnSafetyExplosion(((Component)__instance).transform.position + Vector3.up); return false; } return true; } public static void SpawnSafetyExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false) { //IL_0051: 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) //IL_0011: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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) //IL_0167: 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) if (spawnExplosionEffect) { Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true); } float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition); if (num < 14f) { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } else if (num < 25f) { HUDManager.Instance.ShakeCamera((ScreenShakeType)0); } Collider[] array = Physics.OverlapSphere(explosionPosition, 6f, 2621448, (QueryTriggerInteraction)2); for (int i = 0; i < array.Length; i++) { float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position); if ((!(num2 > 4f) || !Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) && ((Component)array[i]).gameObject.layer == 19) { EnemyAICollisionDetect componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>(); if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num2 < 4.5f) { componentInChildren.mainScript.HitEnemyOnLocalClient(6, default(Vector3), (PlayerControllerB)null, false); } } } } [HarmonyPatch(typeof(HackingTool), "SwitchHackState")] [HarmonyPostfix] public static void SwitchHackState_PostPatch(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"; } } __instance.maxHackDistance = maxHackDistance; __instance.hackCount = hackCount; } private static bool IsTurretMode(float reservedFloat) { return 10000f <= reservedFloat && reservedFloat < 20000f; } private static bool IsDoorMode(float reservedFloat) { return 20000f <= reservedFloat; } private static float RealUpdateTime(float reservedFloat) { if (reservedFloat > 20000f) { return reservedFloat - 20000f; } if (reservedFloat > 10000f) { return reservedFloat - 10000f; } return reservedFloat; } [HarmonyPatch(typeof(HackingTool), "ItemInteractLeftRight")] [HarmonyPostfix] public static void ItemInteractLeftRight_Patch(HackingTool __instance, ref bool right) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (((NetworkBehaviour)__instance).IsOwner && !right && (int)__instance.hackState.Value == 0) { if (!IsTurretMode(__instance.hackUpdateTime)) { __instance.hackUpdateTime = 10000f; } else { __instance.hackUpdateTime = 20000f; } } } [HarmonyPatch(typeof(HackingTool), "Update")] [HarmonyPrefix] private static void Update_Patch(HackingTool __instance, ref TerminalAccessibleObject ___selectedTarget, ref float ___hackUpdateTimer) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) if (__instance.hackUpdateTime < 10000f) { __instance.hackUpdateTime = 10000f; } 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; TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>(); int num2 = 0; TerminalAccessibleObject[] array2 = array; foreach (TerminalAccessibleObject val2 in array2) { if ((Object)(object)val2 == (Object)null || CheckNotAccessable(val2)) { continue; } bool flag2 = (Object)null != (Object)(object)((Component)val2).GetComponentInParent<Turret>() || (Object)null != (Object)(object)((Component)val2).GetComponentInParent<Landmine>(); if ((flag2 && !flag) || !(flag2 && flag)) { float num3 = Vector3.Distance(((Component)val2).transform.position, ((Component)__instance).transform.position); if (num3 < __instance.maxHackDistance) { num2++; } if (num3 < num) { num = num3; val = val2; } } } 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)null != (Object)(object)((Component)val).GetComponentInParent<Turret>()) ? "Turret" : "Mine"); ((TMP_Text)__instance.targetString).text = text2 + "\n" + val.objectCode + "\n" + text; } else { ___selectedTarget = null; if (flag) { ((TMP_Text)__instance.targetString).text = "No door"; } else { ((TMP_Text)__instance.targetString).text = "No turret mine"; } } } [HarmonyPatch(typeof(HackingTool))] [HarmonyPatch("GenerateHack")] [HarmonyPrefix] private static bool GenerateHack_Patch(ref HackingTool __instance, ref string ___answerString) { 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))] [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static void ItemActivate_Patch(ref HackingTool __instance) { ((GrabbableObject)__instance).itemProperties.batteryUsage = HackBattery; } [HarmonyPatch(typeof(HackingTool))] [HarmonyPatch("ItemInteractLeftRight")] [HarmonyPrefix] private static void ItemInteract_Patch(ref HackingTool __instance) { ((GrabbableObject)__instance).itemProperties.batteryUsage = HackBattery; } } public static EnhancedLethalThings instance; public ConfigFile config; public void Awake() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown instance = this; config = ((BaseUnityPlugin)this).Config; ConfigEntry<bool> val = ((BaseUnityPlugin)instance).Config.Bind<bool>("Hacking Tool", "Enable HackingTool Patch", true, "Determine to apply below hackingTool patch"); Harmony val2 = new Harmony("EnhancedLethalThings"); val2.PatchAll(typeof(EnhancedLethalThings)); if (val.Value) { val2.PatchAll(typeof(HackingToolPatch)); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin EnhancedLethalThings is loaded!"); ConfigEntry<float> val3 = ((BaseUnityPlugin)instance).Config.Bind<float>("Hacking Tool", "Hackdistance", HackingToolPatch.maxHackDistance, "Range of selecting hacking target. LethalThings default : 15"); HackingToolPatch.maxHackDistance = val3.Value; ConfigEntry<float> val4 = ((BaseUnityPlugin)instance).Config.Bind<float>("Hacking Tool", "HackSpreadDistance", HackingToolPatch.HackSpreadDistance, "Once hacking successed, other hacking item in this distance will also be hacked"); HackingToolPatch.maxHackDistance = val4.Value; ConfigEntry<int> val5 = ((BaseUnityPlugin)instance).Config.Bind<int>("Hacking Tool", "AnswerNumber", HackingToolPatch.hackCount, "The length of hacking tool answer. LethalThings default : 8"); HackingToolPatch.hackCount = val5.Value; if (HackingToolPatch.hackCount < 1) { HackingToolPatch.hackCount = 1; } ConfigEntry<float> val6 = ((BaseUnityPlugin)instance).Config.Bind<float>("Hacking Tool", "ConnectionTime", HackingToolPatch.ConnectionTime, "How long it will take to connect target"); HackingToolPatch.ConnectionTime = val6.Value; ConfigEntry<float> val7 = ((BaseUnityPlugin)instance).Config.Bind<float>("Hacking Tool", "Battery", HackingToolPatch.HackBattery, "The amount of battery"); HackingToolPatch.HackBattery = val7.Value; } [HarmonyPatch(typeof(PlayerControllerB), "BeginGrabObject")] [HarmonyPostfix] private static void UpdateBeginGrabObject(PlayerControllerB __instance, ref bool ___twoHanded) { if (__instance.ItemSlots.Any((GrabbableObject x) => (Object)(object)x != (Object)null && x is PouchyBelt)) { ___twoHanded = false; } } [HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")] [HarmonyPostfix] private static void UpdateGrabObjectClientRpc(PlayerControllerB __instance, ref bool ___twoHanded) { if (__instance.ItemSlots.Any((GrabbableObject x) => (Object)(object)x != (Object)null && x is PouchyBelt)) { ___twoHanded = false; } } [HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")] [HarmonyPostfix] private static void UpdateSwitchToItemSlot(PlayerControllerB __instance, ref bool ___twoHanded) { if (__instance.ItemSlots.Any((GrabbableObject x) => (Object)(object)x != (Object)null && x is PouchyBelt)) { ___twoHanded = false; } } [HarmonyPatch(typeof(PouchyBelt), "RemoveItemSlots")] [HarmonyPrefix] public static void RemoveItemSlots_Patch(PouchyBelt __instance, ref PlayerControllerB ___playerHeldBy) { if (!((Object)(object)___playerHeldBy != (Object)null)) { return; } int num = ___playerHeldBy.ItemSlots.Length - __instance.beltCapacity; for (int i = 0; i < num; i++) { GrabbableObject val = ___playerHeldBy.ItemSlots[i]; if ((Object)(object)val != (Object)null && val.itemProperties.twoHanded) { PlayerControllerExtensions.DropItem(___playerHeldBy, val, i, true); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "EnhancedLethalThings"; public const string PLUGIN_NAME = "EnhancedLethalThings"; public const string PLUGIN_VERSION = "1.0.2"; } }