Decompiled source of FeralMinimap v0.0.11

BepInEx/plugins/FeralMinimap.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FeralCommon;
using FeralCommon.Config;
using FeralCommon.Input;
using FeralCommon.Utils;
using FeralCommon.Utils.Extensions;
using FeralMinimap.Behaviors;
using FeralMinimap.Patches;
using FeralMinimap.Util;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[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("Ferus LLC")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("An easier way to find your... way")]
[assembly: AssemblyFileVersion("0.0.11.0")]
[assembly: AssemblyInformationalVersion("0.0.11+27af1586307793ab1f0180101e206be351d77995")]
[assembly: AssemblyProduct("FeralMinimap")]
[assembly: AssemblyTitle("FeralMinimap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
namespace FeralMinimap
{
	public static class Buttons
	{
		public static readonly ButtonToggle MinimapEnabled = new ButtonToggle("MinimapEnabled", "Minimap Enabled", "<keyboard>/m", true);

		public static readonly ButtonPress SwitchTarget = new ButtonPress("SwitchTarget", "Switch Target", "<keyboard>/l");

		internal static void InitController()
		{
			MinimapEnabled.OnToggle((Action<bool>)delegate(bool newValue)
			{
				if (Object.op_Implicit((Object)(object)MinimapView.Instance))
				{
					((Behaviour)MinimapView.Instance.Image).enabled = newValue;
					((Behaviour)MinimapView.Instance.Text).enabled = newValue;
					MinimapView.AdjustTooltips();
				}
			});
			SwitchTarget.OnPressed((Action)delegate
			{
				MinimapTarget.Instance.SwitchNextTarget();
			});
		}
	}
	public static class Config
	{
		public static class Minimap
		{
			public static readonly IntConfig InsideBrightness = ((Config<IntConfig, int>)(object)((RangeConfig<IntConfig, int>)(object)((RangeConfig<IntConfig, int>)(object)((Config<IntConfig, int>)new IntConfig("Minimap", "Facility Brightness")).WithDescription("Sets the brightness of the minimap when the current view is within the facility.")).WithMin(0)).WithMax(100)).WithDefaultValue(15).NoSlider();

			public static readonly EnumConfig<RotationStrategy> Rotation = ((Config<EnumConfig<RotationStrategy>, RotationStrategy>)(object)((Config<EnumConfig<RotationStrategy>, RotationStrategy>)(object)new EnumConfig<RotationStrategy>("Minimap", "Rotation")).WithDescription("Determines in which orientation the minimap is rotated.\nDefault is a north-west direction at 315 degrees.\nTarget will rotate the minimap to match the target's current orientation.\nThe cardinal directions (NESW) will rotate the minimap to face the corresponding direction.")).WithDefaultValue(RotationStrategy.Default);

			public static readonly IntConfig Size = ((Config<IntConfig, int>)(object)((RangeConfig<IntConfig, int>)(object)((RangeConfig<IntConfig, int>)(object)((Config<IntConfig, int>)new IntConfig("Minimap", "Size")).WithDescription("The size (in px) of the minimap.")).WithMin(100)).WithMax(500)).WithDefaultValue(200).NoSlider();

			public static readonly FloatConfig AspectRatio = ((Config<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Minimap", "Aspect Ratio")).WithDescription("The aspect ratio of the minimap. This is the ratio of width to height.\n'4:3' is the default aspect ratio, which equates to 4/3=1.3333\n'16:9' is a common widescreen aspect ratio, which equates to 16/9=1.7777")).WithMin(0f)).WithMax(float.MaxValue)).WithDefaultValue(1.3333334f).NoSlider();

			public static readonly FloatConfig Zoom = ((Config<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Minimap", "Zoom")).WithDescription("Determines the 'orthographic size' of the minimap camera. Otherwise known as the zoom level.\nLarger values will zoom the map out, showing more of the facility or surrounding area.")).WithMin(1f)).WithMax(100f)).WithDefaultValue(19.7f).WithStep(0.1f);

			public static readonly FloatConfig CameraFeedQuality = ((Config<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Minimap", "Camera Feed Quality")).WithDescription("Multiplier for the size of the camera feed. Increasing this value will increase the size of the camera feed, which will increase the quality of the minimap.")).WithMin(0.25f)).WithMax(25f)).WithDefaultValue(1f).WithStep(0.1f);

			public static readonly IntConfig XPosOffset = ((Config<IntConfig, int>)new IntConfig("Minimap", "X Position Offset")).WithDescription("The horizontal offset of the minimap from the right side of the screen.\n0 represents being flush with the right side of the screen.\nPositive values move the minimap to the left.");

			public static readonly IntConfig YPosOffset = ((Config<IntConfig, int>)new IntConfig("Minimap", "Y Position Offset")).WithDescription("The vertical offset of the minimap from the top of the screen.\n0 represents being flush with the top of the screen.\nPositive values move the minimap down.");

			public static int Height => Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Size);

			public static int Width => (int)((float)Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Size) * Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)AspectRatio));
		}

		public static class Fixes
		{
			public static readonly BoolConfig AlwaysShowRadarBoosters = ((Config<BoolConfig, bool>)(object)((Config<BoolConfig, bool>)new BoolConfig("Fixes", "Always Show Radar Boosters")).WithDescription("Always show radar boosters on the minimap, even when they're not active.\nThe default behavior is to only show radar boosters on the minimap when they're active or when they have never been activated (because they're visible by default).\nEnabling this option will make radar boosters always visible on the minimap, regardless of their state.")).WithDefaultValue(true);
		}

		internal static void InitController()
		{
			((Config<IntConfig, int>)(object)Minimap.Size).OnValueChanged((Action<int>)delegate
			{
				if (Object.op_Implicit((Object)(object)MinimapView.Instance))
				{
					MinimapView.Instance.UpdateViewSize();
				}
			});
			((Config<FloatConfig, float>)(object)Minimap.AspectRatio).OnValueChanged((Action<float>)delegate
			{
				if (Object.op_Implicit((Object)(object)MinimapView.Instance))
				{
					MinimapView.Instance.UpdateViewSize();
				}
			});
			((Config<FloatConfig, float>)(object)Minimap.CameraFeedQuality).OnValueChanged((Action<float>)delegate
			{
				if (Object.op_Implicit((Object)(object)MinimapView.Instance))
				{
					MinimapView.Instance.UpdateFeedSize();
				}
			});
			((Config<IntConfig, int>)(object)Minimap.XPosOffset).OnValueChanged((Action<int>)delegate(int newValue)
			{
				//IL_001b: 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_0034: 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)
				if (Object.op_Implicit((Object)(object)MinimapView.Instance))
				{
					Vector2 anchoredPosition2 = ((Graphic)MinimapView.Instance.Image).rectTransform.anchoredPosition;
					((Graphic)MinimapView.Instance.Image).rectTransform.anchoredPosition = new Vector2((float)(newValue * -1), anchoredPosition2.y);
					MinimapView.AdjustTooltips();
				}
			});
			((Config<IntConfig, int>)(object)Minimap.YPosOffset).OnValueChanged((Action<int>)delegate(int newValue)
			{
				//IL_001b: 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_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)MinimapView.Instance))
				{
					Vector2 anchoredPosition = ((Graphic)MinimapView.Instance.Image).rectTransform.anchoredPosition;
					((Graphic)MinimapView.Instance.Image).rectTransform.anchoredPosition = new Vector2(anchoredPosition.x, (float)(newValue * -1) + -8f);
					MinimapView.AdjustTooltips();
				}
			});
			((Config<IntConfig, int>)(object)Minimap.InsideBrightness).OnValueChanged((Action<int>)delegate(int newValue)
			{
				MinimapCamera.Instance.Light.intensity = newValue;
			});
			((Config<FloatConfig, float>)(object)Minimap.Zoom).OnValueChanged((Action<float>)delegate
			{
				if (Object.op_Implicit((Object)(object)MinimapCamera.Instance))
				{
					MinimapCamera.Instance.UpdateCameraSize();
				}
			});
			((Config<FloatConfig, float>)(object)Minimap.AspectRatio).OnValueChanged((Action<float>)delegate
			{
				if (Object.op_Implicit((Object)(object)MinimapCamera.Instance))
				{
					MinimapCamera.Instance.UpdateCameraSize();
				}
			});
			((Config<IntConfig, int>)(object)Minimap.Size).OnValueChanged((Action<int>)delegate
			{
				if (Object.op_Implicit((Object)(object)MinimapCamera.Instance))
				{
					MinimapCamera.Instance.UpdateCameraSize();
				}
			});
		}
	}
	[BepInPlugin("FeralMinimap", "FeralMinimap", "0.0.11")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class FeralMinimapPlugin : FeralPlugin
	{
		private class BinderWorkAround : LcInputActions
		{
			[CompilerGenerated]
			private FeralPlugin <plugin>P;

			public BinderWorkAround(FeralPlugin plugin)
			{
				<plugin>P = plugin;
				((LcInputActions)this)..ctor();
			}

			public override void CreateInputActions(in InputActionMapBuilder builder)
			{
				<plugin>P.CompleteWorkAroundPartOne(ref builder);
			}
		}

		protected override void Load()
		{
			((FeralPlugin)this).RegisterConfigs(typeof(Config));
			((FeralPlugin)this).RegisterButtons(typeof(Buttons));
			BinderWorkAround binderWorkAround = new BinderWorkAround((FeralPlugin)(object)this);
			((FeralPlugin)this).CompleteWorkAroundPartTwo((LcInputActions)(object)binderWorkAround);
			HarmonyExtension.PatchNamespace(((FeralPlugin)this).Harmony, "FeralMinimap.Patches");
			Buttons.InitController();
			Config.InitController();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FeralMinimap";

		public const string PLUGIN_NAME = "FeralMinimap";

		public const string PLUGIN_VERSION = "0.0.11";
	}
}
namespace FeralMinimap.Util
{
	public static class MagicNumbers
	{
		public const float MinimapYPosPadding = -8f;

		public const float DefaultNearClipPlane = -2.47f;

		public const float HangerShipNearClipPlane = -0.96f;

		public const float DefaultMinimapEulerY = 315f;

		public static readonly Vector3 TargetPosOffset = new Vector3(0f, 3.636f, 0f);
	}
	public enum RotationStrategy
	{
		Default,
		Target,
		North,
		East,
		South,
		West
	}
}
namespace FeralMinimap.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	public static class HUDManagerPatch
	{
		private static GameObject _minimapViewGameObject;

		public static RectTransform Tooltips { get; private set; }

		public static Vector2 TooltipsOrigin { get; private set; }

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void PostFix_Awake(HUDManager __instance, ref HUDElement ___Tooltips)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			Tooltips = ((Component)___Tooltips.canvasGroup).gameObject.GetComponent<RectTransform>();
			TooltipsOrigin = Tooltips.anchoredPosition;
			if (Object.op_Implicit((Object)(object)_minimapViewGameObject))
			{
				Object.Destroy((Object)(object)_minimapViewGameObject);
			}
			_minimapViewGameObject = new GameObject("FeralMinimapView");
			_minimapViewGameObject.transform.SetParent(((Component)__instance.playerScreenTexture).transform, false);
			_minimapViewGameObject.AddComponent<MinimapView>();
		}
	}
	[HarmonyPatch(typeof(ManualCameraRenderer))]
	public static class ManualCameraRendererPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Postfix_Update(ref PlayerControllerB ___targetedPlayer, ref Light ___mapCameraLight)
		{
			if (Object.op_Implicit((Object)(object)___mapCameraLight) && Object.op_Implicit((Object)(object)___targetedPlayer))
			{
				((Behaviour)___mapCameraLight).enabled = ___targetedPlayer.isInsideFactory;
				if (Object.op_Implicit((Object)(object)Player.LocalPlayerNullable()))
				{
					___mapCameraLight.cullingMask = ~Player.LocalPlayer().gameplayCamera.cullingMask;
				}
			}
		}
	}
	[HarmonyPatch(typeof(RadarBoosterItem))]
	public static class RadarBoosterPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void PostFix_Update(RadarBoosterItem __instance)
		{
			if (Config<BoolConfig, bool>.op_Implicit((Config<BoolConfig, bool>)(object)Config.Fixes.AlwaysShowRadarBoosters))
			{
				__instance.radarDot.SetActive(true);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class StartOfRoundPatch
	{
		private static GameObject _minimapCamera;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void PostFix_Awake(StartOfRound __instance)
		{
			if (Object.op_Implicit((Object)(object)_minimapCamera))
			{
				Object.Destroy((Object)(object)_minimapCamera);
			}
			_minimapCamera = Object.Instantiate<GameObject>(((Component)__instance.mapScreen.mapCamera).gameObject);
			((Object)_minimapCamera).name = "FeralMinimapCamera";
			_minimapCamera.AddComponent<MinimapCamera>();
		}
	}
}
namespace FeralMinimap.Behaviors
{
	public class MinimapCamera : MonoBehaviour
	{
		public static MinimapCamera Instance;

		public Camera Camera { get; private set; }

		public HDAdditionalCameraData CameraData { get; private set; }

		public Light Light { get; private set; }

		public MinimapTarget Target { get; private set; }

		private void Awake()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Camera = ((Component)this).gameObject.GetComponent<Camera>();
			((Object)Camera).name = "FeralMinimapCamera";
			Camera camera = Camera;
			camera.cullingMask += Mask.op_Implicit(Mask.Unused1);
			Camera.aspect = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Minimap.AspectRatio);
			Camera.orthographic = true;
			Camera.orthographicSize = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Minimap.Zoom);
			CameraData = ((Component)this).gameObject.GetComponent<HDAdditionalCameraData>();
			Light = ((Component)this).gameObject.AddComponent<Light>();
			Light.type = (LightType)1;
			Light.range = 100f;
			Light.color = Color.white;
			Light.colorTemperature = 6500f;
			Light.useColorTemperature = true;
			Light.cullingMask = Mask.op_Implicit(Mask.Unused1);
			Light.intensity = Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Config.Minimap.InsideBrightness);
			((Behaviour)Light).enabled = false;
			Target = ((Component)this).gameObject.AddComponent<MinimapTarget>();
		}

		private void Start()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Camera.targetTexture = MinimapView.Instance.Feed;
			((TMP_Text)MinimapView.Instance.Text).font = ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).font;
			((Graphic)MinimapView.Instance.Text).material = ((Graphic)StartOfRound.Instance.mapScreenPlayerName).material;
			((Graphic)MinimapView.Instance.Text).color = ((Graphic)StartOfRound.Instance.mapScreenPlayerName).color;
		}

		private void Update()
		{
			//IL_001b: 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)
			((Component)Camera).transform.eulerAngles = new Vector3(90f, GetEulerY(), 0f);
			((Component)Camera).transform.position = Target.Position;
			Camera.nearClipPlane = Target.NearClipPlane;
			Light.intensity = Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Config.Minimap.InsideBrightness);
			((Behaviour)Light).enabled = Target.RequiresLighting;
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)Camera))
			{
				Object.Destroy((Object)(object)Camera);
			}
			if (Object.op_Implicit((Object)(object)CameraData))
			{
				Object.Destroy((Object)(object)CameraData);
			}
			if (Object.op_Implicit((Object)(object)Light))
			{
				Object.Destroy((Object)(object)Light);
			}
			if (Object.op_Implicit((Object)(object)Target))
			{
				Object.Destroy((Object)(object)Target);
			}
			if (Object.op_Implicit((Object)(object)Instance))
			{
				Object.Destroy((Object)(object)Instance);
			}
		}

		internal void UpdateCameraSize()
		{
			//IL_0046: 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)
			Camera.orthographicSize = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Minimap.Zoom);
			Camera.aspect = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Minimap.AspectRatio);
			Camera.pixelRect = new Rect(0f, 0f, (float)Config.Minimap.Width, (float)Config.Minimap.Height);
			Camera.rect = new Rect(0f, 0f, 1f, 1f);
		}

		private float GetEulerY()
		{
			RotationStrategy value = ((Config<EnumConfig<RotationStrategy>, RotationStrategy>)(object)Config.Minimap.Rotation).Value;
			return value switch
			{
				RotationStrategy.Default => 315f, 
				RotationStrategy.Target => Target.EulerY, 
				RotationStrategy.North => 90f, 
				RotationStrategy.East => 180f, 
				RotationStrategy.South => 270f, 
				RotationStrategy.West => 0f, 
				_ => throw new ArgumentOutOfRangeException("strategy", value, $"Invalid rotation strategy: {value}"), 
			};
		}
	}
	public class MinimapTarget : MonoBehaviour
	{
		private int _index;

		private PlayerControllerB? _player;

		private RadarBoosterItem? _radar;

		private TransformAndName? _target;

		public static MinimapTarget Instance { get; private set; }

		public string Name { get; private set; } = string.Empty;


		public Vector3 Position { get; private set; } = Vector3.zero;


		public float EulerY { get; private set; } = 315f;


		public float NearClipPlane { get; private set; } = -2.47f;


		public bool RequiresLighting { get; private set; }

		private static List<TransformAndName> PotentialTargets => StartOfRound.Instance.mapScreen.radarTargets;

		private void Awake()
		{
			Instance = this;
		}

		private void Update()
		{
			InvalidateCache();
			if (ValidateIndex())
			{
				FetchData();
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)Instance))
			{
				Object.Destroy((Object)(object)Instance);
			}
		}

		private bool ValidateIndex()
		{
			if (PotentialTargets.Count == 0)
			{
				return false;
			}
			if (_index < 0)
			{
				_index = 0;
			}
			if (_index >= PotentialTargets.Count)
			{
				_index = PotentialTargets.Count - 1;
			}
			TransformAndName target = PotentialTargets[_index];
			int index = _index;
			while (!IsTargetValid(target, out _player, out _radar))
			{
				_index++;
				if (_index >= PotentialTargets.Count)
				{
					_index = 0;
				}
				if (_index == index)
				{
					return false;
				}
				target = PotentialTargets[_index];
			}
			_target = target;
			return true;
		}

		private void InvalidateCache()
		{
			_target = null;
			_player = null;
			_radar = null;
		}

		private static bool IsTargetValid(TransformAndName target, out PlayerControllerB? player, out RadarBoosterItem? radar)
		{
			player = null;
			radar = null;
			if (target.isNonPlayer)
			{
				radar = ((Component)target.transform).gameObject.GetComponent<RadarBoosterItem>();
				return true;
			}
			player = ((Component)target.transform).gameObject.GetComponent<PlayerControllerB>();
			if (Object.op_Implicit((Object)(object)player))
			{
				if (!player.isPlayerDead)
				{
					return player.isPlayerControlled;
				}
				return true;
			}
			return false;
		}

		internal void SwitchNextTarget()
		{
			if (_index < 0 || _index + 1 >= PotentialTargets.Count)
			{
				_index = 0;
			}
			else
			{
				_index++;
			}
		}

		private void FetchData()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			Position = _target.transform.position + MagicNumbers.TargetPosOffset;
			EulerY = _target.transform.eulerAngles.y;
			NearClipPlane = -2.47f;
			RequiresLighting = false;
			if (Object.op_Implicit((Object)(object)_player))
			{
				Name = "Player: " + _target.name;
				if (_player.isInHangarShipRoom)
				{
					NearClipPlane = -0.96f;
				}
				if (_player.isInsideFactory)
				{
					RequiresLighting = true;
				}
			}
			else if (Object.op_Implicit((Object)(object)_radar))
			{
				if (((GrabbableObject)_radar).isInFactory)
				{
					RequiresLighting = true;
				}
				Name = "Radar: " + _target.name;
				EulerY = 315f;
			}
			else
			{
				Name = "Unknown: " + _target.name;
				RequiresLighting = false;
			}
		}
	}
	public class MinimapView : MonoBehaviour
	{
		public static MinimapView Instance;

		public RawImage Image { get; private set; }

		public RenderTexture Feed { get; private set; }

		public TextMeshProUGUI Text { get; private set; }

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_008b: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Image = ((Component)this).gameObject.AddComponent<RawImage>();
			((Graphic)Image).rectTransform.pivot = new Vector2(1f, 1f);
			((Graphic)Image).rectTransform.anchorMin = new Vector2(1f, 1f);
			((Graphic)Image).rectTransform.anchorMax = new Vector2(1f, 1f);
			((Graphic)Image).rectTransform.sizeDelta = new Vector2((float)Config.Minimap.Width, (float)Config.Minimap.Height);
			((Graphic)Image).rectTransform.anchoredPosition = new Vector2((float)(Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Config.Minimap.XPosOffset) * -1), (float)(Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Config.Minimap.YPosOffset) * -1) + -8f);
			UpdateFeedSize();
			Text = new GameObject("FeralMinimapText").AddComponent<TextMeshProUGUI>();
			((TMP_Text)Text).transform.SetParent((Transform)(object)((Graphic)Image).rectTransform, false);
			((TMP_Text)Text).rectTransform.pivot = new Vector2(0f, 1f);
			((TMP_Text)Text).rectTransform.anchorMin = new Vector2(0f, 1f);
			((TMP_Text)Text).rectTransform.anchorMax = new Vector2(0f, 1f);
			((TMP_Text)Text).rectTransform.sizeDelta = new Vector2((float)Config.Minimap.Width, (float)Config.Minimap.Height);
			((TMP_Text)Text).rectTransform.anchoredPosition = new Vector2(0f, 0f);
			((TMP_Text)Text).text = "Initializing FeralMinimap...";
			((TMP_Text)Text).fontSizeMax = 20f;
			((TMP_Text)Text).fontSizeMin = 1f;
			((TMP_Text)Text).enableWordWrapping = false;
			((TMP_Text)Text).enableAutoSizing = true;
			AdjustTooltips();
		}

		private void Update()
		{
			((TMP_Text)Text).text = MinimapCamera.Instance.Target.Name;
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)Image))
			{
				Object.Destroy((Object)(object)Image);
			}
			if (Object.op_Implicit((Object)(object)Feed))
			{
				Object.Destroy((Object)(object)Feed);
			}
			if (Object.op_Implicit((Object)(object)Text))
			{
				Object.Destroy((Object)(object)Text);
			}
			if (Object.op_Implicit((Object)(object)Instance))
			{
				Object.Destroy((Object)(object)Instance);
			}
		}

		internal void UpdateViewSize()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)Image).rectTransform.sizeDelta = new Vector2((float)Config.Minimap.Width, (float)Config.Minimap.Height);
			((TMP_Text)Text).rectTransform.sizeDelta = new Vector2((float)Config.Minimap.Width, (float)Config.Minimap.Height);
			UpdateFeedSize();
			AdjustTooltips();
		}

		internal void UpdateFeedSize()
		{
			//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)
			//IL_003a: 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_004d: Expected O, but got Unknown
			RenderTexture feed = Feed;
			Feed = new RenderTexture((int)((float)Config.Minimap.Width * Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Minimap.CameraFeedQuality)), (int)((float)Config.Minimap.Height * Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Minimap.CameraFeedQuality)), 32, (GraphicsFormat)8)
			{
				isPowerOfTwo = true,
				filterMode = (FilterMode)0,
				anisoLevel = 0
			};
			Image.texture = (Texture)(object)Feed;
			if (Object.op_Implicit((Object)(object)MinimapCamera.Instance) && Object.op_Implicit((Object)(object)MinimapCamera.Instance.Camera))
			{
				MinimapCamera.Instance.Camera.targetTexture = Feed;
			}
			Object.Destroy((Object)(object)feed);
		}

		internal static void AdjustTooltips()
		{
			//IL_0044: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (ButtonToggle.op_Implicit(Buttons.MinimapEnabled))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0f, (float)(Config.Minimap.Height + Config<IntConfig, int>.op_Implicit((Config<IntConfig, int>)(object)Config.Minimap.YPosOffset)));
				HUDManagerPatch.Tooltips.anchoredPosition = HUDManagerPatch.TooltipsOrigin - val;
			}
			else
			{
				HUDManagerPatch.Tooltips.anchoredPosition = HUDManagerPatch.TooltipsOrigin;
			}
		}
	}
}