Decompiled source of Motion Tracker V3 v1.0.2

MotionTracker-V3.dll

Decompiled 6 hours ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MotionTracker.Patches;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MotionTracker-V3")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Add the MotionTracker from \"Alien: Isolation\"")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+c3c0c6e4e6aae298dd6cf523da406269b46ef7bc")]
[assembly: AssemblyProduct("MotionTracker-V3")]
[assembly: AssemblyTitle("MotionTracker-V3")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class MotionTrackerConfig
{
	[CompilerGenerated]
	private static class <>O
	{
		public static HandleNamedMessageDelegate <0>__OnRequestSync;

		public static HandleNamedMessageDelegate <1>__OnReceiveSync;
	}

	private const int byteDim = 17;

	private static int MotionTrackerCostLocal = 90;

	private static float MotionTrackerBatteryDurationLocal = 600f;

	private static float MotionTrackerSpeedDetectLocal = 0.01f;

	private static float MotionTrackerRangeLocal = 50f;

	public static int MotionTrackerCost = 90;

	public static float MotionTrackerBatteryDuration = 600f;

	public static float MotionTrackerSpeedDetect = 0.01f;

	public static float MotionTrackerRange = 50f;

	private static void SetValues(int Cost, float BatteryDuration, float SpeedDetect, float Range)
	{
		MotionTrackerCost = Cost;
		MotionTrackerBatteryDuration = BatteryDuration;
		MotionTrackerSpeedDetect = SpeedDetect;
		MotionTrackerRange = Range;
	}

	private static void SetToLocalValues()
	{
		SetValues(MotionTrackerCostLocal, MotionTrackerBatteryDurationLocal, MotionTrackerSpeedDetectLocal, MotionTrackerRangeLocal);
	}

	public static void LoadConfig(ConfigFile config)
	{
		Debug.Log((object)("MotionTrackerLog CONFIG:" + (object)config));
		MotionTrackerCostLocal = Math.Clamp(config.Bind<int>("General", "MotionTrackerCost", 90, "Motion Tracker's cost").Value, 0, 9999);
		MotionTrackerBatteryDurationLocal = Mathf.Clamp(config.Bind<float>("General", "MotionTrackerBatteryDuration", 600f, "Motion Tracker's battery life").Value, 0f, 9999f);
		MotionTrackerSpeedDetectLocal = Mathf.Clamp(config.Bind<float>("General", "MotionTrackerSpeedDetect", 0.01f, "Minimum speed at which entities can be detected by the Motion Tracker (0.05 is faster than a crouch walk)").Value, 0f, 9999f);
		MotionTrackerRangeLocal = Mathf.Clamp(config.Bind<float>("General", "MotionTrackerRange", 50f, "Motion Tracker's range of action").Value, 0f, 9999f);
		SetToLocalValues();
	}

	public static byte[] GetSettings()
	{
		byte[] array = new byte[17]
		{
			1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0
		};
		Array.Copy(BitConverter.GetBytes(MotionTrackerCostLocal), 0, array, 1, 4);
		Array.Copy(BitConverter.GetBytes(MotionTrackerBatteryDurationLocal), 0, array, 5, 4);
		Array.Copy(BitConverter.GetBytes(MotionTrackerSpeedDetectLocal), 0, array, 9, 4);
		Array.Copy(BitConverter.GetBytes(MotionTrackerRangeLocal), 0, array, 13, 4);
		return array;
	}

	public static void SetSettings(byte[] data)
	{
		if (data[0] == 1)
		{
			MotionTrackerCost = BitConverter.ToInt32(data, 1);
			MotionTrackerBatteryDuration = BitConverter.ToSingle(data, 5);
			MotionTrackerSpeedDetect = BitConverter.ToSingle(data, 9);
			MotionTrackerRange = BitConverter.ToSingle(data, 13);
			Debug.Log((object)"MotionTrackerLog: Host config set successfully");
			return;
		}
		throw new Exception("Invalid version byte");
	}

	private static bool IsHost()
	{
		return NetworkManager.Singleton.IsHost;
	}

	public static void OnRequestSync(ulong clientID, FastBufferReader reader)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		if (!IsHost())
		{
			return;
		}
		Debug.Log((object)("MotionTrackerLog: Sending config to client " + clientID));
		byte[] settings = GetSettings();
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(settings.Length, (Allocator)2, settings.Length);
		try
		{
			((FastBufferWriter)(ref val)).WriteBytes(settings, -1, 0);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("MotionTracker_OnReceiveConfigSync", clientID, val, (NetworkDelivery)2);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("MotionTrackerLog: Failed to send config: " + ex));
		}
		finally
		{
			((FastBufferWriter)(ref val)).Dispose();
		}
	}

	public static void OnReceiveSync(ulong clientID, FastBufferReader reader)
	{
		Debug.Log((object)"MotionTrackerLog: Received config from host");
		byte[] settings = new byte[17];
		try
		{
			((FastBufferReader)(ref reader)).ReadBytes(ref settings, 17, 0);
			SetSettings(settings);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("MotionTrackerLog: Failed to receive config: " + ex));
			SetToLocalValues();
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
	private static void ServerConnect()
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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_007a: Expected O, but got Unknown
		//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_0040: Expected O, but got Unknown
		if (IsHost())
		{
			Debug.Log((object)"MotionTrackerLog: Started hosting, using local settings");
			SetToLocalValues();
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			object obj = <>O.<0>__OnRequestSync;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnRequestSync;
				<>O.<0>__OnRequestSync = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler("MotionTracker_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
			return;
		}
		Debug.Log((object)"MotionTrackerLog: Connected to server, requesting settings");
		CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
		object obj2 = <>O.<1>__OnReceiveSync;
		if (obj2 == null)
		{
			HandleNamedMessageDelegate val2 = OnReceiveSync;
			<>O.<1>__OnReceiveSync = val2;
			obj2 = (object)val2;
		}
		customMessagingManager2.RegisterNamedMessageHandler("MotionTracker_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
		FastBufferWriter val3 = default(FastBufferWriter);
		((FastBufferWriter)(ref val3))..ctor(17, (Allocator)2, -1);
		NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("MotionTracker_OnRequestConfigSync", 0uL, val3, (NetworkDelivery)2);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
	private static void ServerDisconnect()
	{
		Debug.Log((object)"MotionTrackerLog: Server disconnect");
		SetToLocalValues();
	}
}
public struct LineDrawer
{
	private LineRenderer lineRenderer;

	private float lineSize;

	public LineDrawer(float lineSize = 0.2f)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		GameObject val = new GameObject("LineObj");
		lineRenderer = val.AddComponent<LineRenderer>();
		((Renderer)lineRenderer).material = new Material(Shader.Find("Hidden/Internal-Colored"));
		this.lineSize = lineSize;
	}

	private void Init(float lineSize = 0.2f)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		if ((Object)(object)lineRenderer == (Object)null)
		{
			GameObject val = new GameObject("LineObj");
			lineRenderer = val.AddComponent<LineRenderer>();
			((Renderer)lineRenderer).material = new Material(Shader.Find("Hidden/Internal-Colored"));
			this.lineSize = lineSize;
		}
	}

	public void DrawLineInGameView(Vector3 start, Vector3 end, Color color)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)lineRenderer == (Object)null)
		{
			Init();
		}
		lineRenderer.startColor = color;
		lineRenderer.endColor = color;
		lineRenderer.startWidth = lineSize;
		lineRenderer.endWidth = lineSize;
		lineRenderer.positionCount = 2;
		lineRenderer.SetPosition(0, start);
		lineRenderer.SetPosition(1, end);
	}

	public void Destroy()
	{
		if ((Object)(object)lineRenderer != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)lineRenderer).gameObject);
		}
	}
}
namespace LC_MotionTracker
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MotionTracker-V3";

		public const string PLUGIN_NAME = "MotionTracker-V3";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MotionTracker
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class MotionTrackerResource
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("LC_MotionTracker.MotionTrackerResource", typeof(MotionTrackerResource).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] motiontrackerled => (byte[])ResourceManager.GetObject("motiontrackerled", resourceCulture);

		internal MotionTrackerResource()
		{
		}
	}
	internal class Utils
	{
		public class Main
		{
			public static bool IsIngame()
			{
				if ((Object)(object)GameObject.Find("Environment") != (Object)null)
				{
					return true;
				}
				return false;
			}
		}
	}
	[BepInPlugin("dopadream.MotionTracker-V3", "MotionTracker-V3", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private static Item motionTrackerLED_Item;

		private static MotionTrackerScript spawnedMotionTracker;

		public static AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "motiontrackerled"));

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin dopadream.MotionTracker-V3 is loaded!");
			MotionTrackerConfig.LoadConfig(((BaseUnityPlugin)this).Config);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Config loaded");
			Harmony.CreateAndPatchAll(typeof(MotionTrackerConfig), (string)null);
			if ((Object)(object)motionTrackerLED_Item == (Object)null)
			{
				try
				{
					Object obj = assetBundle.LoadAsset("MotionTrackerItem", typeof(Item));
					motionTrackerLED_Item = (Item)(object)((obj is Item) ? obj : null);
				}
				catch
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Encountered some error loading asset bundle. Did you install the plugin correctly?");
					return;
				}
			}
			motionTrackerLED_Item.spawnPrefab.GetComponent<NetworkObject>().AutoObjectParentSync = false;
			spawnedMotionTracker = motionTrackerLED_Item.spawnPrefab.AddComponent<MotionTrackerScript>();
			((GrabbableObject)spawnedMotionTracker).itemProperties = motionTrackerLED_Item;
			((GrabbableObject)spawnedMotionTracker).isInFactory = true;
			Items.RegisterShopItem(motionTrackerLED_Item, MotionTrackerConfig.MotionTrackerCost);
			NetworkPrefabs.RegisterNetworkPrefab(motionTrackerLED_Item.spawnPrefab);
		}
	}
}
namespace MotionTracker.Patches
{
	public struct ScannedEntity
	{
		public Collider obj;

		public Vector3 position;

		public Vector3 rawPosition;

		public float speed;

		public GameObject blip;

		public AudioSource trackerAudio;
	}
	public class MotionTrackerScript : GrabbableObject
	{
		private GameObject baseRadar;

		private GameObject baseRadarOff;

		private GameObject LED;

		private GameObject blip;

		private GameObject blipParent;

		private AudioSource trackerAudio;

		private static AudioClip trackerOnClip;

		private static AudioClip trackerOffClip;

		private static AudioClip trackerBlipClip;

		private static AudioClip trackerOutOfBatteriesClip;

		private float searchRadius = MotionTrackerConfig.MotionTrackerRange;

		private Hashtable scannedEntities = new Hashtable();

		private List<GameObject> blipPool = new List<GameObject>();

		private int maxEntities = 50;

		private Collider[] colliders = (Collider[])(object)new Collider[200];

		public void Awake()
		{
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Expected O, but got Unknown
			List<Item> source = StartOfRound.Instance?.allItemsList?.itemsList;
			try
			{
				Object obj = Plugin.assetBundle.LoadAsset("motion_detector_on", typeof(AudioClip));
				trackerOnClip = (AudioClip)(object)((obj is AudioClip) ? obj : null);
				Object obj2 = Plugin.assetBundle.LoadAsset("motion_detector_off", typeof(AudioClip));
				trackerOffClip = (AudioClip)(object)((obj2 is AudioClip) ? obj2 : null);
				Object obj3 = Plugin.assetBundle.LoadAsset("motion_detector_ping", typeof(AudioClip));
				trackerBlipClip = (AudioClip)(object)((obj3 is AudioClip) ? obj3 : null);
				Object obj4 = Plugin.assetBundle.LoadAsset("FlashlightFlicker", typeof(AudioClip));
				trackerOutOfBatteriesClip = (AudioClip)(object)((obj4 is AudioClip) ? obj4 : null);
			}
			catch
			{
				return;
			}
			Item val = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "WalkieTalkie"));
			Item val2 = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "Shotgun"));
			((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "ProFlashlight"));
			base.itemProperties.verticalOffset = 0.1f;
			base.itemProperties.grabSFX = val.grabSFX;
			base.itemProperties.pocketSFX = val.pocketSFX;
			base.itemProperties.dropSFX = val2.dropSFX;
			base.grabbable = true;
			base.grabbableToEnemies = true;
			base.mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>();
			trackerAudio = ((Component)this).GetComponent<AudioSource>();
			base.useCooldown = 1f;
			base.insertedBattery = new Battery(false, 1f);
			base.itemProperties.batteryUsage = MotionTrackerConfig.MotionTrackerBatteryDuration;
			baseRadar = ((Component)((Component)this).transform.Find("Canvas/BaseRadar")).gameObject;
			baseRadarOff = ((Component)((Component)this).transform.Find("Canvas/BaseRadar_off")).gameObject;
			LED = ((Component)((Component)this).transform.Find("LED")).gameObject;
			blipParent = ((Component)((Component)this).transform.Find("Canvas/BlipParent")).gameObject;
			blip = ((Component)((Component)this).transform.Find("Canvas/BlipParent/Blip")).gameObject;
			blip.SetActive(false);
			blipPool.Add(blip);
			for (int i = 1; i < maxEntities; i++)
			{
				blipPool.Add(((Component)((Component)this).transform.Find($"Canvas/BlipParent/Blip ({i})")).gameObject);
				blipPool[i].SetActive(false);
			}
			Enable(enable: false);
		}

		private void Enable(bool enable, bool inHand = true)
		{
			baseRadar.SetActive(enable);
			LED.SetActive(enable);
			if (inHand)
			{
				baseRadarOff.SetActive(!enable);
			}
			else
			{
				baseRadarOff.SetActive(false);
			}
			if (enable)
			{
				return;
			}
			foreach (GameObject item in blipPool)
			{
				item.SetActive(false);
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_006e: 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)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (used)
			{
				trackerAudio.PlayOneShot(trackerOnClip);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 7f, 0.4f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			else
			{
				trackerAudio.PlayOneShot(trackerOffClip);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 7f, 0.4f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			Enable(used);
			Debug.Log((object)$"Motion tracker activate? : {used}");
		}

		public override void UseUpBatteries()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).UseUpBatteries();
			trackerAudio.PlayOneShot(trackerOutOfBatteriesClip);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 13f, 0.65f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			Enable(enable: false, inHand: false);
		}

		public override void Update()
		{
			//IL_0052: 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_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_00d7: 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_00de: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_0163: 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)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (base.isPocketed)
			{
				Enable(enable: false, inHand: false);
			}
			else
			{
				if (!base.isBeingUsed)
				{
					return;
				}
				if (base.isHeld)
				{
					Enable(enable: true);
					blipParent.transform.localRotation = Quaternion.Euler(0f, 0f, ((Component)base.playerHeldBy).transform.eulerAngles.y + 0f);
				}
				else
				{
					Enable(enable: false, inHand: false);
				}
				if (base.insertedBattery.empty)
				{
					Enable(enable: false);
					return;
				}
				for (int i = 0; i < maxEntities; i++)
				{
					blipPool[i].SetActive(false);
				}
				Hashtable hashtable = new Hashtable(scannedEntities);
				scannedEntities.Clear();
				Vector3 position = ((Component)this).transform.position;
				int num = Physics.OverlapCapsuleNonAlloc(position, new Vector3(position.x, position.y - 200f, position.z), searchRadius, colliders, 524296);
				int num2 = 0;
				for (int j = 0; j < num; j++)
				{
					Collider val = colliders[j];
					ScannedEntity scannedEntity = default(ScannedEntity);
					scannedEntity.obj = val;
					scannedEntity.position = ((Component)val).transform.position - baseRadar.transform.position;
					scannedEntity.rawPosition = ((Component)val).transform.position;
					ScannedEntity scannedEntity2 = scannedEntity;
					if (hashtable.Contains(((object)((Component)scannedEntity2.obj).transform).GetHashCode()))
					{
						Vector3 val2 = ((Component)val).transform.position - ((ScannedEntity)hashtable[((object)((Component)scannedEntity2.obj).transform).GetHashCode()]).rawPosition;
						scannedEntity2.speed = ((Vector3)(ref val2)).magnitude;
					}
					else
					{
						scannedEntity2.speed = 0f;
					}
					if (!scannedEntities.Contains(((object)((Component)scannedEntity2.obj).transform).GetHashCode()))
					{
						scannedEntity2.blip = blipPool[num2];
						num2++;
						Vector3 localPosition = scannedEntity2.blip.transform.localPosition;
						localPosition = scannedEntity2.position;
						scannedEntity2.blip.transform.localPosition = new Vector3(Remap(localPosition.x, 0f - searchRadius, searchRadius, -45f, 45f), Remap(localPosition.z, 0f - searchRadius, searchRadius, -45f, 45f), -0.1f);
						scannedEntity2.blip.SetActive(scannedEntity2.speed > MotionTrackerConfig.MotionTrackerSpeedDetect);
						if (scannedEntity2.speed > MotionTrackerConfig.MotionTrackerSpeedDetect && !trackerAudio.isPlaying)
						{
							trackerAudio.PlayOneShot(trackerBlipClip);
							RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 7f, 0.05f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
						}
						scannedEntities.Add(((object)((Component)scannedEntity2.obj).transform).GetHashCode(), scannedEntity2);
					}
				}
			}
		}

		public float Remap(float from, float fromMin, float fromMax, float toMin, float toMax)
		{
			float num = from - fromMin;
			float num2 = fromMax - fromMin;
			float num3 = num / num2;
			return (toMax - toMin) * num3 + toMin;
		}
	}
}