Decompiled source of Multiping v1.0.0

multiping.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("multiping")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+daeb8fdc55301e55256e81e5dc9b8f6356a23453")]
[assembly: AssemblyProduct("multiping")]
[assembly: AssemblyTitle("multiping")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Multiping
{
	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_0009: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			ColorUtility.TryParseHtmlString(colorString, ref result);
			return result;
		}

		public static bool IsObjectVisible(this Camera camera, Transform targetObjectTransform)
		{
			//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_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_001a: 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_0034: 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)
			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;
		}
	}
	[BepInPlugin("com.orsa.multiping", "Multiping", "1.0.0")]
	public class Multiping : BaseUnityPlugin
	{
		private static MultipingConfig _config;

		public string test;

		public static MultipingConfig GetConfig()
		{
			return _config;
		}

		public Multiping()
		{
			_config = new MultipingConfig(((BaseUnityPlugin)this).Config);
			test = "";
			MonoBehaviour.print((object)test);
		}

		public void Awake()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			PingIndicator pingIndicator = new PingIndicator(this);
			PingerController pingerController = new PingerController(this);
			PingerController.SetCurrentPing += new hook_SetCurrentPing(pingerController.SetCurrentPing);
			PingerController.AttemptPing += new hook_AttemptPing(pingerController.AttemptPing);
			PingIndicator.Update += new hook_Update(pingIndicator.Update);
			SceneManager.sceneUnloaded += pingerController.OnSceneUnloaded;
		}
	}
	public class MultipingConfig
	{
		public ConfigEntry<int> DefaultPingLifetime { get; set; }

		public ConfigEntry<int> EnemyPingLifetime { get; set; }

		public ConfigEntry<int> InteractablePingLifetime { get; set; }

		public ConfigEntry<string> DefaultPingColorConfig { get; set; }

		public ConfigEntry<string> EnemyPingColorConfig { get; set; }

		public ConfigEntry<string> InteractablePingColorConfig { get; set; }

		public ConfigEntry<bool> TieredInteractablePingColor { get; set; }

		public ConfigEntry<string> DefaultPingSpriteColorConfig { get; set; }

		public ConfigEntry<string> EnemyPingSpriteColorConfig { get; set; }

		public ConfigEntry<string> InteractablePingSpriteColorConfig { get; set; }

		public ConfigEntry<bool> ShowShopText { get; set; }

		public ConfigEntry<bool> ShowChestText { get; set; }

		public ConfigEntry<bool> ShowPickupText { get; set; }

		public ConfigEntry<bool> ShowDroneText { get; set; }

		public ConfigEntry<bool> ShowShrineText { get; set; }

		public ConfigEntry<bool> ShowEnemyText { get; set; }

		public ConfigEntry<bool> ShowPingDistance { get; set; }

		public ConfigEntry<bool> HideOffscreenPingText { get; set; }

		public ConfigEntry<bool> ShowItemNotification { get; set; }

		public MultipingConfig(ConfigFile config)
		{
			DefaultPingLifetime = config.Bind<int>("Durations", "DefaultPingLifetime", 6, "Time in seconds how long a regular 'walk to' ping indicator should be shown on the map, 0 means it never expires");
			EnemyPingLifetime = config.Bind<int>("Durations", "EnemyPingLifetime", 30, "Time in seconds how long a ping indicator for enemies should be shown on the map, 0 means it never expires");
			InteractablePingLifetime = config.Bind<int>("Durations", "InteractablePingLifetime", 0, "Time in seconds how long a ping indicator for interactables should be shown on the map, 0 means it never expires");
			DefaultPingColorConfig = config.Bind<string>("Colors", "DefaultPingColor", "#86F57C", "Color of the default ping");
			DefaultPingSpriteColorConfig = config.Bind<string>("SpriteColors", "DefaultPingSpriteColor", "#86F57C", "Color of the default ping sprite");
			EnemyPingColorConfig = config.Bind<string>("Colors", "EnemyPingColor", "#D11F1F", "Color of the enemy ping");
			EnemyPingSpriteColorConfig = config.Bind<string>("SpriteColors", "EnemyPingSpriteColor", "#D11F1F", "Color of the enemy ping sprite");
			InteractablePingColorConfig = config.Bind<string>("Colors", "InteractablePingColor", "#E2DE2C", "Color of the interactable ping");
			InteractablePingSpriteColorConfig = config.Bind<string>("SpriteColors", "InteractablePingSpriteColor", "#E2DE2C", "Color of the interactable ping sprite");
			ShowPickupText = config.Bind<bool>("ShowPingText", "Pickups", true, "Shows item names on pickup pings");
			ShowChestText = config.Bind<bool>("ShowPingText", "Chests", false, "Shows item names and cost on chest pings");
			ShowShopText = config.Bind<bool>("ShowPingText", "ShopTerminals", false, "Shows item names and cost on shop terminal pings");
			ShowDroneText = config.Bind<bool>("ShowPingText", "Drones", true, "Shows drone type on broken drone pings");
			ShowShrineText = config.Bind<bool>("ShowPingText", "Shrines", false, "Shows shrine type on shrine pings");
			ShowEnemyText = config.Bind<bool>("ShowPingText", "Enemies", false, "Shows names on enemy pings");
			ShowPingDistance = config.Bind<bool>("ShowPingText", "Distance", false, "Show distance to ping in ping label");
			HideOffscreenPingText = config.Bind<bool>("ShowPingText", "HideOffscreenPingText", true, "Hide text of offscreen pings to prevent cluttering");
			ShowItemNotification = config.Bind<bool>("Notifications", "ShowItemNotification", true, "Show pickup-style notification with description on ping of an already discovered item");
			TieredInteractablePingColor = config.Bind<bool>("Colors", "TieredInteractablePingColor", true, "Color pings in their target tier color");
		}
	}
	internal class PingerController
	{
		private static MultipingConfig _config;

		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;

		public PingerController(Multiping plugin)
		{
			_config = Multiping.GetConfig();
			_painter = new PingPainter(_config);
			_textBuilder = new PingTextBuilder(_config);
			_notificationBuilder = new PingNotificationBuilder(_config);
		}

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

		public void SetCurrentPing(orig_SetCurrentPing orig, PingerController self, PingInfo newPingInfo)
		{
			//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_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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Invalid comparison between Unknown and I4
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			self.pingStock = 99;
			if (newPingInfo.origin == Vector3.zero)
			{
				return;
			}
			if ((Object)(object)((PingInfo)(ref newPingInfo)).targetGameObject != (Object)null)
			{
				PingIndicator val = ((IEnumerable<PingIndicator>)_pingIndicators).SingleOrDefault((Func<PingIndicator, bool>)((PingIndicator indicator) => Object.op_Implicit((Object)(object)indicator) && (Object)(object)indicator.pingTarget == (Object)(object)((PingInfo)(ref newPingInfo)).targetGameObject));
				Debug.Log((object)val);
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
					if (((NetworkBehaviour)self).hasAuthority)
					{
						self.CallCmdPing(newPingInfo);
					}
					return;
				}
			}
			self.NetworkcurrentPing = newPingInfo;
			PingIndicator component = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("Prefabs/PingIndicator")).GetComponent<PingIndicator>();
			component.pingOwner = ((Component)self).gameObject;
			component.pingOrigin = newPingInfo.origin;
			component.pingNormal = newPingInfo.normal;
			component.pingTarget = ((PingInfo)(ref newPingInfo)).targetGameObject;
			component.weakPointTarget = newPingInfo.weakPointObject;
			component.forceUseHitOriginForPosition = newPingInfo.forceUseHitOriginForPosition;
			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_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected I4, but got Unknown
			float num = 0f;
			switch ((int)pingType)
			{
			case 0:
				num = _config.DefaultPingLifetime.Value;
				break;
			case 1:
				num = _config.EnemyPingLifetime.Value;
				break;
			case 2:
				num = _config.InteractablePingLifetime.Value;
				break;
			}
			if (num <= 0f)
			{
				num = float.PositiveInfinity;
			}
			pingIndicator.SetObjectValue("fixedTimer", num);
		}

		public void AttemptPing(orig_AttemptPing orig, PingerController self, Ray aimRay, GameObject bodyObject)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			self.currentPing = PingerController.emptyPing;
			orig.Invoke(self, aimRay, bodyObject);
		}
	}
	public class PingIndicator
	{
		private static MultipingConfig _config;

		public PingIndicator(Multiping plugin)
		{
			_config = Multiping.GetConfig();
		}

		public void Update(orig_Update orig, PingIndicator self)
		{
			//IL_003f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser != null)
			{
				if (_config.ShowPingDistance.Value && Object.op_Implicit((Object)(object)firstLocalUser.cachedBody))
				{
					new Vector3(0f, 0f, 0f);
					float num = Vector3.Distance(firstLocalUser.cachedBody.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 (_config.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
	{
		private MultipingConfig _config;

		public PingNotificationBuilder(MultipingConfig config)
		{
			_config = config;
		}

		public void SetUnlockedItemNotification(PingIndicator pingIndicator)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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) && _config.ShowItemNotification.Value)
			{
				BuildNotification(component.pickup.pickupIndex, pingIndicator);
			}
			PurchaseInteraction component2 = pingIndicator.pingTarget.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component2) && _config.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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterMaster component = pingIndicator.pingOwner.GetComponent<CharacterMaster>();
			CharacterMasterNotificationQueue notificationQueueForMaster = CharacterMasterNotificationQueue.GetNotificationQueueForMaster(component);
			if (firstLocalUser.currentNetworkUser.userName == Util.GetBestMasterName(component) && firstLocalUser.userProfile.HasDiscoveredPickup(pickupIndex))
			{
				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)
				{
					notificationQueueForMaster.PushNotification(new NotificationInfo((object)itemDef, (TransformationInfo)null, false, 0), 6f);
				}
				else if ((Object)(object)equipmentDef != (Object)null)
				{
					notificationQueueForMaster.PushNotification(new NotificationInfo((object)equipmentDef, (TransformationInfo)null, false, 0), 6f);
				}
				else if ((Object)(object)artifactDef != (Object)null)
				{
					notificationQueueForMaster.PushNotification(new NotificationInfo((object)artifactDef, (TransformationInfo)null, false, 0), 6f);
				}
			}
		}
	}
	public class PingPainter
	{
		private readonly Dictionary<string, Color> _colors = new Dictionary<string, Color>();

		private readonly bool _tieredInteractablePingColor;

		public PingPainter(MultipingConfig config)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			_colors.Add("DefaultPingColor", config.DefaultPingColorConfig.Value.ToColor());
			_colors.Add("DefaultPingSpriteColor", config.DefaultPingSpriteColorConfig.Value.ToColor());
			_colors.Add("EnemyPingColor", config.EnemyPingColorConfig.Value.ToColor());
			_colors.Add("EnemyPingSpriteColor", config.EnemyPingSpriteColorConfig.Value.ToColor());
			_colors.Add("InteractablePingColor", config.InteractablePingColorConfig.Value.ToColor());
			_colors.Add("InteractablePingSpriteColor", config.InteractablePingSpriteColorConfig.Value.ToColor());
			_tieredInteractablePingColor = config.TieredInteractablePingColor.Value;
		}

		public void SetPingIndicatorColor(PingIndicator pingIndicator, PingType pingType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0006: 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_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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected I4, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0058: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00b1: 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 = _colors["DefaultPingColor"];
				color2 = _colors["DefaultPingSpriteColor"];
				break;
			case 1:
				val = pingIndicator.enemyPingGameObjects[0].GetComponent<SpriteRenderer>();
				color = _colors["EnemyPingColor"];
				color2 = _colors["EnemyPingSpriteColor"];
				break;
			case 2:
				val = pingIndicator.interactablePingGameObjects[0].GetComponent<SpriteRenderer>();
				if (_tieredInteractablePingColor)
				{
					color2 = (color = GetTargetTierColor(pingIndicator.pingTarget));
					break;
				}
				color = _colors["InteractablePingColor"];
				color2 = _colors["InteractablePingSpriteColor"];
				break;
			}
			((Graphic)pingIndicator.pingText).color = color;
			val.color = color2;
		}

		private Color GetTargetTierColor(GameObject gameObject)
		{
			//IL_0000: 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_0016: 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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00d8: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			Color val = Color.black;
			ShopTerminalBehavior component = gameObject.GetComponent<ShopTerminalBehavior>();
			if (Object.op_Implicit((Object)(object)component))
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(component.CurrentPickup().pickupIndex);
				if (pickupDef != null)
				{
					val = pickupDef.baseColor;
				}
			}
			GenericPickupController component2 = gameObject.GetComponent<GenericPickupController>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				PickupDef pickupDef2 = PickupCatalog.GetPickupDef(component2.pickup.pickupIndex);
				if (pickupDef2 != null)
				{
					val = pickupDef2.baseColor;
				}
			}
			PurchaseInteraction component3 = gameObject.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				val = Color32.op_Implicit(ColorCatalog.GetColor(CostTypeCatalog.GetCostTypeDef(component3.costType).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 = _colors["InteractablePingColor"];
			}
			return val;
		}
	}
	public class PingTextBuilder
	{
		private static MultipingConfig _config;

		public PingTextBuilder(MultipingConfig config)
		{
			_config = config;
		}

		public void SetPingText(PingIndicator pingIndicator, PingType pingType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			switch ((int)pingType)
			{
			case 1:
				AddEnemyText(pingIndicator);
				break;
			case 2:
				AddLootText(pingIndicator);
				break;
			case 0:
				break;
			}
		}

		private static void AddEnemyText(PingIndicator pingIndicator)
		{
			string bestBodyName = Util.GetBestBodyName(pingIndicator.pingTarget);
			if (_config.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_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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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) && _config.ShowShopText.Value)
			{
				string text = "<size=70%>\n";
				PickupDef pickupDef = PickupCatalog.GetPickupDef(component.CurrentPickup().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) && _config.ShowPickupText.Value)
			{
				PickupDef pickupDef2 = PickupCatalog.GetPickupDef(component2.pickup.pickupIndex);
				TextMeshPro pingText2 = pingIndicator.pingText;
				((TMP_Text)pingText2).text = ((TMP_Text)pingText2).text + "<size=70%>\n" + Language.GetString(pickupDef2.nameToken);
			}
			if (Object.op_Implicit((Object)(object)pingIndicator.pingTarget.GetComponent<ChestBehavior>()) && _config.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 component3 = pingIndicator.pingTarget.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				text2 = Language.GetString(component3.displayNameToken);
			}
			if (Object.op_Implicit((Object)(object)pingIndicator.pingTarget.GetComponent<SummonMasterBehavior>()) && _config.ShowDroneText.Value)
			{
				TextMeshPro pingText = pingIndicator.pingText;
				((TMP_Text)pingText).text = ((TMP_Text)pingText).text + "<size=70%>\n" + text2 + " (" + price + ")";
			}
			else if (_config.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_0016: 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;
		}
	}
}