Decompiled source of SuperLandmineFixed v1.1.7

SuperLandmine.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using 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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SuperLandmine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("SuperLandmine mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.1.7.0")]
[assembly: AssemblyInformationalVersion("1.1.7+63d4043842ea53f4b2be900ec1709592b2118b71")]
[assembly: AssemblyProduct("SuperLandmine")]
[assembly: AssemblyTitle("SuperLandmine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.7.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class ExtensionMarkerAttribute : Attribute
	{
		private readonly string <Name>k__BackingField;

		public string Name => <Name>k__BackingField;

		public ExtensionMarkerAttribute(string name)
		{
			<Name>k__BackingField = name;
		}
	}
}
namespace SuperLandmine
{
	[BepInPlugin("Superlandmine", "SuperLandmine", "1.1.4")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource log;

		public Harmony harmony = new Harmony("Superlandmine");

		public static ConfigEntry<int> config_LandmineMinAmount;

		public static ConfigEntry<int> config_LandmineMaxAmount;

		public static ConfigEntry<bool> config_DisableLandmineBeepSound;

		public static ConfigEntry<bool> config_DisableLandmineExplosionSound;

		public static ConfigEntry<bool> config_EnemyCanTriggerLandmine;

		public static ConfigEntry<bool> config_LandmineCanSpawnOutside;

		public static ConfigEntry<bool> config_UseDefaultLandmineSpawnRate;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			log.LogInfo((object)"Loading plugin SuperLandmine ...");
			ConfigSetup();
			harmony.PatchAll();
			log.LogInfo((object)"Plugin SuperLandmine loaded!");
		}

		private void ConfigSetup()
		{
			config_LandmineMinAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Landmine min amount", "Value", 10, "Min landmine to be spawned in the map");
			config_LandmineMaxAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Landmine max amount", "Value", 15, "Max landmine to be spawned in the map");
			config_DisableLandmineBeepSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Disable landmine beep sound", "Value", true, "Enable or disable landmine beep sound");
			config_DisableLandmineExplosionSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Disable landmine explosion sound", "Value", true, "Enable or disable landmine explosion sound");
			config_EnemyCanTriggerLandmine = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemy trigger landmine", "Value", true, "Enable or disable enemy can trigger landmine");
			config_LandmineCanSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<bool>("Landmine can spawn outside", "Value", true, "Enable or disable landmine can spawn outside");
			config_UseDefaultLandmineSpawnRate = ((BaseUnityPlugin)this).Config.Bind<bool>("Use default landmine spawn rate", "Value", false, "Enable or disable default landmine spawn rate");
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "Superlandmine";

		public const string PLUGIN_NAME = "SuperLandmine";

		public const string PLUGIN_VERSION = "1.1.4";
	}
	public static class Utils
	{
		public class OutsideLandmineMarker : MonoBehaviour
		{
		}

		public const float MAX_RAYCAST_DIST = 30000f;

		public static (Vector3, Quaternion) projectToGround(Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0028: 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_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			Ray val = new Ray(position, Vector3.down);
			Quaternion item = Quaternion.identity;
			Vector3 item2 = position;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 30000f))
			{
				item2 = ((RaycastHit)(ref val2)).point;
				item = Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val2)).normal);
			}
			return (item2, item);
		}
	}
}
namespace SuperLandmine.Patchs
{
	[HarmonyPatch(typeof(Landmine))]
	public class SuperLandminePatch
	{
		[CompilerGenerated]
		private sealed class <DelayedExplosion>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Landmine __instance;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayedExplosion>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Expected O, but got Unknown
				//IL_00d6: 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)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					__instance.mineAudio.volume = 1.2f;
					__instance.mineFarAudio.volume = 1.3f;
					__instance.mineAudio.pitch = Random.Range(0.93f, 1.07f);
					__instance.mineAudio.PlayOneShot(__instance.mineDetonate, 1.2f);
					__instance.mineFarAudio.PlayOneShot(__instance.mineDetonate, 1.3f);
					Landmine.SpawnExplosion(((Component)__instance).transform.position + Vector3.up, true, 10f, 12f, 50, 0f, (GameObject)null, false);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					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 <PlayPressSound>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Landmine __instance;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PlayPressSound>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Plugin.log.LogInfo((object)"Play press sound");
					__instance.mineAudio.volume = 1.3f;
					__instance.mineFarAudio.volume = 1.3f;
					__instance.mineAudio.PlayOneShot(__instance.minePress, 1.3f);
					WalkieTalkie.TransmitOneShotAudio(__instance.mineAudio, __instance.minePress, 1f);
					<>2__current = (object)new WaitForSeconds(__instance.minePress.length);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (Plugin.config_DisableLandmineBeepSound.Value && !__instance.GetIdleSoundDisabled())
					{
						__instance.SetIdleSoundDisabled(value: true);
						Plugin.log.LogInfo((object)"Disabling idle audio");
						__instance.mineAudio.volume = 0f;
						__instance.mineFarAudio.volume = 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();
			}
		}

		private static float GetWeightThreshold()
		{
			if (Chainloader.PluginInfos.ContainsKey("LethalWeightedMines"))
			{
				object obj = (Type.GetType("LethalWeightedMines.LethalWeightedMines, LethalWeightedMines")?.GetProperty("CustomConfig", BindingFlags.Static | BindingFlags.NonPublic))?.GetValue(null);
				if (obj != null)
				{
					object obj2 = obj.GetType().GetField("MinWeight")?.GetValue(obj);
					return (float)((obj2?.GetType().GetProperty("Value"))?.GetValue(obj2) ?? ((object)0.01f));
				}
			}
			return 0.01f;
		}

		private static float CallGetWeight(Landmine mine)
		{
			try
			{
				Type type = Type.GetType("LethalWeightedMines.Patches.LandmineExtender, LethalWeightedMines");
				if (type != null)
				{
					MethodInfo method = type.GetMethod("GetWeight", BindingFlags.Static | BindingFlags.Public);
					if (method != null)
					{
						return (float)method.Invoke(null, new object[1] { mine });
					}
				}
			}
			catch (Exception ex)
			{
				Debug.Log((object)("[SuperLandmines] Reflection failed: " + ex.Message));
			}
			return 0f;
		}

		[HarmonyPatch("PressMineClientRpc")]
		[HarmonyPostfix]
		public static void playTriggerSound(Landmine __instance)
		{
			Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
			((MonoBehaviour)__instance).StartCoroutine(PlayPressSound(__instance));
		}

		[IteratorStateMachine(typeof(<PlayPressSound>d__3))]
		private static IEnumerator PlayPressSound(Landmine __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PlayPressSound>d__3(0)
			{
				__instance = __instance
			};
		}

		[HarmonyPatch("SetOffMineAnimation")]
		[HarmonyPrefix]
		public static void ReEnableAudio(Landmine __instance)
		{
			__instance.mineAudio.volume = 1.2f;
			__instance.mineFarAudio.volume = 1.3f;
		}

		[HarmonyPatch("Detonate")]
		[HarmonyPrefix]
		public static void IncreaseAudioVolume(Landmine __instance)
		{
			Plugin.log.LogInfo((object)"Increase landmine volume and kill range");
			__instance.mineAudio.volume = 1.2f;
			__instance.mineFarAudio.volume = 1.3f;
			if (!__instance.hasExploded)
			{
				((MonoBehaviour)__instance).StartCoroutine(DelayedExplosion(__instance));
				__instance.hasExploded = true;
			}
		}

		[IteratorStateMachine(typeof(<DelayedExplosion>d__6))]
		private static IEnumerator DelayedExplosion(Landmine __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedExplosion>d__6(0)
			{
				__instance = __instance
			};
		}

		[HarmonyPatch("Detonate")]
		[HarmonyPostfix]
		public static void disableSoundAfterExplode(Landmine __instance)
		{
			if (Plugin.config_DisableLandmineExplosionSound.Value)
			{
				__instance.mineAudio.volume = 0f;
				__instance.mineFarAudio.volume = 0f;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void disabledLandMineSound(Landmine __instance)
		{
			if (Plugin.config_DisableLandmineBeepSound.Value)
			{
				__instance.mineAudio.volume = 0f;
				__instance.mineFarAudio.volume = 0f;
			}
		}

		[HarmonyPatch("OnTriggerEnter")]
		[HarmonyPrefix]
		public static void anyObjectTriggerLandmineEnter(ref Collider other, Landmine __instance)
		{
			if (!Plugin.config_EnemyCanTriggerLandmine.Value)
			{
				return;
			}
			float weightThreshold = GetWeightThreshold();
			float value = Traverse.Create((object)__instance).Field("pressMineDebounceTimer").GetValue<float>();
			if (__instance.hasExploded || value > 0f)
			{
				return;
			}
			if (((Component)other).CompareTag("Player"))
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if (!((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && (Object)(object)component != (Object)null && !component.isPlayerDead)
				{
					Traverse.Create((object)__instance).Field("localPlayerOnMine").SetValue((object)true);
					Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
					__instance.PressMineServerRpc();
				}
			}
			else
			{
				if (!((Component)other).CompareTag("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp") && !((Component)other).CompareTag("Enemy"))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
				{
					if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						return;
					}
				}
				else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
				{
					return;
				}
				if (CallGetWeight(__instance) >= weightThreshold)
				{
					Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
					__instance.SetIdleSoundDisabled(value: false);
					__instance.PressMineServerRpc();
				}
			}
		}

		[HarmonyPatch("OnTriggerExit")]
		[HarmonyPrefix]
		public static void anyObjectTriggerLandmineExit(ref Collider other, Landmine __instance)
		{
			if (!Plugin.config_EnemyCanTriggerLandmine.Value)
			{
				return;
			}
			bool value = Traverse.Create((object)__instance).Field("mineActivated").GetValue<bool>();
			float weightThreshold = GetWeightThreshold();
			if (__instance.hasExploded || !value)
			{
				return;
			}
			if (((Component)other).CompareTag("Player"))
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !(CallGetWeight(__instance) >= weightThreshold))
				{
					Traverse.Create((object)__instance).Field("localPlayerOnMine").SetValue((object)false);
					Traverse.Create((object)__instance).Method("TriggerMineOnLocalClientByExiting", Array.Empty<object>()).GetValue();
				}
			}
			else
			{
				if (!((Component)other).CompareTag("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp") && !((Component)other).CompareTag("Enemy"))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
				{
					if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						return;
					}
				}
				else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
				{
					return;
				}
				if (!(CallGetWeight(__instance) >= weightThreshold))
				{
					Traverse.Create((object)__instance).Method("TriggerMineOnLocalClientByExiting", Array.Empty<object>()).GetValue();
				}
			}
		}
	}
	public static class LandmineExtender
	{
		[SpecialName]
		public sealed class <G>$690F5BDD406AC531BEB93458DE0C597F
		{
			[SpecialName]
			public static class <M>$6FA3BD1CE21B404F0D651C26F2C5F6B0
			{
			}

			[ExtensionMarker("<M>$6FA3BD1CE21B404F0D651C26F2C5F6B0")]
			public void SetIdleSoundDisabled(bool value)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$6FA3BD1CE21B404F0D651C26F2C5F6B0")]
			public bool GetIdleSoundDisabled()
			{
				throw new NotSupportedException();
			}
		}

		private static readonly ConditionalWeakTable<Landmine, LandmineExtension> extension = new ConditionalWeakTable<Landmine, LandmineExtension>();

		public static void SetIdleSoundDisabled(this Landmine landmine, bool value)
		{
			if (!extension.TryGetValue(landmine, out var value2))
			{
				value2 = new LandmineExtension();
				extension.Add(landmine, value2);
			}
			value2.idleSoundDisabled = value;
		}

		public static bool GetIdleSoundDisabled(this Landmine landmine)
		{
			if (extension.TryGetValue(landmine, out var value))
			{
				return value.idleSoundDisabled;
			}
			return false;
		}
	}
	public class LandmineExtension
	{
		public bool idleSoundDisabled { get; set; }
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManagerPatch
	{
		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		public static void spawnLandmineInside(ref SelectableLevel newLevel)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			if (Plugin.config_UseDefaultLandmineSpawnRate.Value)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Load landmine");
			SelectableLevel obj = newLevel;
			SpawnableMapObject[] spawnableMapObjects = obj.spawnableMapObjects;
			if (obj.spawnableMapObjects.Length == 0)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Spawn landmine inside");
			SpawnableMapObject[] array = spawnableMapObjects;
			foreach (SpawnableMapObject val in array)
			{
				if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
				{
					val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
					{
						new Keyframe(0f, (float)Plugin.config_LandmineMinAmount.Value),
						new Keyframe(1f, (float)Plugin.config_LandmineMaxAmount.Value)
					});
				}
			}
		}

		[HarmonyPatch("SpawnOutsideHazards")]
		[HarmonyPrefix]
		public static void spawnLandmineOutside(RoundManager __instance)
		{
			//IL_00ca: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.config_LandmineCanSpawnOutside.Value || !((NetworkBehaviour)__instance).IsServer || !((NetworkBehaviour)__instance).IsHost || (Object)(object)__instance.currentLevel == (Object)null)
			{
				return;
			}
			Utils.OutsideLandmineMarker[] array = Object.FindObjectsByType<Utils.OutsideLandmineMarker>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				Object.Destroy((Object)(object)((Component)array[i]).gameObject);
			}
			Plugin.log.LogInfo((object)"Load landmine");
			SpawnableMapObject[] spawnableMapObjects = __instance.currentLevel.spawnableMapObjects;
			if (spawnableMapObjects == null || spawnableMapObjects.Length == 0)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Spawn landmine outside");
			SpawnableMapObject[] array2 = spawnableMapObjects;
			foreach (SpawnableMapObject val in array2)
			{
				if (!((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null))
				{
					continue;
				}
				AnimationCurve val2 = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, (float)Plugin.config_LandmineMinAmount.Value),
					new Keyframe(1f, (float)Plugin.config_LandmineMaxAmount.Value)
				});
				Transform[] shipSpawnPathPoints = __instance.shipSpawnPathPoints;
				if (shipSpawnPathPoints == null)
				{
					break;
				}
				Transform[] array3 = shipSpawnPathPoints;
				foreach (Transform val3 in array3)
				{
					int num = (int)val2.Evaluate(Random.Range(0f, 1f));
					for (int k = 0; k < num; k++)
					{
						Random random = new Random();
						NavMeshHit value = Traverse.Create((object)__instance).Field<NavMeshHit>("navHit").Value;
						Type[] array4 = new Type[6]
						{
							typeof(Vector3),
							typeof(float),
							typeof(NavMeshHit),
							typeof(Random),
							typeof(int),
							typeof(float)
						};
						MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "GetRandomNavMeshPositionInBoxPredictable", array4, (Type[])null);
						if (methodInfo != null)
						{
							object[] parameters = new object[6] { val3.position, 300f, value, random, -5, 1f };
							(Vector3, Quaternion) tuple = Utils.projectToGround((Vector3)methodInfo.Invoke(__instance, parameters));
							Vector3 item = tuple.Item1;
							Quaternion item2 = tuple.Item2;
							GameObject obj = Object.Instantiate<GameObject>(val.prefabToSpawn, item, item2);
							obj.SetActive(true);
							obj.GetComponent<NetworkObject>().Spawn(false);
							obj.AddComponent<Utils.OutsideLandmineMarker>();
						}
						else
						{
							Plugin.log.LogError((object)"FAILED TO FIND METHOD: Even with reflection and parameter counting.");
						}
					}
				}
			}
		}
	}
}