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 LCSpawnOnPlayerFix v1.0.0
LCSpawnOnPlayerFix.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; using UnityEngine; [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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("LCSpawnOnPlayerFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Ever got an Eyeless Dog or Forest Giant spawn directly on top of you? Yeah... This mod fixes that.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+01481f30750129d740d9a3593f9453429b54104b")] [assembly: AssemblyProduct("LCSpawnOnPlayerFix")] [assembly: AssemblyTitle("LCSpawnOnPlayerFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace LCSpawnOnPlayerFix { public static class Helpers { public const float SafeSpawnDistanceFromPlayer = 16f; public const float SafeSpawnSquaredDistanceFromPlayer = 256f; public static readonly Vector3 SafeOutsideScaleDistance = new Vector3(1f, 0.7f, 1f); public static float SquaredDistance(Vector3 v1, Vector3 v2, Vector3 scale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) float num = v1.x - v2.x; float num2 = v1.y - v2.y; float num3 = v1.z - v2.z; return num * num * scale.x * scale.x + num2 * num2 * scale.y * scale.y + num3 * num3 * scale.z * scale.z; } public static bool IsTrulyAlive(this PlayerControllerB player) { return ((NetworkBehaviour)player).IsSpawned && player.isPlayerControlled && !player.isPlayerDead; } public static bool IsUnsafeOutside(this PlayerControllerB player) { return !player.isInsideFactory && !player.isInHangarShipRoom; } public static bool IsOutsidePositionNearPlayer(this PlayerControllerB player, Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return SquaredDistance(position, ((Component)player).transform.position, SafeOutsideScaleDistance) < 256f; } } [BepInPlugin("LCSpawnOnPlayerFix", "LCSpawnOnPlayerFix", "1.0.0")] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = null; internal static ManualLogSource Logger { get; private set; } protected Plugin() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("LCSpawnOnPlayerFix"); } protected void Awake() { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)"Plugin LCSpawnOnPlayerFix is loaded!"); } ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogDebug((object)"Patching harmony..."); } _harmony.PatchAll(Assembly.GetExecutingAssembly()); } } public static class PluginInfo { public const string PLUGIN_GUID = "LCSpawnOnPlayerFix"; public const string PLUGIN_NAME = "LCSpawnOnPlayerFix"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace LCSpawnOnPlayerFix.Patches { [HarmonyPatch(typeof(RoundManager))] internal static class RoundManagerPatch { [HarmonyPatch("SpawnRandomOutsideEnemy")] [HarmonyPrefix] private static bool SpawnRandomOutsideEnemyPrefix(ref GameObject[] spawnPoints) { int num = spawnPoints.Length; List<GameObject> list = new List<GameObject>(spawnPoints); int num2 = StartOfRound.Instance.allPlayerScripts.Length; for (int i = 0; i < num2; i++) { PlayerControllerB player = StartOfRound.Instance.allPlayerScripts[i]; if ((Object)(object)player != (Object)null && player.IsTrulyAlive() && player.IsUnsafeOutside()) { list.RemoveAll((GameObject x) => player.IsOutsidePositionNearPlayer(x.transform.position)); } } ManualLogSource logger = Plugin.Logger; if (logger != null) { logger.LogDebug((object)string.Format("\"{0}\" Removed {1} spawn points too close to players", "RoundManagerPatch", num - list.Count)); } if (list.Count < 1) { return false; } spawnPoints = list.ToArray(); return true; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }