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 PreventRandomLightningDeaths v1.0.3
PreventRandomLightningDeaths.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using PreventRandomLightningDeaths.Patches; using UnityEngine; using UnityEngine.AI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("DisableRandomLightning")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DisableRandomLightning")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9554fc61-af3b-40ec-801d-3effc7e1b632")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace PreventRandomLightningDeaths { [BepInPlugin("Vizashiro.PreventRandomLightningDeaths", "PreventRandomLightningDeaths", "1.0.3.0")] public class PreventRandomLightningDeathsBase : BaseUnityPlugin { private const string modGUID = "Vizashiro.PreventRandomLightningDeaths"; private const string modName = "PreventRandomLightningDeaths"; private const string modVersion = "1.0.3.0"; private readonly Harmony harmony = new Harmony("Vizashiro.PreventRandomLightningDeaths"); internal static ManualLogSource mls; private static PreventRandomLightningDeathsBase Instance; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Vizashiro.PreventRandomLightningDeaths"); harmony.PatchAll(typeof(PreventRandomLightningDeathsBase)); harmony.PatchAll(typeof(LightningStrikeRandomPatch)); } } } namespace PreventRandomLightningDeaths.Patches { [HarmonyPatch(typeof(StormyWeather))] internal class LightningStrikeRandomPatch { [HarmonyPatch("LightningStrikeRandom")] [HarmonyPrefix] private static bool Prefix(StormyWeather __instance, ref Random ___seed, ref GameObject[] ___outsideNodes, NavMeshHit ___navHit) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0155: 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) try { Dictionary<string, Vector3> dictionary = new Dictionary<string, Vector3>(); for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i]; if (Object.op_Implicit((Object)(object)val) && val.isPlayerControlled && !val.isInsideFactory) { Vector3 position = ((Component)val).transform.position; string playerUsername = val.playerUsername; dictionary.Add(playerUsername, position); } } if (dictionary.Count > 0) { bool flag = false; int num = 0; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0f, 0f); if (___outsideNodes == null) { ___outsideNodes = (from x in GameObject.FindGameObjectsWithTag("OutsideAINode") orderby x.transform.position.x + x.transform.position.z select x).ToArray(); } while (!flag && num < 100) { num++; int num2 = ___seed.Next(0, ___outsideNodes.Length); GameObject val3 = ___outsideNodes[num2]; if (!((Object)(object)val3 != (Object)null)) { continue; } Vector3 position2 = val3.transform.position; bool flag2 = true; foreach (KeyValuePair<string, Vector3> item in dictionary) { string key = item.Key; Vector3 val4 = dictionary[key]; if (Vector3.Distance(val4, position2) < 40f) { flag2 = false; break; } } if (flag2) { flag = true; val2 = position2; break; } } if (flag) { val2 = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val2, 15f, ___navHit, ___seed, -1); __instance.LightningStrike(val2, false); } return false; } return true; } catch (Exception ex) { PreventRandomLightningDeathsBase.mls.LogError((object)ex.Message); return true; } } } }