Decompiled source of Rosies Landmines v0.1.4

plugins/RosieLandMines/RosieLandMines.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using RosieLandMines.Behaviours;
using RosieLandMines.Patches;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RosieLandMines")]
[assembly: AssemblyProduct("RosieLandMines")]
[assembly: AssemblyDescription("Landmine variants, based on LootableLandmines by Procyon.")]
[assembly: AssemblyFileVersion("0.1.4")]
[assembly: AssemblyInformationalVersion("0.1.4")]
[assembly: AssemblyMetadata("HiddenNote", "You found Shery's toy box. Guided mines are a private joke for friends; mind the return address.")]
[assembly: AssemblyVersion("0.1.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 RosieLandMines
{
	internal static class AbductionAudio
	{
		private static AudioClip clip;

		internal static IEnumerator Load()
		{
			string uriString = Path.Combine(ResourcePack.Directory, "boo_laugh.ogg");
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(uriString).AbsoluteUri, (AudioType)14);
			try
			{
				yield return request.SendWebRequest();
				if ((int)request.result != 1)
				{
					Plugin.Log.LogError((object)("[Abduction] Cannot load boo_laugh.ogg: " + request.error));
					yield break;
				}
				clip = DownloadHandlerAudioClip.GetContent(request);
				Plugin.Log.LogInfo((object)$"[Abduction] Laugh loaded: {clip.length:F2}s.");
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		internal static void Play(Transform emitter, Landmine mine, double start)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (!((Object)(object)clip == (Object)null) && !((Object)(object)emitter == (Object)null))
			{
				GameObject val = new GameObject("AbductionMine.Laugh");
				val.transform.SetParent(emitter, false);
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.playOnAwake = false;
				val2.spatialize = false;
				val2.spatialBlend = 1f;
				val2.minDistance = 2f;
				val2.maxDistance = 30f;
				val2.rolloffMode = (AudioRolloffMode)1;
				if ((Object)(object)mine != (Object)null && (Object)(object)mine.mineAudio != (Object)null)
				{
					val2.outputAudioMixerGroup = mine.mineAudio.outputAudioMixerGroup;
				}
				((MonoBehaviour)ThrowRunner.Instance).StartCoroutine(PlayAt(val2, val, start));
			}
		}

		private static IEnumerator PlayAt(AudioSource audio, GameObject root, double start)
		{
			while (Tp2Mine.Now < start)
			{
				yield return null;
			}
			if (!((Object)(object)audio == (Object)null) && !((Object)(object)clip == (Object)null))
			{
				float num = Mathf.Max(0f, (float)(Tp2Mine.Now - start));
				if (num < clip.length)
				{
					audio.clip = clip;
					audio.volume = Plugin.AbductionSoundGain.Value;
					audio.time = num;
					audio.Play();
				}
				Object.Destroy((Object)(object)root, Mathf.Max(0.1f, clip.length - num) + 0.2f);
			}
		}
	}
	internal static class AbductionMine
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__Receive;
		}

		internal const int Variant = 10;

		private const string Channel = "rosie.landmines.abduction.v1";

		private static NetworkManager manager;

		private static readonly FieldInfo Armed = AccessTools.Field(typeof(Landmine), "mineActivated");

		internal static void EnsureRegistered()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			NetworkManager val = NetworkManager.Singleton;
			if ((Object)(object)val != (Object)null && !val.IsListening)
			{
				val = null;
			}
			if ((Object)(object)manager == (Object)(object)val)
			{
				return;
			}
			if ((Object)(object)manager != (Object)null && manager.CustomMessagingManager != null)
			{
				manager.CustomMessagingManager.UnregisterNamedMessageHandler("rosie.landmines.abduction.v1");
			}
			manager = val;
			if ((Object)(object)manager != (Object)null)
			{
				CustomMessagingManager customMessagingManager = manager.CustomMessagingManager;
				object obj = <>O.<0>__Receive;
				if (obj == null)
				{
					HandleNamedMessageDelegate val2 = Receive;
					<>O.<0>__Receive = val2;
					obj = (object)val2;
				}
				customMessagingManager.RegisterNamedMessageHandler("rosie.landmines.abduction.v1", (HandleNamedMessageDelegate)obj);
			}
		}

		internal unsafe static void RequestStep(CustomMine mine)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			Landmine componentInChildren = ((Component)mine).GetComponentInChildren<Landmine>();
			if ((Object)(object)componentInChildren == (Object)null || !(bool)Armed.GetValue(componentInChildren))
			{
				return;
			}
			EnsureRegistered();
			if ((Object)(object)manager == (Object)null)
			{
				return;
			}
			if (manager.IsServer)
			{
				mine.TpTarget = manager.LocalClientId;
				Activate(mine);
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(9, (Allocator)2, -1);
			try
			{
				byte b = 1;
				((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
				ulong networkObjectId = ((NetworkBehaviour)mine).NetworkObjectId;
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
				manager.CustomMessagingManager.SendNamedMessage("rosie.landmines.abduction.v1", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		internal unsafe static void Activate(CustomMine mine)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)mine).IsServer || mine.AbductionTriggered)
			{
				return;
			}
			EnsureRegistered();
			PlayerControllerB val = Tp2Mine.Player(((Object)(object)((GrabbableObject)mine).playerHeldBy != (Object)null) ? ((GrabbableObject)mine).playerHeldBy.actualClientId : mine.TpTarget);
			if ((Object)(object)val == (Object)null || val.isPlayerDead || (Object)(object)((Component)val).GetComponent<AbductionRide>() != (Object)null || (Object)(object)((Component)val).GetComponent<Tp2Sequence>() != (Object)null || (Object)(object)val.inAnimationWithEnemy != (Object)null || val.isClimbingLadder || val.inSpecialInteractAnimation)
			{
				Cancel(mine);
				Plugin.Log.LogWarning((object)"[Abduction] No available activator; mine remains in place");
				return;
			}
			if (!Landing(((Component)val).transform.position, out var feet) || !Destination(val, out var result))
			{
				Cancel(mine);
				Plugin.Log.LogWarning((object)"[Abduction] No distant solid landing found; mine remains in place");
				return;
			}
			Vector3[] array = Route(((Component)val).transform.position, result);
			float value = Plugin.AbductionHeight.Value;
			float value2 = Plugin.AbductionSpeed.Value;
			float value3 = Plugin.AbductionRise.Value;
			float value4 = Plugin.AbductionDescent.Value;
			double start = Tp2Mine.Now + 0.15;
			bool isInsideFactory = val.isInsideFactory;
			mine.AbductionTriggered = true;
			ApplyStart(((NetworkBehaviour)mine).NetworkObjectId, val.actualClientId, feet, array, start, value, value2, value3, value4, isInsideFactory);
			FastBufferWriter val2 = default(FastBufferWriter);
			foreach (ulong connectedClientsId in manager.ConnectedClientsIds)
			{
				if (connectedClientsId == manager.LocalClientId)
				{
					continue;
				}
				((FastBufferWriter)(ref val2))..ctor(2048, (Allocator)2, -1);
				try
				{
					byte b = 0;
					((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
					ulong networkObjectId = ((NetworkBehaviour)mine).NetworkObjectId;
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref val.actualClientId, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref feet);
					((FastBufferWriter)(ref val2)).WriteValueSafe<double>(ref start, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value2, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value3, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value4, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isInsideFactory, default(ForPrimitives));
					int num = array.Length;
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref num, default(ForPrimitives));
					Vector3[] array2 = array;
					for (num = 0; num < array2.Length; num++)
					{
						Vector3 val3 = array2[num];
						((FastBufferWriter)(ref val2)).WriteValueSafe(ref val3);
					}
					manager.CustomMessagingManager.SendNamedMessage("rosie.landmines.abduction.v1", connectedClientsId, val2, (NetworkDelivery)3);
				}
				finally
				{
					((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose();
				}
			}
			Plugin.Log.LogInfo((object)$"[Abduction] Start player={val.actualClientId}, distance={Vector3.Distance(array[0], result):F1}m, corners={array.Length}, inside={isInsideFactory}, destination={result}");
		}

		private static bool Destination(PlayerControllerB player, out Vector3 result)
		{
			//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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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)
			result = Vector3.zero;
			GameObject[] array = GameObject.FindGameObjectsWithTag(player.isInsideFactory ? "AINode" : "OutsideAINode");
			float value = Plugin.AbductionMinDistance.Value;
			float num = Mathf.Max(value, Plugin.AbductionMaxDistance.Value);
			float num2 = -1f;
			NavMeshHit val2 = default(NavMeshHit);
			for (int i = 0; i < 160 && array.Length != 0; i++)
			{
				Vector2 val = Random.insideUnitCircle * 4f;
				if (!NavMesh.SamplePosition(array[Random.Range(0, array.Length)].transform.position + new Vector3(val.x, 0f, val.y), ref val2, 2f, -1))
				{
					continue;
				}
				float num3 = Vector3.Distance(((Component)player).transform.position, ((NavMeshHit)(ref val2)).position);
				if (num3 < value - 0.5f || num3 > num + 0.5f || num3 < num2 - 0.5f || !Landing(((NavMeshHit)(ref val2)).position, out var feet))
				{
					continue;
				}
				float num4 = Vector3.Distance(((Component)player).transform.position, feet);
				if (num4 < value || num4 > num || num4 <= num2)
				{
					continue;
				}
				if ((Object)(object)StartOfRound.Instance.shipBounds != (Object)null)
				{
					Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
					if (((Bounds)(ref bounds)).Contains(feet))
					{
						continue;
					}
				}
				result = feet;
				num2 = num4;
			}
			return num2 >= value;
		}

		internal static bool Landing(Vector3 near, out Vector3 feet)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0144: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			feet = Vector3.zero;
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return false;
			}
			int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault;
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(near + Vector3.up * 0.6f, Vector3.down, ref val, 3f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || Vector3.Angle(((RaycastHit)(ref val)).normal, Vector3.up) > 40f || !SolidGround(((RaycastHit)(ref val)).collider))
			{
				return false;
			}
			feet = ((RaycastHit)(ref val)).point + Vector3.up * 0.08f;
			if (Physics.CheckCapsule(feet + Vector3.up * 0.4f, feet + Vector3.up * 1.5f, 0.32f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return false;
			}
			Vector3[] array = (Vector3[])(object)new Vector3[4]
			{
				Vector3.left,
				Vector3.right,
				Vector3.forward,
				Vector3.back
			};
			RaycastHit val3 = default(RaycastHit);
			foreach (Vector3 val2 in array)
			{
				if (!Physics.Raycast(feet + val2 * 0.25f + Vector3.up * 0.4f, Vector3.down, ref val3, 0.8f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !SolidGround(((RaycastHit)(ref val3)).collider) || Mathf.Abs(((RaycastHit)(ref val3)).point.y - ((RaycastHit)(ref val)).point.y) > 0.2f)
				{
					return false;
				}
			}
			Collider[] array2 = Physics.OverlapCapsule(feet + Vector3.up * 0.15f, feet + Vector3.up * 1.6f, 0.45f, -1, (QueryTriggerInteraction)2);
			foreach (Collider val4 in array2)
			{
				if ((Object)(object)((Component)val4).GetComponentInParent<KillLocalPlayer>() != (Object)null || (Object)(object)((Component)val4).GetComponentInParent<QuicksandTrigger>() != (Object)null)
				{
					return false;
				}
			}
			return true;
		}

		private static bool SolidGround(Collider c)
		{
			if ((Object)(object)c != (Object)null && !c.isTrigger && (Object)(object)c.attachedRigidbody == (Object)null && (Object)(object)((Component)c).GetComponentInParent<PlayerControllerB>() == (Object)null && (Object)(object)((Component)c).GetComponentInParent<EnemyAI>() == (Object)null && (Object)(object)((Component)c).GetComponentInParent<GrabbableObject>() == (Object)null && (Object)(object)((Component)c).GetComponentInParent<KillLocalPlayer>() == (Object)null && (Object)(object)((Component)c).GetComponentInParent<QuicksandTrigger>() == (Object)null)
			{
				return (Object)(object)((Component)c).GetComponentInParent<DoorLock>() == (Object)null;
			}
			return false;
		}

		private static Vector3[] Route(Vector3 origin, Vector3 destination)
		{
			//IL_0006: 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)
			//IL_0013: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0042: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3> { origin };
			NavMeshPath val = new NavMeshPath();
			NavMeshHit val2 = default(NavMeshHit);
			NavMeshHit val3 = default(NavMeshHit);
			if (NavMesh.SamplePosition(origin, ref val2, 3f, -1) && NavMesh.SamplePosition(destination, ref val3, 2f, -1) && NavMesh.CalculatePath(((NavMeshHit)(ref val2)).position, ((NavMeshHit)(ref val3)).position, -1, val) && (int)val.status == 0 && val.corners.Length < 60)
			{
				float num = 0f;
				Vector3 val4 = origin;
				Vector3[] corners = val.corners;
				foreach (Vector3 val5 in corners)
				{
					num += Vector3.Distance(val4, val5);
					val4 = val5;
				}
				if (num <= Mathf.Max(80f, Vector3.Distance(origin, destination) * 2.5f))
				{
					corners = val.corners;
					foreach (Vector3 val6 in corners)
					{
						if (Vector3.Distance(list[list.Count - 1], val6) > 0.5f)
						{
							list.Add(val6 + Vector3.up * 0.08f);
						}
					}
				}
			}
			list.Add(destination);
			return list.ToArray();
		}

		private static void ApplyStart(ulong mineId, ulong playerId, Vector3 recovery, Vector3[] points, double start, float height, float speed, float rise, float down, bool inside)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = Tp2Mine.Player(playerId);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent<AbductionRide>() != (Object)null))
			{
				CustomMine m = null;
				if (manager.SpawnManager.SpawnedObjects.TryGetValue(mineId, out var value))
				{
					m = ((Component)value).GetComponent<CustomMine>();
				}
				((Component)val).gameObject.AddComponent<AbductionRide>().Initialize(m, mineId, val, recovery, points, start, height, speed, rise, down, inside);
			}
		}

		private static void Receive(ulong sender, FastBufferReader reader)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			byte b = default(byte);
			((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
			ulong num = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives));
			if (manager.IsServer)
			{
				if (b != 1)
				{
					return;
				}
				PlayerControllerB val = Tp2Mine.Player(sender);
				if (manager.SpawnManager.SpawnedObjects.TryGetValue(num, out var value) && !((Object)(object)val == (Object)null) && !val.isPlayerDead)
				{
					CustomMine component = ((Component)value).GetComponent<CustomMine>();
					Landmine componentInChildren = ((Component)value).GetComponentInChildren<Landmine>();
					if (!((Object)(object)component == (Object)null) && !((Object)(object)componentInChildren == (Object)null) && component.Variant == 10 && !((GrabbableObject)component).isHeld && ((GrabbableObject)component).hasHitGround && !component.RequestPending && !(Vector3.Distance(((Component)val).transform.position, ((Component)component).transform.position) > 3f) && (bool)Armed.GetValue(componentInChildren))
					{
						component.TpTarget = sender;
						Activate(component);
					}
				}
			}
			else
			{
				if (sender != 0L)
				{
					return;
				}
				if (b == 3)
				{
					if (manager.SpawnManager.SpawnedObjects.TryGetValue(num, out var value2))
					{
						((Component)value2).GetComponent<CustomMine>()?.CancelAbductionAttempt();
					}
					return;
				}
				ulong num2 = default(ulong);
				((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives));
				switch (b)
				{
				case 0:
				{
					Vector3 recovery = default(Vector3);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref recovery);
					double start = default(double);
					((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref start, default(ForPrimitives));
					float height = default(float);
					((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref height, default(ForPrimitives));
					float speed = default(float);
					((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref speed, default(ForPrimitives));
					float rise = default(float);
					((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref rise, default(ForPrimitives));
					float down = default(float);
					((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref down, default(ForPrimitives));
					bool inside = default(bool);
					((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inside, default(ForPrimitives));
					int num3 = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num3, default(ForPrimitives));
					if (num3 >= 2 && num3 <= 64)
					{
						Vector3[] array = (Vector3[])(object)new Vector3[num3];
						for (int i = 0; i < num3; i++)
						{
							((FastBufferReader)(ref reader)).ReadValueSafe(ref array[i]);
						}
						ApplyStart(num, num2, recovery, array, start, height, speed, rise, down, inside);
					}
					break;
				}
				case 2:
				{
					Vector3 position = default(Vector3);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
					PlayerControllerB val2 = Tp2Mine.Player(num2);
					AbductionRide abductionRide = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<AbductionRide>() : null);
					if ((Object)(object)abductionRide != (Object)null && abductionRide.MineId == num)
					{
						abductionRide.Finish(position);
					}
					break;
				}
				}
			}
		}

		private unsafe static void Cancel(CustomMine mine)
		{
			//IL_004d: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			mine.CancelAbductionAttempt();
			if ((Object)(object)manager == (Object)null)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			foreach (ulong connectedClientsId in manager.ConnectedClientsIds)
			{
				if (connectedClientsId != manager.LocalClientId)
				{
					((FastBufferWriter)(ref val))..ctor(9, (Allocator)2, -1);
					try
					{
						byte b = 3;
						((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
						ulong networkObjectId = ((NetworkBehaviour)mine).NetworkObjectId;
						((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
						manager.CustomMessagingManager.SendNamedMessage("rosie.landmines.abduction.v1", connectedClientsId, val, (NetworkDelivery)3);
					}
					finally
					{
						((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
		}

		internal unsafe static void Complete(AbductionRide ride, Vector3 destination, Vector3 recovery)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			if (!Landing(destination, out var feet))
			{
				bool flag = false;
				for (int i = 0; i < 24; i++)
				{
					if (flag)
					{
						break;
					}
					Vector2 val = Random.insideUnitCircle * 3f;
					flag = Landing(destination + new Vector3(val.x, 0f, val.y), out feet);
				}
				if (!flag && !Landing(recovery, out feet))
				{
					feet = recovery;
				}
				ManualLogSource log = Plugin.Log;
				Vector3 val2 = feet;
				log.LogWarning((object)("[Abduction] Landing changed; using alternate solid point " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString()));
			}
			FastBufferWriter val3 = default(FastBufferWriter);
			foreach (ulong connectedClientsId in manager.ConnectedClientsIds)
			{
				if (connectedClientsId != manager.LocalClientId)
				{
					((FastBufferWriter)(ref val3))..ctor(32, (Allocator)2, -1);
					try
					{
						byte b = 2;
						((FastBufferWriter)(ref val3)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
						((FastBufferWriter)(ref val3)).WriteValueSafe<ulong>(ref ride.MineId, default(ForPrimitives));
						((FastBufferWriter)(ref val3)).WriteValueSafe<ulong>(ref ride.PlayerId, default(ForPrimitives));
						((FastBufferWriter)(ref val3)).WriteValueSafe(ref feet);
						manager.CustomMessagingManager.SendNamedMessage("rosie.landmines.abduction.v1", connectedClientsId, val3, (NetworkDelivery)3);
					}
					finally
					{
						((IDisposable)(*(FastBufferWriter*)(&val3))/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
			ride.Finish(feet);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal static class AbductionMovement
	{
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Movement(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo move = AccessTools.Method(typeof(CharacterController), "Move", new Type[1] { typeof(Vector3) }, (Type[])null);
			int count = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, move))
				{
					instruction.opcode = OpCodes.Call;
					instruction.operand = AccessTools.Method(typeof(AbductionMovement), "Move", (Type[])null, (Type[])null);
					count++;
				}
				yield return instruction;
			}
			if (count != 1)
			{
				throw new InvalidOperationException("Abduction expected one CharacterController.Move call; found " + count);
			}
		}

		private static CollisionFlags Move(CharacterController controller, Vector3 delta)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			AbductionRide component = ((Component)controller).GetComponent<AbductionRide>();
			CardEscapeSequence component2 = ((Component)controller).GetComponent<CardEscapeSequence>();
			if (((Object)(object)component != (Object)null && component.Active) || ((Object)(object)component2 != (Object)null && component2.Active))
			{
				return (CollisionFlags)0;
			}
			return controller.Move(delta);
		}
	}
	internal sealed class AbductionRide : MonoBehaviour
	{
		internal ulong MineId;

		internal ulong PlayerId;

		internal bool Firework;

		internal bool FireworkLeaveBody;

		private PlayerControllerB player;

		private CustomMine mine;

		private Vector3 recovery;

		private Vector3[] points;

		private float[] lengths;

		private double start;

		private float height;

		private float rise;

		private float down;

		private float travel;

		private float distance;

		private bool initialized;

		private bool finished;

		private bool completing;

		private bool oldMove;

		private bool oldInteract;

		private bool oldSpecial;

		private bool oldInside;

		private bool oldElevator;

		private bool oldHangar;

		private bool inside;

		private float stamina;

		private readonly Dictionary<Collider, bool> collisions = new Dictionary<Collider, bool>();

		private readonly Dictionary<Renderer, bool> visorVisibility = new Dictionary<Renderer, bool>();

		internal bool Active
		{
			get
			{
				if (initialized)
				{
					return !finished;
				}
				return false;
			}
		}

		internal void Initialize(CustomMine m, ulong id, PlayerControllerB p, Vector3 safe, Vector3[] path, double time, float h, float speed, float up, float descent, bool interior)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			player = p;
			mine = m;
			MineId = id;
			PlayerId = p.actualClientId;
			recovery = safe;
			points = path;
			start = time;
			height = h;
			rise = up;
			down = descent;
			inside = interior;
			oldMove = p.disableMoveInput;
			oldInteract = p.disableInteract;
			oldSpecial = p.inSpecialInteractAnimation;
			if (Firework)
			{
				oldMove = false;
				oldInteract = false;
				oldSpecial = false;
			}
			oldInside = p.isInsideFactory;
			oldElevator = p.isInElevator;
			oldHangar = p.isInHangarShipRoom;
			stamina = p.sprintMeter;
			if (((NetworkBehaviour)p).IsOwner && Plugin.AbductionHideVisor.Value && (Object)(object)p.localVisor != (Object)null)
			{
				Renderer[] componentsInChildren = ((Component)p.localVisor).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val in componentsInChildren)
				{
					visorVisibility[val] = val.forceRenderingOff;
					val.forceRenderingOff = true;
				}
				Plugin.Log.LogInfo((object)("[Abduction] Hidden local visor renderers=" + visorVisibility.Count));
			}
			lengths = new float[points.Length];
			for (int j = 1; j < points.Length; j++)
			{
				distance += Vector3.Distance(points[j - 1], points[j]);
				lengths[j] = distance;
			}
			travel = Mathf.Max(0.2f, distance / Mathf.Max(1f, speed));
			Collider[] componentsInChildren2 = ((Component)p).GetComponentsInChildren<Collider>(true);
			foreach (Collider val2 in componentsInChildren2)
			{
				collisions[val2] = val2.enabled;
				val2.enabled = false;
			}
			initialized = true;
			if ((Object)(object)mine != (Object)null)
			{
				mine.BeginAbduction();
				componentsInChildren2 = ((Component)mine).GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					componentsInChildren2[i].enabled = false;
				}
				Rigidbody[] componentsInChildren3 = ((Component)mine).GetComponentsInChildren<Rigidbody>(true);
				foreach (Rigidbody obj in componentsInChildren3)
				{
					obj.isKinematic = true;
					obj.detectCollisions = false;
				}
				Landmine[] componentsInChildren4 = ((Component)mine).GetComponentsInChildren<Landmine>(true);
				for (int i = 0; i < componentsInChildren4.Length; i++)
				{
					((Behaviour)componentsInChildren4[i]).enabled = false;
				}
				AudioSource[] componentsInChildren5 = ((Component)mine).GetComponentsInChildren<AudioSource>(true);
				for (int i = 0; i < componentsInChildren5.Length; i++)
				{
					componentsInChildren5[i].Stop();
				}
				Animator[] componentsInChildren6 = ((Component)mine).GetComponentsInChildren<Animator>(true);
				for (int i = 0; i < componentsInChildren6.Length; i++)
				{
					((Behaviour)componentsInChildren6[i]).enabled = false;
				}
				((Component)mine).transform.rotation = Quaternion.Euler(((GrabbableObject)mine).itemProperties.restingRotation);
			}
			if (!Firework && (Object)(object)mine != (Object)null)
			{
				AbductionAudio.Play(((Component)mine).transform, ((Component)mine).GetComponentInChildren<Landmine>(true), start);
			}
			Lock();
			Plugin.Log.LogInfo((object)$"[Abduction] Ride ready player={PlayerId}, duration={rise + travel + down:F2}s; noclip enabled");
		}

		private void Lock()
		{
			//IL_00b5: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			player.disableMoveInput = true;
			player.disableInteract = true;
			player.inSpecialInteractAnimation = true;
			player.isInsideFactory = inside;
			player.isInElevator = (player.isInHangarShipRoom = false);
			player.fallValue = (player.fallValueUncapped = (player.averageVelocity = 0f));
			player.takingFallDamage = (player.isFallingFromJump = (player.isFallingNoJump = false));
			player.velocityLastFrame = (player.externalForces = (player.externalForceAutoFade = Vector3.zero));
			player.sprintMeter = stamina;
			player.isSinking = (player.isUnderwater = false);
			player.sinkingValue = 0f;
			player.sourcesCausingSinking = 0;
			foreach (KeyValuePair<Collider, bool> collision in collisions)
			{
				if ((Object)(object)collision.Key != (Object)null)
				{
					collision.Key.enabled = false;
				}
			}
			foreach (KeyValuePair<Renderer, bool> item in visorVisibility)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.forceRenderingOff = true;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00cc: 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)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized || finished)
			{
				return;
			}
			if ((Object)(object)player == (Object)null || player.isPlayerDead || !player.isPlayerControlled || (Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.inShipPhase)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			Lock();
			float num = Mathf.Max(0f, (float)(Tp2Mine.Now - start));
			Vector3 val = ((num < rise) ? (points[0] + Vector3.up * height * Mathf.SmoothStep(0f, 1f, num / rise)) : ((!(num < rise + travel)) ? (points[points.Length - 1] + Vector3.up * height * (Firework ? 1f : (1f - Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num - rise - travel) / down))))) : (Along(Mathf.Clamp01((num - rise) / travel) * distance) + Vector3.up * height)));
			((Component)player).transform.position = val;
			if ((Object)(object)mine != (Object)null)
			{
				((GrabbableObject)mine).parentObject = null;
				((Component)mine).transform.position = val - Vector3.up * 0.05f;
			}
			if (Firework && num >= rise + travel)
			{
				finished = true;
				TerminalFirework.Burst(val, mine);
				Restore();
				if (((NetworkBehaviour)player).IsOwner)
				{
					player.KillPlayer(Vector3.zero, FireworkLeaveBody, (CauseOfDeath)3, 0, Vector3.zero, false);
				}
				if ((Object)(object)mine != (Object)null && ((NetworkBehaviour)mine).IsServer && ((NetworkBehaviour)mine).NetworkObject.IsSpawned)
				{
					((NetworkBehaviour)mine).NetworkObject.Despawn(true);
				}
				Object.Destroy((Object)(object)this);
			}
			else if (num >= rise + travel + down && NetworkManager.Singleton.IsServer && !completing)
			{
				completing = true;
				AbductionMine.Complete(this, points[points.Length - 1], recovery);
			}
			else if (num > rise + travel + down + 6f)
			{
				Plugin.Log.LogWarning((object)"[Abduction] Finish timeout; restoring player");
				Object.Destroy((Object)(object)this);
			}
		}

		private Vector3 Along(float length)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			for (int i = 1; i < points.Length; i++)
			{
				if (length <= lengths[i])
				{
					return Vector3.Lerp(points[i - 1], points[i], (length - lengths[i - 1]) / Mathf.Max(0.001f, lengths[i] - lengths[i - 1]));
				}
			}
			return points[points.Length - 1];
		}

		internal void Finish(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!finished && !((Object)(object)player == (Object)null))
			{
				finished = true;
				player.TeleportPlayer(position, false, 0f, true, false);
				player.isInsideFactory = inside;
				player.isInElevator = (player.isInHangarShipRoom = false);
				player.serverPlayerPosition = position;
				Restore();
				if ((Object)(object)mine != (Object)null && ((NetworkBehaviour)mine).IsServer && ((NetworkBehaviour)mine).NetworkObject.IsSpawned)
				{
					((NetworkBehaviour)mine).NetworkObject.Despawn(true);
				}
				Plugin.Log.LogInfo((object)$"[Abduction] Landed player={PlayerId}, position={position}; collisions and controls restored");
				Object.Destroy((Object)(object)this);
			}
		}

		private void Restore()
		{
			//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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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)
			RestoreVisor();
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			foreach (KeyValuePair<Collider, bool> collision in collisions)
			{
				if ((Object)(object)collision.Key != (Object)null)
				{
					collision.Key.enabled = (!player.isPlayerDead || (!((Object)(object)collision.Key == (Object)(object)player.thisController) && !((Object)(object)collision.Key == (Object)(object)player.playerCollider))) && collision.Value;
				}
			}
			if (!player.isPlayerDead)
			{
				player.disableMoveInput = oldMove;
				player.disableInteract = oldInteract;
				player.inSpecialInteractAnimation = oldSpecial;
				player.fallValue = (player.fallValueUncapped = (player.averageVelocity = 0f));
				player.takingFallDamage = (player.isFallingFromJump = (player.isFallingNoJump = false));
				player.velocityLastFrame = (player.externalForces = (player.externalForceAutoFade = Vector3.zero));
				player.sprintMeter = stamina;
			}
		}

		private void RestoreVisor()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (visorVisibility.Count == 0)
			{
				return;
			}
			if ((Object)(object)player != (Object)null && !player.isPlayerDead && (Object)(object)player.localVisor != (Object)null && (Object)(object)player.localVisorTargetPoint != (Object)null)
			{
				player.localVisor.SetPositionAndRotation(player.localVisorTargetPoint.position, player.localVisorTargetPoint.rotation);
			}
			foreach (KeyValuePair<Renderer, bool> item in visorVisibility)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.forceRenderingOff = item.Value;
				}
			}
			visorVisibility.Clear();
		}

		private void OnDestroy()
		{
			//IL_003e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			if (initialized)
			{
				if (!finished && (Object)(object)player != (Object)null && !player.isPlayerDead)
				{
					((Component)player).transform.position = recovery;
					player.serverPlayerPosition = recovery;
					player.isInsideFactory = oldInside;
					player.isInElevator = oldElevator;
					player.isInHangarShipRoom = oldHangar;
					Plugin.Log.LogWarning((object)("[Abduction] Interrupted; restored at origin player=" + PlayerId));
				}
				Restore();
				if ((Object)(object)mine != (Object)null && ((NetworkBehaviour)mine).IsServer && (Object)(object)((NetworkBehaviour)mine).NetworkObject != (Object)null && ((NetworkBehaviour)mine).NetworkObject.IsSpawned)
				{
					((NetworkBehaviour)mine).NetworkObject.Despawn(true);
				}
			}
		}
	}
	internal static class AmbushAudio
	{
		internal static AudioClip Sequence;

		internal static AudioClip Wind;

		internal static readonly AudioClip[] Impacts = (AudioClip[])(object)new AudioClip[5];

		internal static IEnumerator Load()
		{
			LoadOne("sequence", delegate(AudioClip clip)
			{
				Sequence = clip;
			});
			yield return null;
			LoadOne("wind", delegate(AudioClip clip)
			{
				Wind = clip;
			});
			yield return null;
			for (int i = 0; i < 5; i++)
			{
				int index = i;
				LoadOne("impact" + i, delegate(AudioClip clip)
				{
					Impacts[index] = clip;
				});
				yield return null;
			}
			Plugin.Log.LogInfo((object)"[Ambush] Approved v5 WAV sequence/impacts loaded; wind defaults to half reference volume.");
		}

		private static void LoadOne(string name, Action<AudioClip> assign)
		{
			try
			{
				assign(ReadWav(Path.Combine(ResourcePack.Directory, "ambush", name + ".wav"), name));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[Ambush] Cannot load " + name + ": " + ex));
			}
		}

		private static AudioClip ReadWav(string path, string name)
		{
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
			if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "RIFF")
			{
				throw new InvalidDataException("Not RIFF");
			}
			binaryReader.ReadUInt32();
			if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "WAVE")
			{
				throw new InvalidDataException("Not WAV");
			}
			ushort num = 0;
			ushort num2 = 0;
			ushort num3 = 0;
			int num4 = 0;
			byte[] array = null;
			while (binaryReader.BaseStream.Position + 8 <= binaryReader.BaseStream.Length)
			{
				string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(4));
				uint num5 = binaryReader.ReadUInt32();
				long num6 = binaryReader.BaseStream.Position + num5;
				if (num6 > binaryReader.BaseStream.Length)
				{
					throw new InvalidDataException("Truncated chunk");
				}
				if (text == "fmt ")
				{
					num = binaryReader.ReadUInt16();
					num2 = binaryReader.ReadUInt16();
					num4 = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadUInt16();
					num3 = binaryReader.ReadUInt16();
				}
				else if (text == "data")
				{
					array = binaryReader.ReadBytes(checked((int)num5));
				}
				binaryReader.BaseStream.Position = num6 + num5 % 2;
			}
			if (num != 1 || num2 < 1 || num2 > 2 || num3 != 16 || num4 <= 0 || array == null || array.Length % (num2 * 2) != 0)
			{
				throw new InvalidDataException("Expected PCM16 mono/stereo");
			}
			float[] array2 = new float[array.Length / 2];
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i] = (float)(short)(array[i * 2] | (array[i * 2 + 1] << 8)) / 32768f;
			}
			AudioClip obj = AudioClip.Create("Ambush." + name, array2.Length / num2, (int)num2, num4, false);
			obj.SetData(array2, 0);
			return obj;
		}
	}
	internal sealed class AmbushSoundSession
	{
		private readonly Transform root;

		private readonly AudioSource sequence;

		private readonly AudioSource wind;

		private readonly AudioSource impact;

		private readonly AudioLowPassFilter impactFilter;

		private AudioLowPassFilter ears;

		private bool ownEars;

		private bool oldEnabled;

		private bool played;

		private bool impactPlayed;

		private float oldCutoff;

		private float oldResonance;

		private double impactAt = -1.0;

		private float impactGain;

		internal AmbushSoundSession(Transform root)
		{
			this.root = root;
			sequence = Source("ApprovedSequence", bypassListener: true);
			wind = Source("QuietWind", bypassListener: false);
			impact = Source("LocalImpact", bypassListener: true);
			impactFilter = ((Component)impact).gameObject.AddComponent<AudioLowPassFilter>();
			((Behaviour)impactFilter).enabled = false;
			wind.clip = AmbushAudio.Wind;
			wind.loop = true;
			wind.volume = 0f;
			if ((Object)(object)wind.clip != (Object)null)
			{
				wind.Play();
			}
		}

		private AudioSource Source(string name, bool bypassListener)
		{
			//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)
			GameObject val = new GameObject("Ambush." + name);
			val.transform.SetParent(root, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.spatialBlend = 0f;
			obj.spatialize = false;
			obj.bypassListenerEffects = bypassListener;
			obj.bypassReverbZones = true;
			return obj;
		}

		internal void Tick(double sequenceAge, Vector3 comet, Vector3 impactPoint, bool inside)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			float value = Plugin.AmbushVolume.Value;
			sequence.volume = value * (inside ? 0.24f : 1f);
			if ((Object)(object)val != (Object)null && (Object)(object)val.gameplayCamera != (Object)null)
			{
				Vector3 val2 = comet - ((Component)val.gameplayCamera).transform.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				sequence.panStereo = Mathf.Clamp(Vector3.Dot(((Component)val.gameplayCamera).transform.right, normalized) * 0.3f, -0.3f, 0.3f);
			}
			if (!played && sequenceAge >= 0.0 && (Object)(object)AmbushAudio.Sequence != (Object)null)
			{
				played = true;
				if (sequenceAge < (double)AmbushAudio.Sequence.length)
				{
					sequence.clip = AmbushAudio.Sequence;
					sequence.time = (float)sequenceAge;
					sequence.Play();
				}
			}
			float num = ((sequenceAge > 12.836598639) ? Mathf.Clamp01(1f - (float)(sequenceAge - 12.836598639) / 2f) : 1f);
			wind.volume = value * Plugin.AmbushWindVolume.Value * (inside ? 0.3f : 1f) * num;
			float num2 = (float)Math.Max(0.0, Math.Min(1.0, (sequenceAge - 4.061496599) / 0.35));
			num2 *= (float)(1.0 - Math.Max(0.0, Math.Min(1.0, (sequenceAge - 6.961496599) / 0.65)));
			Muffle(num2);
			if (impactAt >= 0.0 && !impactPlayed && sequenceAge >= impactAt)
			{
				impactPlayed = true;
				if ((Object)(object)impact.clip != (Object)null)
				{
					impact.volume = value * impactGain;
					impact.Play();
				}
			}
		}

		internal void Impact(Vector3 point, bool sheltered)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			float num = (((Object)(object)val != (Object)null) ? Vector3.Distance(((Component)val).transform.position, point) : 0f);
			bool flag = num <= Plugin.AmbushNearDistance.Value;
			int[] array = ((!flag) ? new int[2] { 1, 3 } : new int[3] { 0, 2, 4 });
			int num2 = array[Random.Range(0, array.Length)];
			impact.clip = AmbushAudio.Impacts[num2];
			impactAt = 12.836598639 + (double)Mathf.Clamp(num / 343f, 0f, 0.8f);
			impactGain = (flag ? 1f : 0.52f);
			((Behaviour)impactFilter).enabled = sheltered || !flag;
			impactFilter.cutoffFrequency = (sheltered ? 950f : 1800f);
			if (sheltered)
			{
				impactGain *= 0.45f;
			}
			Plugin.Log.LogInfo((object)$"[Ambush] Local impact{num2}, distance={num:F1}m, sheltered={sheltered}.");
		}

		private void Muffle(float amount)
		{
			if (amount <= 0.0001f)
			{
				RestoreEars();
				return;
			}
			if ((Object)(object)ears == (Object)null)
			{
				AudioListener val = null;
				AudioListener[] array = Object.FindObjectsOfType<AudioListener>();
				foreach (AudioListener val2 in array)
				{
					if (((Behaviour)val2).enabled && ((Component)val2).gameObject.activeInHierarchy)
					{
						val = val2;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				ears = ((Component)val).GetComponent<AudioLowPassFilter>();
				ownEars = (Object)(object)ears == (Object)null;
				if (ownEars)
				{
					ears = ((Component)val).gameObject.AddComponent<AudioLowPassFilter>();
				}
				oldEnabled = ((Behaviour)ears).enabled;
				oldCutoff = ears.cutoffFrequency;
				oldResonance = ears.lowpassResonanceQ;
			}
			((Behaviour)ears).enabled = true;
			ears.cutoffFrequency = Mathf.Min((oldEnabled && !ownEars) ? oldCutoff : 22000f, Mathf.Lerp(22000f, 550f, amount));
			ears.lowpassResonanceQ = 1f;
		}

		private void RestoreEars()
		{
			if (!((Object)(object)ears == (Object)null))
			{
				if (ownEars)
				{
					Object.Destroy((Object)(object)ears);
				}
				else
				{
					ears.cutoffFrequency = oldCutoff;
					ears.lowpassResonanceQ = oldResonance;
					((Behaviour)ears).enabled = oldEnabled;
				}
				ears = null;
			}
		}

		internal void Cleanup()
		{
			RestoreEars();
		}
	}
	internal static class AmbushMine
	{
		private sealed class Event
		{
			internal ulong Id;

			internal int Seed;

			internal Vector3 Position;

			internal Vector3 Launch;

			internal Vector3 OrbitCenter;

			internal double Start;

			internal float Duration;

			internal float Diameter;

			internal float ExplosionScale;

			internal float DeathDelay;

			internal AmbushTrajectory Path;

			internal GameObject Root;

			internal GameObject Comet;

			internal GameObject Ui;

			internal TrailRenderer Trail;

			internal LineRenderer Wave;

			internal LineRenderer Ring1;

			internal LineRenderer Ring2;

			internal Material Red;

			internal Material White;

			internal HDAdditionalLightData Light;

			internal AmbushSoundSession Sound;

			internal Volume Volume;

			internal VolumeProfile Profile;

			internal ColorAdjustments Grade;

			internal TMP_Text Banner;

			internal RawImage Flash;

			internal bool ImpactShown;

			internal bool Verdict;

			internal bool Killed;

			internal bool LocalExposed;

			internal int Bursts;

			internal readonly HashSet<ulong> Victims = new HashSet<ulong>();
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__Receive;
		}

		internal const int Variant = 14;

		private const string Channel = "rosie.landmines.ambush.v3";

		private static NetworkManager manager;

		private static Event active;

		private static Event pending;

		private static double nextAvailable;

		private static bool requested;

		private static double Now
		{
			get
			{
				//IL_0019: 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)
				if (!((Object)(object)manager != (Object)null))
				{
					return Time.realtimeSinceStartup;
				}
				NetworkTime serverTime = manager.ServerTime;
				return ((NetworkTime)(ref serverTime)).Time;
			}
		}

		private static bool RoundActive
		{
			get
			{
				if ((Object)(object)StartOfRound.Instance != (Object)null)
				{
					return !StartOfRound.Instance.inShipPhase;
				}
				return false;
			}
		}

		internal unsafe static void Tick()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_091a: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0980: Unknown result type (might be due to invalid IL or missing references)
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager val = NetworkManager.Singleton;
			if ((Object)(object)val != (Object)null && !val.IsListening)
			{
				val = null;
			}
			if ((Object)(object)manager != (Object)(object)val)
			{
				if ((Object)(object)manager != (Object)null && manager.CustomMessagingManager != null)
				{
					manager.CustomMessagingManager.UnregisterNamedMessageHandler("rosie.landmines.ambush.v3");
				}
				Cleanup();
				pending = null;
				manager = val;
				nextAvailable = 0.0;
				requested = false;
				if ((Object)(object)manager != (Object)null)
				{
					CustomMessagingManager customMessagingManager = manager.CustomMessagingManager;
					object obj = <>O.<0>__Receive;
					if (obj == null)
					{
						HandleNamedMessageDelegate val2 = Receive;
						<>O.<0>__Receive = val2;
						obj = (object)val2;
					}
					customMessagingManager.RegisterNamedMessageHandler("rosie.landmines.ambush.v3", (HandleNamedMessageDelegate)obj);
				}
			}
			if ((Object)(object)manager == (Object)null)
			{
				return;
			}
			if (!RoundActive)
			{
				Cleanup();
				pending = null;
				nextAvailable = 0.0;
				requested = false;
				return;
			}
			if (!manager.IsServer && !requested && manager.IsConnectedClient && RoundActive && (Object)(object)GameNetworkManager.Instance?.localPlayerController != (Object)null)
			{
				requested = true;
				FastBufferWriter val3 = default(FastBufferWriter);
				((FastBufferWriter)(ref val3))..ctor(1, (Allocator)2, -1);
				try
				{
					byte b = 3;
					((FastBufferWriter)(ref val3)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
					manager.CustomMessagingManager.SendNamedMessage("rosie.landmines.ambush.v3", 0uL, val3, (NetworkDelivery)3);
				}
				finally
				{
					((IDisposable)(*(FastBufferWriter*)(&val3))/*cast due to .constrained prefix*/).Dispose();
				}
			}
			if (manager.IsServer && active == null && pending != null && Now >= nextAvailable)
			{
				Event e = pending;
				pending = null;
				BeginEvent(e);
			}
			if (active == null)
			{
				return;
			}
			Event obj2 = active;
			float num = Mathf.Max(0f, (float)(Now - obj2.Start));
			double num2 = (double)obj2.Duration - 12.836598639;
			double num3 = (double)num - num2;
			float num4 = num - obj2.Duration;
			AmbushTrajectory.Point launch = new AmbushTrajectory.Point(obj2.Launch.x - obj2.Position.x, obj2.Launch.y - obj2.Position.y, obj2.Launch.z - obj2.Position.z);
			AmbushTrajectory.Point point = AmbushMotion.Sample(obj2.Path, launch, num3);
			obj2.Sound?.Tick(num3, obj2.Position + Point(point), obj2.Position, (Object)(object)GameNetworkManager.Instance?.localPlayerController != (Object)null && GameNetworkManager.Instance.localPlayerController.isInsideFactory);
			if (num4 > 6f)
			{
				Cleanup();
				return;
			}
			PlayerControllerB val4 = GameNetworkManager.Instance?.localPlayerController;
			bool flag = (Object)(object)val4 != (Object)null && val4.isInsideFactory;
			if ((Object)(object)obj2.Ui == (Object)null && (Object)(object)HUDManager.Instance != (Object)null)
			{
				BuildUi(obj2);
			}
			if ((Object)(object)obj2.Banner != (Object)null)
			{
				((Component)obj2.Banner).gameObject.SetActive(num4 < 0f);
				obj2.Banner.text = ((num < 1.5f) ? "EVACUATE IMMEDIATELY" : ((num3 < 0.0) ? ("VALSTRAX AMBUSH\n" + Mathf.CeilToInt((float)(0.0 - num3))) : "VALSTRAX AMBUSH"));
			}
			if ((Object)(object)obj2.Volume != (Object)null)
			{
				float num5 = ((num4 < 0f) ? Mathf.Clamp01(num / 2f) : Mathf.Clamp01(1f - num4 / 5f));
				obj2.Volume.weight = ((flag || Plugin.AmbushSky.Value <= 0f) ? 0f : num5);
			}
			if (num4 < 0f)
			{
				Vector3 position = obj2.Position + Point(point);
				Vector3 val5 = Point(AmbushMotion.Sample(obj2.Path, launch, num3 + 0.003)) - Point(point);
				bool flag2 = AmbushMotion.Visible(num3);
				if ((Object)(object)obj2.Comet != (Object)null)
				{
					obj2.Comet.transform.position = position;
					if (((Vector3)(ref val5)).sqrMagnitude > 0.0001f)
					{
						obj2.Comet.transform.rotation = Quaternion.LookRotation(val5);
					}
					float num6 = ((num3 < 6.811496599) ? 22f : obj2.Diameter) * (float)point.Scale;
					obj2.Comet.transform.localScale = new Vector3(num6 * 0.65f, num6 * 0.65f, num6);
					if (flag2 && !obj2.Comet.activeSelf && (Object)(object)obj2.Trail != (Object)null)
					{
						obj2.Trail.Clear();
					}
					obj2.Comet.SetActive(flag2);
					if ((Object)(object)obj2.Trail != (Object)null)
					{
						obj2.Trail.widthMultiplier = Mathf.Max(0.2f, num6 * 0.35f);
					}
					if ((Object)(object)obj2.Light != (Object)null)
					{
						obj2.Light.SetIntensity(Mathf.Lerp(15000f, 250000f, Mathf.Clamp01((float)((num3 - 9.634331066) / 3.2022675730000003))), (LightUnit)1);
					}
				}
				Ring(obj2, obj2.Ring1, launch, num3, 9.634331066, 30f);
				Ring(obj2, obj2.Ring2, launch, num3, 12.486598639, 45f);
				return;
			}
			if (manager.IsServer && !obj2.Verdict)
			{
				Decide(obj2);
			}
			if (!obj2.ImpactShown)
			{
				obj2.ImpactShown = true;
				obj2.LocalExposed = (Object)(object)val4 != (Object)null && !Safe(val4);
				if ((Object)(object)obj2.Ring1 != (Object)null)
				{
					((Renderer)obj2.Ring1).enabled = false;
				}
				if ((Object)(object)obj2.Ring2 != (Object)null)
				{
					((Renderer)obj2.Ring2).enabled = false;
				}
				if ((Object)(object)obj2.Light != (Object)null)
				{
					((Component)obj2.Light).transform.SetParent(obj2.Root.transform, true);
					((Component)obj2.Light).transform.position = obj2.Position + Vector3.up * 15f;
					obj2.Light.SetRange(300f);
				}
				if ((Object)(object)obj2.Comet != (Object)null)
				{
					obj2.Comet.SetActive(false);
				}
				obj2.Sound?.Impact(obj2.Position, (Object)(object)val4 != (Object)null && Safe(val4));
				if ((Object)(object)val4 != (Object)null && !val4.isPlayerDead && (Object)(object)HUDManager.Instance != (Object)null)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)(obj2.LocalExposed ? 3 : 0));
				}
				if (obj2.LocalExposed && (Object)(object)val4 != (Object)null)
				{
					for (int i = 0; i < 3; i++)
					{
						Burst(((Component)val4).transform.position + ((Component)val4).transform.forward * (float)(10 + i * 12) + Vector3.right * (float)((i - 1) * 12), obj2.ExplosionScale * 0.4f);
					}
				}
			}
			Vector3 val6 = default(Vector3);
			while (obj2.Bursts < 6 && num4 >= (float)obj2.Bursts * 0.18f)
			{
				int num7 = obj2.Bursts++;
				double num8 = new Random(obj2.Seed + num7 * 713).NextDouble() * Math.PI * 2.0;
				float num9 = ((num7 == 0) ? 0f : (15f + (float)num7 * 11f));
				((Vector3)(ref val6))..ctor((float)Math.Cos(num8) * num9, (num7 % 2 == 0) ? ((float)num7 * 6f) : 0f, (float)Math.Sin(num8) * num9);
				Burst(obj2.Position + val6, obj2.ExplosionScale * ((num7 == 0) ? 1.5f : 0.7f));
			}
			if ((Object)(object)obj2.Light != (Object)null)
			{
				obj2.Light.SetIntensity(800000f * Mathf.Clamp01(1f - num4 / 2f), (LightUnit)1);
			}
			if ((Object)(object)obj2.Wave != (Object)null)
			{
				float num10 = Mathf.Clamp01(num4 / 1.2f) * 300f;
				((Renderer)obj2.Wave).enabled = num4 < 1.2f;
				for (int j = 0; j < 97; j++)
				{
					float num11 = (float)j / 96f * (float)Math.PI * 2f;
					obj2.Wave.SetPosition(j, obj2.Position + new Vector3(Mathf.Cos(num11) * num10, 0.8f, Mathf.Sin(num11) * num10));
				}
			}
			if ((Object)(object)obj2.Flash != (Object)null)
			{
				((Graphic)obj2.Flash).color = new Color(1f, 0.82f, 0.8f, Mathf.Clamp01(1f - num4 / 0.7f) * (obj2.LocalExposed ? 0.72f : 0.08f));
			}
			if (obj2.Verdict && !obj2.Killed && num4 >= obj2.DeathDelay && (Object)(object)val4 != (Object)null && ((NetworkBehaviour)val4).IsOwner)
			{
				obj2.Killed = true;
				if (obj2.Victims.Contains(val4.actualClientId) && !val4.isPlayerDead)
				{
					val4.KillPlayer(Vector3.zero, true, (CauseOfDeath)3, 0, Vector3.zero, false);
				}
			}
		}

		internal static void Activate(CustomMine mine)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			Tick();
			if ((Object)(object)manager == (Object)null || !manager.IsServer || mine.AmbushTriggered)
			{
				return;
			}
			mine.AmbushTriggered = true;
			PlayerControllerB val = MineActivator.Resolve(mine);
			EnemyAI val2 = EnemyMineEffects.Find(mine.EnemyActivator);
			Vector3 position = ((Component)mine).transform.position;
			bool insideFacility = (((Object)(object)val != (Object)null) ? val.isInsideFactory : (((Object)(object)val2 != (Object)null) ? (!val2.isOutside) : ((GrabbableObject)mine).isInFactory));
			Bounds bounds;
			int num;
			if ((Object)(object)StartOfRound.Instance.shipBounds != (Object)null)
			{
				bounds = StartOfRound.Instance.shipBounds.bounds;
				num = (((Bounds)(ref bounds)).Contains(position) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool insideShip = (byte)num != 0;
			if (!AmbushRules.CanStart(insideFacility, insideShip))
			{
				Plugin.Log.LogInfo((object)"[Ambush] Interior/ship activation consumed harmlessly; comet is outdoor-only.");
				mine.Cleanup();
				return;
			}
			if (active != null)
			{
				Plugin.Log.LogInfo((object)"[Ambush] Activation joined the current event; no ordinary explosion.");
				mine.Cleanup();
				return;
			}
			Vector3 val3;
			if (!((Object)(object)StartOfRound.Instance.shipBounds != (Object)null))
			{
				val3 = position;
			}
			else
			{
				bounds = StartOfRound.Instance.shipBounds.bounds;
				val3 = ((Bounds)(ref bounds)).center;
			}
			Vector3 orbitCenter = val3;
			Vector3 position2 = ShipImpact(position);
			Event e = new Event
			{
				Id = ((NetworkBehaviour)mine).NetworkObjectId,
				Seed = Random.Range(1, int.MaxValue),
				Position = position2,
				OrbitCenter = orbitCenter,
				Start = Now + 0.2,
				Duration = Plugin.AmbushWarning.Value + 12.836598f,
				Launch = LaunchPoint(position),
				Diameter = Plugin.AmbushDiameter.Value,
				ExplosionScale = Plugin.AmbushExplosionScale.Value,
				DeathDelay = Plugin.AmbushDeathDelay.Value
			};
			mine.Cleanup();
			if (Now < nextAvailable)
			{
				if (pending == null)
				{
					pending = e;
				}
				Plugin.Log.LogInfo((object)$"[Ambush] Outdoor activation queued/coalesced; cooldown remaining={nextAvailable - Now:F1}s. No ordinary explosion.");
			}
			else
			{
				BeginEvent(e);
			}
		}

		private static void BeginEvent(Event e)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			e.Start = Now + 0.2;
			nextAvailable = e.Start + (double)e.Duration + (double)Plugin.AmbushCooldown.Value;
			Start(e);
			foreach (ulong connectedClientsId in manager.ConnectedClientsIds)
			{
				if (connectedClientsId != manager.LocalClientId)
				{
					SendStart(connectedClientsId, e);
				}
			}
			Plugin.Log.LogInfo((object)$"[Ambush] Started at {e.Position}, seed={e.Seed}, head-start={(double)e.Duration - 12.836598639:F2}s, impact-after={e.Duration:F2}s, diameter={e.Diameter}m.");
		}

		private static Vector3 LaunchPoint(Vector3 impact)
		{
			//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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = impact;
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			foreach (EntranceTeleport val2 in array)
			{
				if (val2.entranceId == 0 && val2.isEntranceToBuilding && (Object)(object)val2.entrancePoint != (Object)null)
				{
					val = val2.entrancePoint.position;
					break;
				}
			}
			Vector3 val3;
			if (!((Object)(object)StartOfRound.Instance.shipBounds != (Object)null))
			{
				val3 = impact - Vector3.forward * 50f;
			}
			else
			{
				Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
				val3 = ((Bounds)(ref bounds)).center;
			}
			Vector3 val4 = val3;
			Vector3 val5 = val - val4;
			val5.y = 0f;
			if (((Vector3)(ref val5)).sqrMagnitude < 1f)
			{
				val5 = Vector3.forward;
			}
			Vector3 val6 = val + ((Vector3)(ref val5)).normalized * 120f;
			RaycastHit val7 = default(RaycastHit);
			if (Physics.Raycast(val6 + Vector3.up * 200f, Vector3.down, ref val7, 400f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				val6.y = ((RaycastHit)(ref val7)).point.y;
			}
			return val6 + Vector3.up * 12f;
		}

		private static Vector3 ShipImpact(Vector3 fallback)
		{
			//IL_0022: 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_002f: 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_0037: 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_0041: 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)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance.outsideDoorPosition == (Object)null || (Object)(object)instance.middleOfShipNode == (Object)null)
			{
				return fallback;
			}
			Vector3 position = instance.outsideDoorPosition.position;
			Vector3 val = position - instance.middleOfShipNode.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				return fallback;
			}
			Vector3 val2 = position + ((Vector3)(ref val)).normalized * 30f;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2 + Vector3.up * 100f, Vector3.down, ref val3, 250f, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val3)).point;
			}
			return new Vector3(val2.x, position.y, val2.z);
		}

		private static LineRenderer CreateRing(Event e, string name)
		{
			//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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(e.Root.transform, false);
			LineRenderer obj = val.AddComponent<LineRenderer>();
			((Renderer)obj).sharedMaterial = e.White;
			obj.positionCount = 65;
			obj.useWorldSpace = true;
			((Renderer)obj).enabled = false;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			return obj;
		}

		private static void Ring(Event e, LineRenderer line, AmbushTrajectory.Point launch, double time, double began, float radius)
		{
			//IL_0049: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)line == (Object)null)
			{
				return;
			}
			double num = time - began;
			((Renderer)line).enabled = num >= 0.0 && num < 0.75;
			if (((Renderer)line).enabled)
			{
				AmbushTrajectory.Point point = AmbushMotion.Sample(e.Path, launch, began);
				Vector3 val = e.Position + Point(point);
				Vector3 val2 = Point(AmbushMotion.Sample(e.Path, launch, began + 0.003)) - Point(point);
				Quaternion val3 = Quaternion.LookRotation((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? val2 : Vector3.up);
				float num2 = (float)(num / 0.75);
				line.widthMultiplier = 2f * (1f - num2);
				for (int i = 0; i < 65; i++)
				{
					float num3 = (float)i / 64f * (float)Math.PI * 2f;
					line.SetPosition(i, val + val3 * new Vector3(Mathf.Cos(num3), Mathf.Sin(num3), 0f) * Mathf.Lerp(1f, radius, num2));
				}
			}
		}

		private static bool Safe(PlayerControllerB player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_003f: 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)
			StartOfRound instance = StartOfRound.Instance;
			int num;
			if (!player.isInHangarShipRoom)
			{
				if ((Object)(object)instance.shipBounds != (Object)null)
				{
					Bounds bounds = instance.shipBounds.bounds;
					num = (((Bounds)(ref bounds)).Contains(((Component)player).transform.position + Vector3.up * 0.4f) ? 1 : 0);
				}
				else
				{
					num = 0;
				}
			}
			else
			{
				num = 1;
			}
			bool insideShip = (byte)num != 0;
			return AmbushRules.Safe(player.isInsideFactory, insideShip, instance.hangarDoorsClosed);
		}

		private static void Decide(Event e)
		{
			e.Verdict = true;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead)
				{
					bool flag = Safe(val);
					if (!flag)
					{
						e.Victims.Add(val.actualClientId);
					}
					Plugin.Log.LogInfo((object)$"[Ambush] Impact exposure player={val.playerUsername}, safe={flag}, inside={val.isInsideFactory}, ship={val.isInHangarShipRoom}, doorsClosed={StartOfRound.Instance.hangarDoorsClosed}.");
				}
			}
			foreach (ulong connectedClientsId in manager.ConnectedClientsIds)
			{
				if (connectedClientsId != manager.LocalClientId)
				{
					SendVerdict(connectedClientsId, e);
				}
			}
		}

		private static void Start(Event e)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Expected O, but got Unknown
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Expected O, but got Unknown
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			if (active != null && active.Id == e.Id)
			{
				return;
			}
			Cleanup();
			active = e;
			Vector3 val = e.OrbitCenter - e.Position;
			e.Path = new AmbushTrajectory(e.Seed, new AmbushTrajectory.Point(val.x, val.y, val.z));
			if (manager.SpawnManager.SpawnedObjects.TryGetValue(e.Id, out var value))
			{
				CustomMine component = ((Component)value).GetComponent<CustomMine>();
				if ((Object)(object)component != (Object)null)
				{
					component.BeginAbduction();
					Renderer[] componentsInChildren = ((Component)component).GetComponentsInChildren<Renderer>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].forceRenderingOff = true;
					}
				}
			}
			e.Root = new GameObject("ValstraxAmbush.Effects");
			e.Red = Material(new Color(10f, 0.03f, 0.08f));
			e.White = Material(new Color(20f, 12f, 12f));
			e.Comet = Sphere("CrimsonComet", e.Root.transform, e.Red);
			e.Comet.transform.position = e.Launch;
			e.Comet.SetActive(false);
			float num = e.Diameter * 0.08f;
			e.Comet.transform.localScale = new Vector3(num * 0.65f, num * 0.65f, num);
			GameObject obj = Sphere("WhiteCore", e.Comet.transform, e.White);
			obj.transform.localPosition = new Vector3(0f, 0f, 0.36f);
			obj.transform.localScale = Vector3.one * 0.38f;
			GameObject val2 = new GameObject("CrimsonTrail");
			val2.transform.SetParent(e.Comet.transform, false);
			e.Trail = val2.AddComponent<TrailRenderer>();
			((Renderer)e.Trail).sharedMaterial = e.Red;
			e.Trail.time = 2f;
			e.Trail.minVertexDistance = 0.4f;
			e.Trail.widthCurve = AnimationCurve.Linear(0f, 1f, 1f, 0f);
			((Renderer)e.Trail).shadowCastingMode = (ShadowCastingMode)0;
			GameObject val3 = new GameObject("CometLight");
			val3.transform.SetParent(e.Comet.transform, false);
			Light obj2 = val3.AddComponent<Light>();
			obj2.type = (LightType)2;
			obj2.color = new Color(1f, 0.05f, 0.1f);
			obj2.shadows = (LightShadows)0;
			e.Light = val3.AddComponent<HDAdditionalLightData>();
			e.Light.SetRange(250f);
			e.Light.SetIntensity(15000f, (LightUnit)1);
			e.Light.fadeDistance = 1000f;
			GameObject val4 = new GameObject("ImpactShockwave");
			val4.transform.SetParent(e.Root.transform, false);
			e.Wave = val4.AddComponent<LineRenderer>();
			((Renderer)e.Wave).sharedMaterial = e.White;
			e.Wave.positionCount = 97;
			e.Wave.widthMultiplier = 2f;
			e.Wave.useWorldSpace = true;
			((Renderer)e.Wave).enabled = false;
			e.Volume = e.Root.AddComponent<Volume>();
			e.Volume.isGlobal = true;
			e.Volume.priority = 10000f;
			e.Profile = ScriptableObject.CreateInstance<VolumeProfile>();
			e.Volume.sharedProfile = e.Profile;
			e.Grade = e.Profile.Add<ColorAdjustments>(false);
			((VolumeParameter)e.Grade.colorFilter).overrideState = true;
			((VolumeParameter<Color>)(object)e.Grade.colorFilter).value = Color.Lerp(Color.white, new Color(1f, 0.55f, 0.65f), Plugin.AmbushSky.Value);
			((VolumeParameter<float>)(object)e.Grade.postExposure).value = 0.05f;
			e.Ring1 = CreateRing(e, "FirstPropulsionRing");
			e.Ring2 = CreateRing(e, "SecondPropulsionRing");
			e.Sound = new AmbushSoundSession(e.Root.transform);
			BuildUi(e);
		}

		private static Material Material(Color color)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Color"));
			if (val.HasProperty("_UnlitColor"))
			{
				val.SetColor("_UnlitColor", color);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", color);
			}
			if (val.HasProperty("_EmissiveColor"))
			{
				val.SetColor("_EmissiveColor", color);
			}
			return val;
		}

		private static GameObject Sphere(string name, Transform parent, Material material)
		{
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)obj).name = name;
			obj.transform.SetParent(parent, false);
			Collider component = obj.GetComponent<Collider>();
			component.enabled = false;
			Object.Destroy((Object)(object)component);
			MeshRenderer component2 = obj.GetComponent<MeshRenderer>();
			((Renderer)component2).sharedMaterial = material;
			((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component2).receiveShadows = false;
			return obj;
		}

		private static Vector3 Point(AmbushTrajectory.Point point)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3((float)po