Decompiled source of Pingprovements Fixed v1.0.1

Pingprovements_fixed.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Pingprovements_fixed")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Pingprovements_fixed")]
[assembly: AssemblyTitle("Pingprovements_fixed")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Pingprovements
{
	public static class Extensions
	{
		public static void SetObjectValue(this object obj, string fieldName, object value)
		{
			obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, value);
		}

		public static T GetObjectValue<T>(this object obj, string fieldName)
		{
			return (T)obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj);
		}

		public static Color ToColor(this string colorString)
		{
			//IL_003b: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			float[] array = Array.ConvertAll(colorString.Split(','), (string str) => float.Parse(str, CultureInfo.InvariantCulture));
			return new Color(array[0], array[1], array[2], array[3]);
		}

		public static bool IsObjectVisible(this Camera camera, Transform targetObjectTransform)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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)
			Vector3 val = camera.WorldToViewportPoint(targetObjectTransform.position);
			if (val.x >= 0f && val.x <= 1f && val.y >= 0f && val.y <= 1f && val.z > 0f)
			{
				return true;
			}
			return false;
		}
	}
	internal class PingerController
	{
		private readonly Dictionary<string, Color> _colors = new Dictionary<string, Color>();

		private readonly List<PingIndicator> _pingIndicators = new List<PingIndicator>();

		private static PingPainter _painter;

		private static PingTextBuilder _textBuilder;

		private static PingNotificationBuilder _notificationBuilder;

		private PingerController lastController;

		public PingerController(Pingprovements plugin)
		{
			_painter = new PingPainter();
			_textBuilder = new PingTextBuilder();
			_notificationBuilder = new PingNotificationBuilder();
		}

		public void OnSceneUnloaded(Scene scene)
		{
			_pingIndicators.Clear();
		}

		public void SetCurrentPing(orig_SetCurrentPing orig, PingerController self, PingInfo newPingInfo)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0053: 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_0060: 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_0087: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Invalid comparison between Unknown and I4
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			if (!(newPingInfo.origin == Vector3.zero))
			{
				lastController = self;
				self.NetworkcurrentPing = newPingInfo;
				GameObject val = (GameObject)Object.Instantiate(Resources.Load("Prefabs/PingIndicator"));
				PingIndicator component = val.GetComponent<PingIndicator>();
				component.pingOwner = ((Component)self).gameObject;
				component.pingOrigin = newPingInfo.origin;
				component.pingNormal = newPingInfo.normal;
				component.pingTarget = ((PingInfo)(ref newPingInfo)).targetGameObject;
				component.RebuildPing();
				PingType objectValue = component.GetObjectValue<PingType>("pingType");
				_painter.SetPingIndicatorColor(component, objectValue);
				_textBuilder.SetPingText(component, objectValue);
				SetPingTimer(component, objectValue);
				if ((int)objectValue == 2)
				{
					_notificationBuilder.SetUnlockedItemNotification(component);
				}
				_pingIndicators.Add(component);
				if (((NetworkBehaviour)self).hasAuthority)
				{
					self.CallCmdPing(self.currentPing);
				}
			}
		}

		private void SetPingTimer(PingIndicator pingIndicator, PingType pingType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			float num = 0f;
			switch ((int)pingType)
			{
			case 0:
				num = Pingprovements.DefaultPingLifetime.Value;
				break;
			case 1:
				num = Pingprovements.EnemyPingLifetime.Value;
				break;
			case 2:
				num = Pingprovements.InteractablePingLifetime.Value;
				break;
			}
			pingIndicator.SetObjectValue("fixedTimer", num);
		}

		public bool GeneratePingInfo(orig_GeneratePingInfo orig, Ray aimRay, GameObject bodyObject, out PingInfo result)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (!orig.Invoke(aimRay, bodyObject, ref result))
			{
				return false;
			}
			GameObject target = ((PingInfo)(ref result)).targetGameObject;
			if ((Object)(object)lastController != (Object)null)
			{
				lastController.currentPing = PingerController.emptyPing;
			}
			if ((Object)(object)target != (Object)null)
			{
				PingIndicator val = ((IEnumerable<PingIndicator>)_pingIndicators).FirstOrDefault((Func<PingIndicator, bool>)((PingIndicator ind) => Object.op_Implicit((Object)(object)ind) && (Object)(object)ind.pingTarget == (Object)(object)target));
				if ((Object)(object)val != (Object)null)
				{
					val.DestroyPing();
					_pingIndicators.Remove(val);
					result = default(PingInfo);
					return false;
				}
			}
			return true;
		}
	}
	public class PingIndicator
	{
		public PingIndicator(Pingprovements plugin)
		{
		}

		public void Update(orig_Update orig, PingIndicator self)
		{
			//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_0057: 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)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser != null)
			{
				if (Pingprovements.ShowPingDistance.Value && Object.op_Implicit((Object)(object)firstLocalUser.cachedBody))
				{
					Vector3 footPosition = default(Vector3);
					((Vector3)(ref footPosition))..ctor(0f, 0f, 0f);
					footPosition = firstLocalUser.cachedBody.footPosition;
					float num = Vector3.Distance(footPosition, ((Component)self).transform.position);
					int num2 = ((TMP_Text)self.pingText).text.IndexOf('\u200b');
					string text = ((num2 >= 0) ? ((TMP_Text)self.pingText).text.Substring(0, num2) : ((TMP_Text)self.pingText).text);
					((TMP_Text)self.pingText).text = text + "\u200b" + $" ({num:0.0}m)";
				}
				if (Pingprovements.HideOffscreenPingText.Value)
				{
					if (!firstLocalUser.cameraRigController.sceneCam.IsObjectVisible(((Component)self).transform))
					{
						((TMP_Text)self.pingText).alpha = 0f;
					}
					else
					{
						((TMP_Text)self.pingText).alpha = 1f;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)self.pingTarget))
			{
				BarrelInteraction component = self.pingTarget.GetComponent<BarrelInteraction>();
				if (Object.op_Implicit((Object)(object)component) && component.Networkopened)
				{
					Object.Destroy((Object)(object)((Component)self).gameObject);
				}
			}
			orig.Invoke(self);
		}
	}
	public class PingNotificationBuilder
	{
		public void SetUnlockedItemNotification(PingIndicator pingIndicator)
		{
			//IL_002e: 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)
			GenericPickupController component = pingIndicator.pingTarget.GetComponent<GenericPickupController>();
			if (Object.op_Implicit((Object)(object)component) && Pingprovements.ShowItemNotification.Value)
			{
				BuildNotification(component._pickupState.pickupIndex, pingIndicator);
			}
			PurchaseInteraction component2 = pingIndicator.pingTarget.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component2) && Pingprovements.ShowItemNotification.Value)
			{
				ShopTerminalBehavior component3 = ((Component)component2).GetComponent<ShopTerminalBehavior>();
				if (Object.op_Implicit((Object)(object)component3) && !component3.pickupIndexIsHidden)
				{
					BuildNotification(component3.CurrentPickup().pickupIndex, pingIndicator);
				}
			}
		}

		private void BuildNotification(PickupIndex pickupIndex, PingIndicator pingIndicator)
		{
			//IL_0035: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (!(firstLocalUser.currentNetworkUser.userName == Util.GetBestMasterName(pingIndicator.pingOwner.GetComponent<CharacterMaster>())) || !firstLocalUser.userProfile.HasDiscoveredPickup(pickupIndex))
			{
				return;
			}
			CharacterMasterNotificationQueue notificationQueueForMaster = CharacterMasterNotificationQueue.GetNotificationQueueForMaster(pingIndicator.pingOwner.GetComponent<CharacterMaster>());
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
			ArtifactDef artifactDef = ArtifactCatalog.GetArtifactDef(pickupDef.artifactIndex);
			if ((Object)(object)itemDef != (Object)null)
			{
				CustomOverrideInfo val = new CustomOverrideInfo();
				if (Pingprovements.ShowDetailsDescription.Value)
				{
					val.SetDescriptionText(itemDef.descriptionToken);
				}
				NotificationInfo val2 = new NotificationInfo((object)itemDef, (TransformationInfo)null, val, false);
				notificationQueueForMaster.PushNotification(val2, (float)Pingprovements.NotificationLifetime.Value);
			}
			if ((Object)(object)equipmentDef != (Object)null)
			{
				CustomOverrideInfo val3 = new CustomOverrideInfo();
				if (Pingprovements.ShowDetailsDescription.Value)
				{
					val3.SetDescriptionText(equipmentDef.descriptionToken);
				}
				NotificationInfo val4 = new NotificationInfo((object)equipmentDef, (TransformationInfo)null, val3, false);
				notificationQueueForMaster.PushNotification(val4, (float)Pingprovements.NotificationLifetime.Value);
			}
			if ((Object)(object)artifactDef != (Object)null)
			{
				CustomOverrideInfo val5 = new CustomOverrideInfo();
				if (Pingprovements.ShowDetailsDescription.Value)
				{
					val5.SetDescriptionText(artifactDef.descriptionToken);
				}
				NotificationInfo val6 = new NotificationInfo((object)artifactDef, (TransformationInfo)null, val5, false);
				notificationQueueForMaster.PushNotification(val6, (float)Pingprovements.NotificationLifetime.Value);
			}
		}
	}
	public class PingPainter
	{
		private readonly Dictionary<string, Color> _colors = new Dictionary<string, Color>();

		public void SetPingIndicatorColor(PingIndicator pingIndicator, PingType pingType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected I4, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0069: 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_0074: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00bd: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			SpriteRenderer val = new SpriteRenderer();
			Color color = Color.black;
			Color color2 = Color.black;
			switch ((int)pingType)
			{
			case 0:
				val = pingIndicator.defaultPingGameObjects[0].GetComponent<SpriteRenderer>();
				color = Pingprovements.DefaultPingColorConfig.Value;
				color2 = Pingprovements.DefaultPingSpriteColorConfig.Value;
				break;
			case 1:
				val = pingIndicator.enemyPingGameObjects[0].GetComponent<SpriteRenderer>();
				color = Pingprovements.EnemyPingColorConfig.Value;
				color2 = Pingprovements.EnemyPingSpriteColorConfig.Value;
				break;
			case 2:
				val = pingIndicator.interactablePingGameObjects[0].GetComponent<SpriteRenderer>();
				if (Pingprovements.TieredInteractablePingColor.Value)
				{
					Color targetTierColor = GetTargetTierColor(pingIndicator.pingTarget);
					color = targetTierColor;
					color2 = targetTierColor;
				}
				else
				{
					color = Pingprovements.InteractablePingColorConfig.Value;
					color2 = Pingprovements.InteractablePingSpriteColorConfig.Value;
				}
				break;
			}
			((Graphic)pingIndicator.pingText).color = color;
			val.color = color2;
		}

		private Color GetTargetTierColor(GameObject gameObject)
		{
			//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_001c: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			//IL_0098: 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_00ab: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00f7: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			Color val = Color.black;
			ShopTerminalBehavior component = gameObject.GetComponent<ShopTerminalBehavior>();
			if (Object.op_Implicit((Object)(object)component))
			{
				PickupIndex pickupIndex = component.CurrentPickup().pickupIndex;
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
				if (pickupDef != null)
				{
					val = pickupDef.baseColor;
				}
			}
			GenericPickupController component2 = gameObject.GetComponent<GenericPickupController>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				PickupDef pickupDef2 = PickupCatalog.GetPickupDef(component2._pickupState.pickupIndex);
				if (pickupDef2 != null)
				{
					val = pickupDef2.baseColor;
				}
			}
			PurchaseInteraction component3 = gameObject.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				CostTypeDef costTypeDef = CostTypeCatalog.GetCostTypeDef(component3.costType);
				val = Color32.op_Implicit(ColorCatalog.GetColor(costTypeDef.colorIndex));
			}
			PickupIndexNetworker component4 = gameObject.GetComponent<PickupIndexNetworker>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				PickupDef pickupDef3 = PickupCatalog.GetPickupDef(component4.NetworkpickupState.pickupIndex);
				if (pickupDef3 != null)
				{
					val = pickupDef3.baseColor;
				}
			}
			if (val == Color.black)
			{
				val = Pingprovements.InteractablePingColorConfig.Value;
			}
			return val;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.ebi.pingprovements_fixed", "Pingprovements Fixed!", "1.0.0")]
	public class Pingprovements : BaseUnityPlugin
	{
		public static ConfigEntry<int> DefaultPingLifetime;

		public static ConfigEntry<int> EnemyPingLifetime;

		public static ConfigEntry<int> InteractablePingLifetime;

		public static ConfigEntry<int> NotificationLifetime;

		public static ConfigEntry<Color> DefaultPingColorConfig;

		public static ConfigEntry<Color> DefaultPingSpriteColorConfig;

		public static ConfigEntry<Color> EnemyPingColorConfig;

		public static ConfigEntry<Color> EnemyPingSpriteColorConfig;

		public static ConfigEntry<Color> InteractablePingColorConfig;

		public static ConfigEntry<Color> InteractablePingSpriteColorConfig;

		public static ConfigEntry<bool> ShowPickupText;

		public static ConfigEntry<bool> ShowChestText;

		public static ConfigEntry<bool> ShowShopText;

		public static ConfigEntry<bool> ShowDroneText;

		public static ConfigEntry<bool> ShowShrineText;

		public static ConfigEntry<bool> ShowEnemyText;

		public static ConfigEntry<bool> ShowPingDistance;

		public static ConfigEntry<bool> HideOffscreenPingText;

		public static ConfigEntry<bool> ShowItemNotification;

		public static ConfigEntry<bool> ShowDetailsDescription;

		public static ConfigEntry<bool> TieredInteractablePingColor;

		public void Awake()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Expected O, but got Unknown
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Expected O, but got Unknown
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Expected O, but got Unknown
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Expected O, but got Unknown
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Expected O, but got Unknown
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Expected O, but got Unknown
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Expected O, but got Unknown
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Expected O, but got Unknown
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Expected O, but got Unknown
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Expected O, but got Unknown
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Expected O, but got Unknown
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Expected O, but got Unknown
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Expected O, but got Unknown
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Expected O, but got Unknown
			DefaultPingLifetime = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Default Lifetime", 6, "Time in seconds how long a regular 'walk to' ping indicator should be shown on the map");
			EnemyPingLifetime = ((BaseUnityPlugin)this).Config.Bind<int>("Enemies", "Enemy Lifetime", 8, "Time in seconds how long a ping indicator for enemies should be shown on the map");
			InteractablePingLifetime = ((BaseUnityPlugin)this).Config.Bind<int>("Interactables", "Interactable Lifetime", 30, "Time in seconds how long a ping indicator for interactables should be shown on the map");
			NotificationLifetime = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Notification Lifetime", 30, "Time in seconds how long the notification with an item description will be shown");
			DefaultPingColorConfig = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "Default Color", new Color(0.525f, 0.961f, 0.486f, 1f), "Color of the default ping");
			DefaultPingSpriteColorConfig = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "Default Sprite Color", new Color(0.527f, 0.962f, 0.486f, 1f), "Color of the default ping sprite");
			EnemyPingColorConfig = ((BaseUnityPlugin)this).Config.Bind<Color>("Enemies", "Enemy Color", new Color(0.82f, 0.122f, 0.122f, 1f), "Color of the enemy ping");
			EnemyPingSpriteColorConfig = ((BaseUnityPlugin)this).Config.Bind<Color>("Enemies", "Enemy Sprite Color", new Color(0.821f, 0.12f, 0.12f, 1f), "Color of the enemy ping sprite");
			InteractablePingColorConfig = ((BaseUnityPlugin)this).Config.Bind<Color>("Interactables", "Interactable Color", new Color(0.886f, 0.871f, 0.173f, 1f), "Color of the interactable ping");
			InteractablePingSpriteColorConfig = ((BaseUnityPlugin)this).Config.Bind<Color>("Interactables", "Interactable Sprite Color", new Color(0.887f, 0.87f, 0.172f, 1f), "Color of the interactable ping sprite");
			ShowPickupText = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Items", true, "Shows item names on ping");
			ShowChestText = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Chests", true, "Shows item names and cost on chest pings");
			ShowShopText = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Terminals", true, "Shows item names and cost on shop terminal pings");
			ShowDroneText = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Drones", true, "Shows drone type on broken drone pings");
			ShowShrineText = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Shrines", true, "Shows shrine type on shrine pings");
			ShowEnemyText = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Enemies", true, "Shows names on enemy pings");
			ShowPingDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Distance", true, "Show distance to ping in ping label");
			HideOffscreenPingText = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide Offscreen Pings", true, "Hide text of offscreen pings to prevent cluttering");
			ShowItemNotification = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Item Description", true, "Show pickup-style notification with description on ping of an already discovered item");
			ShowDetailsDescription = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", "Detailed Description", true, "Show detailed description in the item notification. Requires Show Item Description to be enabled");
			TieredInteractablePingColor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Tier Color", true, "Color pings in their target tier color");
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(DefaultPingLifetime));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(EnemyPingLifetime));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(InteractablePingLifetime));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(DefaultPingColorConfig));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(DefaultPingSpriteColorConfig));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(EnemyPingColorConfig));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(EnemyPingSpriteColorConfig));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(InteractablePingColorConfig));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(InteractablePingSpriteColorConfig));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowPickupText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowChestText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowShopText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowDroneText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowShrineText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowEnemyText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowPingDistance));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(HideOffscreenPingText));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowItemNotification));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ShowDetailsDescription));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(TieredInteractablePingColor));
			PingIndicator pingIndicator = new PingIndicator(this);
			PingerController pingerController = new PingerController(this);
			PingerController.SetCurrentPing += new hook_SetCurrentPing(pingerController.SetCurrentPing);
			PingerController.GeneratePingInfo += new hook_GeneratePingInfo(pingerController.GeneratePingInfo);
			PingIndicator.Update += new hook_Update(pingIndicator.Update);
			SceneManager.sceneUnloaded += pingerController.OnSceneUnloaded;
		}

		public void log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}
	}
	public class PingTextBuilder
	{
		public void SetPingText(PingIndicator pingIndicator, PingType pingType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected I4, but got Unknown
			switch ((int)pingType)
			{
			case 0:
				break;
			case 1:
				AddEnemyText(pingIndicator);
				break;
			case 2:
				AddLootText(pingIndicator);
				break;
			}
		}

		private static void AddEnemyText(PingIndicator pingIndicator)
		{
			string bestBodyName = Util.GetBestBodyName(pingIndicator.pingTarget);
			if (Pingprovements.ShowEnemyText.Value)
			{
				TextMeshPro pingText = pingIndicator.pingText;
				((TMP_Text)pingText).text = ((TMP_Text)pingText).text + "<size=70%>\n" + bestBodyName;
			}
		}

		private static void AddLootText(PingIndicator pingIndicator)
		{
			//IL_0040: 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_004a: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			string price = GetPrice(pingIndicator.pingTarget);
			ShopTerminalBehavior component = pingIndicator.pingTarget.GetComponent<ShopTerminalBehavior>();
			if (Object.op_Implicit((Object)(object)component) && Pingprovements.ShowShopText.Value)
			{
				string text = "<size=70%>\n";
				PickupIndex pickupIndex = component.CurrentPickup().pickupIndex;
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
				text += (component.pickupIndexIsHidden ? "?" : (Language.GetString(pickupDef.nameToken) ?? ""));
				TextMeshPro pingText = pingIndicator.pingText;
				((TMP_Text)pingText).text = ((TMP_Text)pingText).text + text + " (" + price + ")";
				return;
			}
			GenericPickupController component2 = pingIndicator.pingTarget.GetComponent<GenericPickupController>();
			if (Object.op_Implicit((Object)(object)component2) && Pingprovements.ShowPickupText.Value)
			{
				PickupDef pickupDef2 = PickupCatalog.GetPickupDef(component2._pickupState.pickupIndex);
				TextMeshPro pingText2 = pingIndicator.pingText;
				((TMP_Text)pingText2).text = ((TMP_Text)pingText2).text + "<size=70%>\n" + Language.GetString(pickupDef2.nameToken);
			}
			ChestBehavior component3 = pingIndicator.pingTarget.GetComponent<ChestBehavior>();
			if (Object.op_Implicit((Object)(object)component3) && Pingprovements.ShowChestText.Value)
			{
				TextMeshPro pingText = pingIndicator.pingText;
				((TMP_Text)pingText).text = ((TMP_Text)pingText).text + "<size=70%>\n" + Util.GetBestBodyName(pingIndicator.pingTarget) + " (" + price + ")";
				return;
			}
			string text2 = "";
			PurchaseInteraction component4 = pingIndicator.pingTarget.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				text2 = Language.GetString(component4.displayNameToken);
			}
			SummonMasterBehavior component5 = pingIndicator.pingTarget.GetComponent<SummonMasterBehavior>();
			if (Object.op_Implicit((Object)(object)component5) && Pingprovements.ShowDroneText.Value)
			{
				TextMeshPro pingText = pingIndicator.pingText;
				((TMP_Text)pingText).text = ((TMP_Text)pingText).text + "<size=70%>\n" + text2 + " (" + price + ")";
			}
			else if (Pingprovements.ShowShrineText.Value)
			{
				TextMeshPro pingText3 = pingIndicator.pingText;
				((TMP_Text)pingText3).text = ((TMP_Text)pingText3).text + "<size=70%>\n" + text2;
			}
		}

		private static string GetPrice(GameObject go)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			PurchaseInteraction component = go.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component))
			{
				StringBuilder stringBuilder = new StringBuilder();
				CostTypeCatalog.GetCostTypeDef(component.costType).BuildCostStringStyled(component.cost, stringBuilder, true, true);
				return stringBuilder.ToString();
			}
			return null;
		}
	}
}