Decompiled source of ColoredPingChat v1.2.1

PingChat.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using IL.RoR2.UI;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
internal static class log
{
	private static ManualLogSource logger;

	internal static void start(ManualLogSource logSource)
	{
		logger = logSource;
	}

	internal static void start(string name)
	{
		logger = Logger.CreateLogSource(name);
	}

	internal static void info(object data)
	{
		logger.LogInfo(data);
	}

	internal static void message(object data)
	{
		logger.LogMessage(data);
	}

	internal static void warning(object data)
	{
		logger.LogWarning(data);
	}

	internal static void error(object data)
	{
		logger.LogError(data);
	}

	internal static void fatal(object data)
	{
		logger.LogFatal(data);
	}
}
namespace PingChat;

internal static class Assets
{
	private const string assetbundleName = "itemicon";

	internal static Shader itemIconShader;

	internal static void LoadAssetBundle(PluginInfo pluginInfo)
	{
		try
		{
			AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "itemicon"));
			itemIconShader = obj.LoadAsset<Shader>("ItemIcon.shader");
			if (!Object.op_Implicit((Object)(object)itemIconShader))
			{
				log.error("failed to load itemIconShader");
			}
			obj.Unload(false);
		}
		catch (Exception ex)
		{
			log.error("Failed to load assetbundle. Make sure your assetbundle name is setup correctly\n" + ex);
		}
	}
}
internal static class Config
{
	internal static ConfigFile configFile;

	internal static ConfigEntry<KeyboardShortcut> PCChatKey;

	internal static ConfigEntry<float> PCItemScale;

	internal static ConfigEntry<float> PCMove;

	internal static ConfigEntry<float> PCInteract;

	internal static ConfigEntry<float> PCItem;

	internal static ConfigEntry<float> PCEnemy;

	internal static ConfigEntry<bool> PCChatToggle;

	internal static ConfigEntry<bool> PCItemIconToggle;

	internal static ConfigEntry<bool> PCShopItemIconToggle;

	internal static ConfigEntry<bool> PCEnemyIconToggle;

	internal static ConfigEntry<bool> PCEnemyIconColorToggle;

	internal static IDictionary<EliteIndex, ConfigEntry<Vector4>> PCEliteColors = new Dictionary<EliteIndex, ConfigEntry<Vector4>>();

	internal static ConfigEntry<Vector4> PCItemIconColor;

	internal static ConfigEntry<Vector4> PCInteractableIconColor;

	internal static void DoConfigs()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		configFile = new ConfigFile(Paths.ConfigPath + "//PingChat.cfg", true);
		PCChatKey = configFile.Bind<KeyboardShortcut>("Misc", "Key", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "The key for sending a custom chat message");
		PCItemScale = configFile.Bind<float>("Misc", "Item icon scale", 0.67f, "Scale of item icon in pings");
		PCMove = configFile.Bind<float>("Durations", "Move ping duration", 6f, "Duration of move here ping");
		PCInteract = configFile.Bind<float>("Durations", "Interactives ping duration", 30f, "Duration of interactives ping. Includes chests, shops, printers, teleporter, etc");
		PCItem = configFile.Bind<float>("Durations", "Item ping duration", 60f, "Duration of item ping. Includes scrappers and potentials");
		PCEnemy = configFile.Bind<float>("Durations", "Enemy ping duration", 8f, "Duration of attack enemy ping");
		PCChatToggle = configFile.Bind<bool>("Toggles", "Chat coloring toggle", true, "Toggles the coloring of chat");
		PCEnemyIconToggle = configFile.Bind<bool>("Toggles", "Enemy icon toggle", true, "Toggles changing the ping icons for enemies to their logbook icons");
		PCEnemyIconColorToggle = configFile.Bind<bool>("Toggles", "Elite enemy icon coloring toggle", true, "Toggles the coloring of elite enemy ping icons. If false, but icons are on, will use color of 'None'");
		PCItemIconToggle = configFile.Bind<bool>("Toggles", "Item icon toggle", true, "Toggles changing the ping icons for items to their logbook icons");
		PCShopItemIconToggle = configFile.Bind<bool>("Toggles", "Item icon toggle for multishops and printers", true, "Toggles changing the ping icons for items in multishops and printers");
		PCEliteColors.Add((EliteIndex)0, configFile.Bind<Vector4>("Elite colors", "Blazing", new Vector4(203f, 53f, 38f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)2, configFile.Bind<Vector4>("Elite colors", "Celestine", new Vector4(141f, 202f, 204f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)3, configFile.Bind<Vector4>("Elite colors", "Glacial", new Vector4(214f, 245f, 248f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)5, configFile.Bind<Vector4>("Elite colors", "Overloading", new Vector4(77f, 115f, 255f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)7, configFile.Bind<Vector4>("Elite colors", "Perfected", new Vector4(86f, 116f, 148f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)8, configFile.Bind<Vector4>("Elite colors", "Malachite", new Vector4(148f, 219f, 156f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)10, configFile.Bind<Vector4>("Elite colors", "Mending", new Vector4(161f, 231f, 79f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)13, configFile.Bind<Vector4>("Elite colors", "Voidtouched", new Vector4(219f, 113f, 237f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCEliteColors.Add((EliteIndex)(-1), configFile.Bind<Vector4>("Elite colors", "None", new Vector4(255f, 255f, 255f, 255f), "Color32: (Red, Green, Blue, Alpha), 0 to 255"));
		PCItemIconColor = configFile.Bind<Vector4>("IColor", "Item icon color", new Vector4(255f, 255f, 255f, 255f), "Color of pinged item icons");
		PCInteractableIconColor = configFile.Bind<Vector4>("IColor", "Pinged interactable color", new Vector4(226f, 222f, 44f, 255f), "Color of pinged nteractables");
	}
}
[BepInPlugin("dolso.pingchat", "ColoredPingChat", "1.2.1")]
public class PingChat : BaseUnityPlugin
{
	private static EliteIndex currentEliteIndex = (EliteIndex)(-1);

	private static PickupDef currentPickupDef = null;

	private static Shader defaultSpriteShader;

	private void Awake()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		log.start(((BaseUnityPlugin)this).Logger);
		Config.DoConfigs();
		Assets.LoadAssetBundle(((BaseUnityPlugin)this).Info);
		PlayerCharacterMasterController.CheckPinging += new hook_CheckPinging(Messages.OnHook_CheckPinging);
		PingIndicator.RebuildPing += new hook_RebuildPing(OnHook_RebuildPing);
		PingIndicator.RebuildPing += new Manipulator(ILHook_RebuildPing);
		log.info("PingChat loaded");
	}

	private void Update()
	{
		Messages.CheckInput();
	}

	private void OnHook_RebuildPing(orig_RebuildPing orig, PingIndicator self)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Invalid comparison between Unknown and I4
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Invalid comparison between Unknown and I4
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		self.defaultPingDuration = Config.PCMove.Value;
		self.interactablePingDuration = Config.PCInteract.Value;
		self.enemyPingDuration = Config.PCEnemy.Value;
		if ((Object)(object)defaultSpriteShader == (Object)null)
		{
			defaultSpriteShader = ((Renderer)self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>()).material.shader;
		}
		else
		{
			SpriteRenderer component = self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>();
			((Renderer)component).material.shader = defaultSpriteShader;
			((Component)component).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
		}
		orig.Invoke(self);
		if ((int)self.pingType == 1 && Config.PCEnemyIconToggle.Value)
		{
			SpriteRenderer component2 = self.enemyPingGameObjects[0].GetComponent<SpriteRenderer>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				Debug.LogWarning((object)"no sprite");
				return;
			}
			CharacterBody component3 = self.pingTarget.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component3))
			{
				Debug.LogWarning((object)"no body");
				return;
			}
			Texture portraitIcon = component3.portraitIcon;
			Texture2D val = (Texture2D)(object)((portraitIcon is Texture2D) ? portraitIcon : null);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
			component2.sprite = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f));
			if (Config.PCEnemyIconColorToggle.Value)
			{
				component2.color = Color.op_Implicit(Config.PCEliteColors[currentEliteIndex].Value / 255f);
			}
			else
			{
				component2.color = Color.op_Implicit(Config.PCEliteColors[(EliteIndex)(-1)].Value / 255f);
			}
			currentEliteIndex = (EliteIndex)(-1);
		}
		else if ((int)self.pingType == 2 && currentPickupDef != null && Config.PCItemIconToggle.Value)
		{
			SpriteRenderer component4 = self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>();
			if (!Object.op_Implicit((Object)(object)component4))
			{
				Debug.LogWarning((object)"no sprite");
				return;
			}
			component4.sprite = currentPickupDef.iconSprite;
			((Component)component4).transform.localScale = new Vector3(Config.PCItemScale.Value * 0.1f, Config.PCItemScale.Value * 0.1f, 0.1f);
			currentPickupDef = null;
		}
	}

	private void ILHook_RebuildPing(ILContext il)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0547: Unknown result type (might be due to invalid IL or missing references)
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		int textLabel = 4;
		if (!val.TryGotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(Util), "GetBestBodyName"),
			(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref textLabel)
		}))
		{
			log.error("failed to find text");
			textLabel = 4;
		}
		val.GotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "PLAYER_PING_ENEMY"),
			(Instruction x) => ILPatternMatchingExt.MatchCall<Language>(x, "GetString")
		});
		val.Index += 4;
		val.EmitDelegate<Func<string, string>>((Func<string, string>)delegate(string text)
		{
			//IL_0015: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Config.PCEliteColors.Count - 1; i++)
			{
				string stringFormatted = Language.GetStringFormatted(EliteCatalog.GetEliteDef(Config.PCEliteColors.ElementAt(i).Key).modifierToken, new object[1] { "" });
				if (text.Contains(stringFormatted))
				{
					Color val4 = Color.op_Implicit(Config.PCEliteColors.ElementAt(i).Value.Value / 255f);
					currentEliteIndex = Config.PCEliteColors.ElementAt(i).Key;
					if (Config.PCChatToggle.Value)
					{
						text = text.Replace(stringFormatted, Util.GenerateColoredString(stringFormatted, Color32.op_Implicit(val4)));
					}
					break;
				}
			}
			return text;
		});
		int interactableIcon = 8;
		if (!val.TryGotoNext(new Func<Instruction, bool>[3]
		{
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PingIndicator>(a, "get_pingTarget"),
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PingIndicator>(a, "GetInteractableIcon"),
			(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref interactableIcon)
		}))
		{
			log.error("failed to find interactableIcon");
			interactableIcon = 8;
		}
		int component3Label = 9;
		if (!val.TryGotoNext(new Func<Instruction, bool>[3]
		{
			(Instruction a) => ILPatternMatchingExt.MatchLdelemRef(a),
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(a, "GetComponent"),
			(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref component3Label)
		}))
		{
			log.error("failed to find component3");
			component3Label = 9;
		}
		int pickupIndexLabel = 17;
		if (!val.TryGotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<ShopTerminalBehavior>(a, "CurrentPickupIndex"),
			(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref pickupIndexLabel)
		}))
		{
			log.error("failed to find pickupIndex");
			pickupIndexLabel = 17;
		}
		val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, pickupIndexLabel),
			(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.PickupCatalog", "GetPickupDef")
		});
		val.Emit(OpCodes.Dup);
		val.Emit(OpCodes.Ldloc, interactableIcon);
		val.Emit(OpCodes.Ldloc, component3Label);
		val.EmitDelegate<Func<PickupDef, Sprite, SpriteRenderer, Sprite>>((Func<PickupDef, Sprite, SpriteRenderer, Sprite>)delegate(PickupDef pickupDef, Sprite sprite, SpriteRenderer spriteRenderer)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (Config.PCShopItemIconToggle.Value && pickupDef != null && (Object)(object)pickupDef.iconSprite != (Object)null)
			{
				sprite = pickupDef.iconSprite;
				((Renderer)spriteRenderer).material.shader = Assets.itemIconShader;
				((Component)spriteRenderer).transform.localScale = new Vector3(Config.PCItemScale.Value * 0.1f, Config.PCItemScale.Value * 0.1f, 0.1f);
			}
			return sprite;
		});
		val.Emit(OpCodes.Stloc, interactableIcon);
		val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
		{
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Language>(a, "GetString")
		});
		val.Emit(OpCodes.Ldloc, pickupIndexLabel);
		val.EmitDelegate<Func<string, PickupIndex, string>>((Func<string, PickupIndex, string>)((string name, PickupIndex pickupindex) => Config.PCChatToggle.Value ? Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(pickupindex).baseColor)) : name));
		val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "?")
		});
		val.Emit(OpCodes.Ldloc, pickupIndexLabel);
		val.EmitDelegate<Func<string, PickupIndex, string>>((Func<string, PickupIndex, string>)((string name, PickupIndex pickupindex) => Config.PCChatToggle.Value ? Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(pickupindex).baseColor)) : name));
		ILLabel val3 = default(ILLabel);
		ILLabel val2 = default(ILLabel);
		val.GotoNext(new Func<Instruction, bool>[6]
		{
			(Instruction a) => ILPatternMatchingExt.MatchBrtrue(a, ref val3),
			(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0),
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PingIndicator>(a, "get_pingTarget"),
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(a, "GetComponent"),
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Object>(a, "op_Implicit"),
			(Instruction a) => ILPatternMatchingExt.MatchBrfalse(a, ref val2)
		});
		val.RemoveRange(5);
		val.GotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
			(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 60f)
		});
		val.Index += 1;
		val.Remove();
		val.EmitDelegate<Func<float>>((Func<float>)(() => Config.PCItem.Value));
		val.Index += 1;
		val.Emit(OpCodes.Ldloc, textLabel);
		val.Emit(OpCodes.Ldarg_0);
		val.Emit(OpCodes.Call, (MethodBase)typeof(PingIndicator).GetMethod("get_pingTarget"));
		val.EmitDelegate<Func<string, GameObject, string>>((Func<string, GameObject, string>)delegate(string name, GameObject target)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			//IL_0062: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			GenericPickupController component = target.GetComponent<GenericPickupController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				currentPickupDef = PickupCatalog.GetPickupDef(component.pickupIndex);
				if (Config.PCChatToggle.Value)
				{
					return Util.GenerateColoredString(name, Color32.op_Implicit(currentPickupDef.baseColor));
				}
				return name;
			}
			if (!Config.PCChatToggle.Value)
			{
				return name;
			}
			PickupIndexNetworker component2 = target.GetComponent<PickupIndexNetworker>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component2.pickupIndex).baseColor));
			}
			PickupDropletController component3 = target.GetComponent<PickupDropletController>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				Debug.Log((object)"PICKUPDROPLETCONTROLLER");
				return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component3.pickupIndex).baseColor));
			}
			return name;
		});
		val.Emit(OpCodes.Stloc, textLabel);
		val.Index += 3;
		val.Emit(OpCodes.Ldloc, component3Label);
		val.EmitDelegate<Func<Color>>((Func<Color>)(() => (Config.PCItemIconToggle.Value && currentPickupDef != null) ? Color.op_Implicit(Config.PCItemIconColor.Value / 255f) : Color.op_Implicit(Config.PCInteractableIconColor.Value / 255f)));
		val.Emit(OpCodes.Callvirt, (MethodBase)typeof(SpriteRenderer).GetMethod("set_color"));
	}

	[ConCommand(/*Could not decode attribute arguments.*/)]
	private static void CCReloadConfig(ConCommandArgs args)
	{
		Config.configFile.Reload();
	}
}
internal static class Messages
{
	private static bool keyDown;

	private static bool keySpent;

	internal static void CheckInput()
	{
		//IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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)
		KeyboardShortcut value = Config.PCChatKey.Value;
		if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
		{
			keyDown = true;
		}
		value = Config.PCChatKey.Value;
		if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey))
		{
			keyDown = false;
			keySpent = false;
		}
	}

	internal static void OnHook_CheckPinging(orig_CheckPinging orig, PlayerCharacterMasterController self)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Invalid comparison between Unknown and I4
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Invalid comparison between Unknown and I4
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self);
		if (!keyDown || keySpent)
		{
			return;
		}
		PingIndicator pingIndicator = self.pingerController.pingIndicator;
		GameObject val = ((pingIndicator != null) ? pingIndicator.pingTarget : null);
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		if ((int)pingIndicator.pingType == 1)
		{
			string userName = val.GetComponent<CharacterBody>().GetUserName();
			SendChatMessage("Attack " + userName);
		}
		else
		{
			if ((int)pingIndicator.pingType != 2)
			{
				return;
			}
			IDisplayNameProvider componentInParent = val.GetComponentInParent<IDisplayNameProvider>();
			if (componentInParent == null)
			{
				log.error("null displayNameProvider");
				return;
			}
			string displayName = componentInParent.GetDisplayName();
			if (Object.op_Implicit((Object)(object)val.GetComponent<GenericPickupController>()))
			{
				SendChatMessage("pickup " + displayName);
			}
			else if (Object.op_Implicit((Object)(object)val.GetComponent<SceneExitController>()))
			{
				SendChatMessage("hit the " + displayName);
			}
			else if (Object.op_Implicit((Object)(object)val.GetComponent<PickupIndexNetworker>()) && Object.op_Implicit((Object)(object)val.GetComponent<PickupPickerController>()))
			{
				SendChatMessage("open this " + displayName);
			}
			else if (Object.op_Implicit((Object)(object)val.GetComponent<ShopTerminalBehavior>()))
			{
				ShopTerminalBehavior component = val.GetComponent<ShopTerminalBehavior>();
				SendChatMessage(string.Format(arg1: (component.pickupIndexIsHidden || !Object.op_Implicit((Object)(object)component.pickupDisplay)) ? "?" : Language.GetString(PickupCatalog.GetPickupDef(component.CurrentPickupIndex())?.nameToken ?? PickupCatalog.invalidPickupToken), provider: CultureInfo.InvariantCulture, format: "{0} ({1}) here", arg0: displayName));
			}
			else
			{
				SendChatMessage(displayName + " here");
			}
		}
		keySpent = true;
	}

	private static void SendChatMessage(string message)
	{
		Console.instance.SubmitCmd(NetworkUser.readOnlyLocalPlayersList[0], "say \"" + message + "\"", false);
	}
}