Decompiled source of ScanTweaks v1.2.0

ScanTweaks.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using LethalMDK;
using LethalMDK.World;
using ScanTweaks.World;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityMDK.Config;
using UnityMDK.Injection;
using UnityMDK.Reflection;

[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("ScanTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScanTweaks")]
[assembly: AssemblyTitle("ScanTweaks")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ScanTweaks
{
	[InjectToComponent(typeof(IngamePlayerSettings), false)]
	public class PingScan : MonoBehaviour
	{
		[ConfigSection("PingScan")]
		[ConfigDescription("Enable/Disable the ping scan tweaks")]
		public static readonly ConfigData<bool> DoPatch = new ConfigData<bool>(true);

		[SerializeField]
		private float _range = 80f;

		[SerializeField]
		private float _outOfFrustumPaddingHorizontal = 0.2f;

		private readonly List<Collider> _currentScannedColliders = new List<Collider>();

		private readonly List<ScanNodeProperties> _currentScannedNodes = new List<ScanNodeProperties>();

		private readonly List<int> _currentScannedValues = new List<int>();

		private readonly List<GrabbableObject> _currentScannedGrabbables = new List<GrabbableObject>();

		private readonly Collider[] _hitAlloc = (Collider[])(object)new Collider[30];

		private static readonly int _physicsMask = LayerMasks.Room | LayerMasks.InteractableObject;

		private float _outOfFrustumPaddingVertical => _outOfFrustumPaddingHorizontal * ((float)Screen.width / (float)Screen.height);

		public static int PingedScrapValue { get; private set; }

		public static int NodeUtility => 0;

		public static int NodeCreature => 1;

		public static int NodeScrap => 2;

		public static event Action<ScanNodeProperties> ScanNodeAdded;

		public static event Action<ScanNodeProperties> ScanNodeRemoved;

		public static event Action DoPing;

		internal static void TriggerPingScan()
		{
			PingScan.DoPing?.Invoke();
		}

		private void Update()
		{
			PlayerControllerB localPlayer = Player.LocalPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return;
			}
			if (localPlayer.inSpecialInteractAnimation && _currentScannedNodes.Count > 0)
			{
				RemoveAll();
			}
			float outOfFrustumPaddingHorizontal = _outOfFrustumPaddingHorizontal;
			float outOfFrustumPaddingVertical = _outOfFrustumPaddingVertical;
			for (int num = _currentScannedNodes.Count - 1; num >= 0; num--)
			{
				ScanNodeProperties scanNode = _currentScannedNodes[num];
				Collider nodeCollider = _currentScannedColliders[num];
				GrabbableObject val = _currentScannedGrabbables[num];
				if (Object.op_Implicit((Object)(object)val) && val.isHeld && !val.isHeldByEnemy)
				{
					RemoveScanNodeAt(num);
				}
				else if (!IsNodeVisible(scanNode, nodeCollider, localPlayer.gameplayCamera, outOfFrustumPaddingHorizontal, outOfFrustumPaddingVertical))
				{
					RemoveScanNodeAt(num);
				}
			}
		}

		private void OnEnable()
		{
			DoPing += OnPingScan;
		}

		private void OnDisable()
		{
			DoPing -= OnPingScan;
			RemoveAll();
		}

		private void RemoveAll()
		{
			for (int num = _currentScannedNodes.Count - 1; num >= 0; num--)
			{
				RemoveScanNodeAt(num);
			}
		}

		private void OnPingScan()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_001d: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Camera gameplayCamera = Player.LocalPlayer.gameplayCamera;
			Transform transform = ((Component)gameplayCamera).transform;
			Vector3 position = transform.position;
			Vector3 forward = transform.forward;
			float num = _range * 0.5f;
			int num2 = Physics.OverlapSphereNonAlloc(position + forward * num, num, _hitAlloc, LayerMasks.ScanNode, (QueryTriggerInteraction)1);
			ScanNodeProperties val2 = default(ScanNodeProperties);
			for (int i = 0; i < num2; i++)
			{
				Collider val = _hitAlloc[i];
				if (((Component)val).TryGetComponent<ScanNodeProperties>(ref val2) && IsNodeVisible(val2, val, gameplayCamera, 0f, 0f))
				{
					AddScanNode(val2);
				}
			}
		}

		private static bool PointOutOfViewport(float point, float padding)
		{
			if (!(point > 1f + padding))
			{
				return point < 0f - padding;
			}
			return true;
		}

		private static bool IsNodeVisible(ScanNodeProperties scanNode, Collider nodeCollider, Camera camera, float paddingX, float paddingY)
		{
			//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_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_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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_006a: 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_0079: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)scanNode))
			{
				return false;
			}
			if (!Object.op_Implicit((Object)(object)nodeCollider))
			{
				return false;
			}
			Vector3 position = ((Component)camera).transform.position;
			Bounds bounds = nodeCollider.bounds;
			Vector3 val = position - ((Bounds)(ref bounds)).center;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < (float)scanNode.minRange)
			{
				return false;
			}
			if (magnitude > (float)scanNode.maxRange)
			{
				return false;
			}
			bounds = nodeCollider.bounds;
			Vector3 val2 = camera.WorldToViewportPoint(((Bounds)(ref bounds)).center);
			if (PointOutOfViewport(val2.x, paddingX) || PointOutOfViewport(val2.y, paddingY) || val2.z < 0f)
			{
				return false;
			}
			if (scanNode.requiresLineOfSight)
			{
				bounds = nodeCollider.bounds;
				return !Linecast(position, ((Bounds)(ref bounds)).center, _physicsMask);
			}
			return true;
		}

		private static bool Linecast(Vector3 start, Vector3 end, int layerMask)
		{
			//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)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Linecast(start, end, ref val, layerMask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (((Component)((RaycastHit)(ref val)).collider).gameObject.CompareTag(Tags.InteractTrigger))
			{
				return Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<AnimatedObjectTrigger>());
			}
			return true;
		}

		private void AttemptScanNewCreature(int creatureID)
		{
			Terminal val = default(Terminal);
			if (creatureID >= 0 && Object.op_Implicit((Object)(object)HUDManager.Instance) && ReflectionUtility.TryGetField<Terminal>((object)HUDManager.Instance, "terminalScript", ref val) && !val.scannedEnemyIDs.Contains(creatureID))
			{
				HUDManager.Instance.ScanNewCreatureServerRpc(creatureID);
			}
		}

		private void AddScanNode(ScanNodeProperties scanNodeProperties)
		{
			if (Object.op_Implicit((Object)(object)scanNodeProperties) && !_currentScannedNodes.Contains(scanNodeProperties))
			{
				GrabbableObject componentInParent = ((Component)scanNodeProperties).GetComponentInParent<GrabbableObject>();
				if (!Object.op_Implicit((Object)(object)componentInParent) || !componentInParent.isHeld || componentInParent.isHeldByEnemy)
				{
					Collider component = ((Component)scanNodeProperties).GetComponent<Collider>();
					component.enabled = false;
					AttemptScanNewCreature(scanNodeProperties.creatureScanID);
					_currentScannedValues.Add((scanNodeProperties.nodeType == NodeScrap) ? scanNodeProperties.scrapValue : 0);
					_currentScannedColliders.Add(component);
					_currentScannedNodes.Add(scanNodeProperties);
					_currentScannedGrabbables.Add(componentInParent);
					CalculateTotalValue();
					PingScan.ScanNodeAdded?.Invoke(scanNodeProperties);
				}
			}
		}

		private void RemoveScanNodeAt(int index)
		{
			if (index >= 0 && index < _currentScannedNodes.Count)
			{
				Collider val = _currentScannedColliders[index];
				if (Object.op_Implicit((Object)(object)val))
				{
					val.enabled = true;
				}
				_currentScannedValues.RemoveAt(index);
				CalculateTotalValue();
				PingScan.ScanNodeRemoved?.Invoke(_currentScannedNodes[index]);
				_currentScannedColliders.RemoveAt(index);
				_currentScannedNodes.RemoveAt(index);
				_currentScannedGrabbables.RemoveAt(index);
			}
		}

		private void CalculateTotalValue()
		{
			PingedScrapValue = 0;
			foreach (int currentScannedValue in _currentScannedValues)
			{
				PingedScrapValue += currentScannedValue;
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Saradora.ScanTweaks", "Scan Tweaks", "1.2.0")]
	public class PluginInitializer : BaseUnityPlugin
	{
		private readonly Harmony _harmonyInstance = new Harmony("Saradora.ScanTweaks");

		private void Awake()
		{
			ConfigBinder.BindAll(((BaseUnityPlugin)this).Config);
			_harmonyInstance.PatchAll();
		}
	}
	public static class ScanTweaks
	{
		public const string ModGuid = "Saradora.ScanTweaks";

		public const string ModVersion = "1.2.0";

		public const string ModName = "Scan Tweaks";
	}
}
namespace ScanTweaks.World
{
	public class ApparaticeScrapValue : MonoBehaviour
	{
		[ConfigDescription("Minimum possible scrap value of the apparatice. This value has a x0.4 multiplier in patch 47")]
		private static readonly ConfigData<int> _minValue = new ConfigData<int>(125);

		[ConfigDescription("Maximum possible scrap value of the apparatice. This value has a x0.4 multiplier in patch 47")]
		private static readonly ConfigData<int> _maxValue = new ConfigData<int>(350);

		private LungProp _lungProp;

		[ConfigSection("Apparatice")]
		[ConfigDescription("Make the apparatice have a random scrap value, also fixes the \"???\" on the scan node, Host-only")]
		public static ConfigData<bool> MakeRandomValue { get; } = new ConfigData<bool>(true);


		private static bool IsServerOrHost
		{
			get
			{
				if (!NetworkManager.Singleton.IsHost)
				{
					return NetworkManager.Singleton.IsServer;
				}
				return true;
			}
		}

		private void Awake()
		{
			_lungProp = ((Component)this).GetComponent<LungProp>();
		}

		private IEnumerator Start()
		{
			yield return (object)new WaitForSeconds(11f);
			if (IsServerOrHost)
			{
				int num = ConfigData<int>.op_Implicit(_minValue);
				int num2 = ConfigData<int>.op_Implicit(_maxValue);
				if (num > num2)
				{
					int num3 = num2;
					num2 = num;
					num = num3;
				}
				int num4 = (int)((float)RoundManager.Instance.AnomalyRandom.Next(num, num2) * RoundManager.Instance.scrapValueMultiplier);
				((GrabbableObject)_lungProp).SetScrapValue(num4);
				NetworkObjectReference val = NetworkObjectReference.op_Implicit(((NetworkBehaviour)_lungProp).NetworkObject);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { val }, new int[1] { num4 });
			}
		}
	}
	[Initializer(0)]
	[SceneConstructor]
	public class ApparatusScrapValueInjector : ComponentInjector<LungProp>
	{
		[Initializer(0)]
		private static void Init()
		{
			if (ConfigData<bool>.op_Implicit(ApparaticeScrapValue.MakeRandomValue))
			{
				SceneInjection.AddComponentInjector<LungProp>((ComponentInjector<LungProp>)new ApparatusScrapValueInjector(), true);
			}
		}

		protected override bool CanBeInjected(LungProp component)
		{
			return IsLungPropValid(component);
		}

		protected override void Inject(LungProp component)
		{
			((Component)component).gameObject.AddComponent<ApparaticeScrapValue>();
		}

		private static bool IsLungPropValid(LungProp lungProp)
		{
			if (((GrabbableObject)lungProp).itemProperties.itemName != "Apparatus")
			{
				return false;
			}
			if (!lungProp.isLungDocked || !lungProp.isLungPowered)
			{
				return false;
			}
			return ((GrabbableObject)lungProp).isInFactory;
		}
	}
	[Initializer(0)]
	public static class BreakerBoxScanNode
	{
		[ConfigSection("BreakerBox")]
		[ConfigDescription("Adds a scan node to the breaker box")]
		private static readonly ConfigData<bool> _scanNode = new ConfigData<bool>(true);

		[ConfigDescription("Minimum range of the scan node")]
		private static readonly ConfigData<int> _minRange = new ConfigData<int>(3);

		[ConfigDescription("Maximum range of the scan node")]
		private static readonly ConfigData<int> _maxRange = new ConfigData<int>(13);

		private static readonly Vector3 Offset = new Vector3(-1f, -0.8f, -1.2f);

		[Initializer(0)]
		private static void Initialize()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigData<bool>.op_Implicit(_scanNode))
			{
				ScanNodes.AddScanNode<BreakerBox>((EType)0, "Breaker Box", "Flip the switches! Maybe it'll do something?", ConfigData<int>.op_Implicit(_minRange), ConfigData<int>.op_Implicit(_maxRange), (Vector3?)Offset, true, -1);
			}
		}
	}
	[InjectToComponent(typeof(StartOfRound), false)]
	public class RadarIcons : MonoBehaviour
	{
		[ConfigSection("Radar")]
		[ConfigDescription("Fixes the item radar so that item icons properly disappear when the item itself is destroyed (e.g. when a player is eaten).")]
		public static readonly ConfigData<bool> PatchRadarIcons = new ConfigData<bool>(true);

		private static List<(GrabbableObject, MeshRenderer)> _radarIconList = new List<(GrabbableObject, MeshRenderer)>();

		private static readonly Vector3 Offset = Vector3.up * 0.5f;

		private void Update()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			for (int num = _radarIconList.Count - 1; num >= 0; num--)
			{
				var (val, val2) = _radarIconList[num];
				if (!Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
					_radarIconList.RemoveAt(num);
				}
				else if (!Object.op_Implicit((Object)(object)val2))
				{
					_radarIconList.RemoveAt(num);
				}
				else if (((Renderer)val2).enabled = ((Component)val).gameObject.activeInHierarchy && !val.deactivated && (val.isHeld || (!val.isInElevator && !val.isInShipRoom)))
				{
					((Component)val2).transform.position = ((Component)val).transform.position + Offset;
				}
			}
		}

		public static void AddRadarIcon(GrabbableObject grabbableObject, MeshRenderer radarIcon)
		{
			if (Object.op_Implicit((Object)(object)grabbableObject) && Object.op_Implicit((Object)(object)radarIcon))
			{
				_radarIconList.Add((grabbableObject, radarIcon));
			}
		}
	}
}
namespace ScanTweaks.UI
{
	[InjectToComponent(typeof(HUDManager), false)]
	public class PingScanUI : MonoBehaviour
	{
		[SerializeField]
		private float _counterUpdateSpeed = 1500f;

		[SerializeField]
		private float _counterInterval = 0.03f;

		private float _nextCounterUpdate;

		private HUDManager _hudManager;

		private Queue<RectTransform> _uiElementsPool = new Queue<RectTransform>();

		private Dictionary<ScanNodeProperties, RectTransform> _currentScanNodes = new Dictionary<ScanNodeProperties, RectTransform>();

		private static readonly int AColorNumber = Animator.StringToHash("colorNumber");

		private static readonly int ADisplayBool = Animator.StringToHash("display");

		private int _currentScrapValue;

		private void Awake()
		{
			_hudManager = ((Component)this).GetComponent<HUDManager>();
			for (int i = 1; i < _hudManager.scanElements.Length; i++)
			{
				_uiElementsPool.Enqueue(_hudManager.scanElements[i]);
			}
		}

		private void OnEnable()
		{
			PingScan.ScanNodeAdded += OnScanNodeAdded;
			PingScan.ScanNodeRemoved += OnScanNodeRemoved;
		}

		private void OnDisable()
		{
			PingScan.ScanNodeAdded -= OnScanNodeAdded;
			PingScan.ScanNodeRemoved -= OnScanNodeRemoved;
		}

		private void Update()
		{
			UpdateScanUIPositions();
			UpdateScrapValueCounter();
		}

		private void UpdateScanUIPositions()
		{
			//IL_006b: 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_0070: 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_00d5: 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_00e2: 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_00f6: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayer = Player.LocalPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return;
			}
			Camera gameplayCamera = localPlayer.gameplayCamera;
			float num = 860f;
			float num2 = (float)((Texture)gameplayCamera.targetTexture).width / num;
			float num3 = 0.123f * num2 + 0.877f;
			if (num3 > 1.238f)
			{
				num3 = 1.238f;
			}
			Vector3 localScale = ((num2 <= 3f) ? new Vector3(num2, num2, num2) : new Vector3(3f, 3f, 3f));
			List<ScanNodeProperties> list = new List<ScanNodeProperties>();
			SortedList<float, RectTransform> sortedList = new SortedList<float, RectTransform>();
			foreach (var (val3, val4) in _currentScanNodes)
			{
				if (!Object.op_Implicit((Object)(object)val3))
				{
					list.Add(val3);
					continue;
				}
				Vector3 position = ((Component)val3).transform.position;
				sortedList.Add(Vector3.SqrMagnitude(position - ((Component)gameplayCamera).transform.position), val4);
				Vector3 val5 = gameplayCamera.WorldToScreenPoint(position);
				Vector3 position2 = ((Transform)val4).position;
				position2.z = 12.17f * num3;
				((Transform)val4).position = position2;
				val4.anchoredPosition = new Vector2(val5.x - 439.48f * num2, val5.y - 244.8f * num2);
				((Transform)val4).localScale = localScale;
			}
			foreach (ScanNodeProperties item in list)
			{
				OnScanNodeRemoved(item);
			}
			foreach (KeyValuePair<float, RectTransform> item2 in sortedList)
			{
				((Transform)item2.Value).SetAsFirstSibling();
			}
		}

		private void UpdateScrapValueCounter()
		{
			if (PingScan.PingedScrapValue != _currentScrapValue && !(Time.time < _nextCounterUpdate))
			{
				_nextCounterUpdate = Time.time + _counterInterval;
				if (!_hudManager.scanInfoAnimator.GetBool(ADisplayBool))
				{
					_hudManager.scanInfoAnimator.SetBool(ADisplayBool, true);
				}
				if (_currentScrapValue < PingScan.PingedScrapValue)
				{
					_currentScrapValue = Mathf.RoundToInt(Mathf.MoveTowards((float)_currentScrapValue, (float)PingScan.PingedScrapValue, _counterUpdateSpeed * Time.deltaTime));
					_hudManager.UIAudio.PlayOneShot(_hudManager.addToScrapTotalSFX);
				}
				else
				{
					_currentScrapValue = PingScan.PingedScrapValue;
				}
				((TMP_Text)_hudManager.totalValueText).text = $"${_currentScrapValue}";
				if (_currentScrapValue == 0)
				{
					_hudManager.scanInfoAnimator.SetBool(ADisplayBool, false);
				}
				else if (PingScan.PingedScrapValue == _currentScrapValue)
				{
					_hudManager.UIAudio.PlayOneShot(_hudManager.finishAddingToTotalSFX);
				}
			}
		}

		private RectTransform GetUIElement()
		{
			if (_uiElementsPool.Count > 0)
			{
				return _uiElementsPool.Dequeue();
			}
			RectTransform obj = Object.Instantiate<RectTransform>(_hudManager.scanElements[0], ((Component)_hudManager.scanElements[0]).transform.parent);
			((Transform)obj).SetAsFirstSibling();
			return obj;
		}

		private void OnScanNodeAdded(ScanNodeProperties scanNode)
		{
			if (!_currentScanNodes.ContainsKey(scanNode))
			{
				RectTransform uIElement = GetUIElement();
				((Component)uIElement).gameObject.SetActive(true);
				TextMeshProUGUI[] componentsInChildren = ((Component)uIElement).GetComponentsInChildren<TextMeshProUGUI>();
				if (componentsInChildren.Length == 2)
				{
					((TMP_Text)componentsInChildren[0]).text = scanNode.headerText;
					((TMP_Text)componentsInChildren[1]).text = scanNode.subText;
				}
				((Component)uIElement).GetComponent<Animator>().SetInteger(AColorNumber, scanNode.nodeType);
				_currentScanNodes.Add(scanNode, uIElement);
			}
		}

		private void OnScanNodeRemoved(ScanNodeProperties scanNode)
		{
			if (_currentScanNodes.ContainsKey(scanNode))
			{
				RectTransform val = _currentScanNodes[scanNode];
				((Component)val).gameObject.SetActive(false);
				_currentScanNodes.Remove(scanNode);
				_uiElementsPool.Enqueue(val);
			}
		}
	}
}
namespace ScanTweaks.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal static class GrabbableObject_Patching
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start_PostFix(GrabbableObject __instance)
		{
			if (ConfigData<bool>.op_Implicit(RadarIcons.PatchRadarIcons))
			{
				PatchRadarIcon(__instance);
			}
			PatchPropColliders(__instance);
		}

		private static void PatchRadarIcon(GrabbableObject grabbableObject)
		{
			if (Object.op_Implicit((Object)(object)grabbableObject.radarIcon))
			{
				RadarIcons.AddRadarIcon(grabbableObject, ((Component)grabbableObject.radarIcon).GetComponent<MeshRenderer>());
				((Component)grabbableObject.radarIcon).transform.SetParent(((Component)StartOfRound.Instance).transform);
				grabbableObject.radarIcon = null;
			}
		}

		private static void PatchPropColliders(GrabbableObject grabbableObject)
		{
			List<Collider> list = new List<Collider>();
			Collider[] propColliders = grabbableObject.propColliders;
			foreach (Collider val in propColliders)
			{
				if (((Component)val).gameObject.layer != Layers.ScanNode)
				{
					list.Add(val);
				}
			}
			grabbableObject.propColliders = list.ToArray();
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal static class HUDManager_Patching
	{
		private static bool _insideUpdate;

		[HarmonyPatch("CanPlayerScan")]
		[HarmonyPrefix]
		private static bool CanPlayerScan_Prefix(ref bool __result)
		{
			if (!ConfigData<bool>.op_Implicit(PingScan.DoPatch))
			{
				return true;
			}
			if (!_insideUpdate)
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPatch("PingScan_performed")]
		[HarmonyPostfix]
		private static void PingScan_performed_Postfix(HUDManager __instance)
		{
			if (!((Object)(object)Player.LocalPlayer == (Object)null) && !(ReflectionUtility.GetField<float>((object)__instance, "playerPingingScan") < 0.3f))
			{
				PingScan.TriggerPingScan();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		private static void Update_Prefix()
		{
			_insideUpdate = true;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		[HarmonyPriority(800)]
		private static void Update_Postfix()
		{
			_insideUpdate = false;
		}
	}
}