Decompiled source of WhoseThisTeleport v1.0.0

WhoseThisTeleport.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("WhoseThisTeleport")]
[assembly: AssemblyConfiguration("Thunderstore")]
[assembly: AssemblyDescription("Shows whose teleport is it and with what button it was placed")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0badf9a5d5a0719963e88c3cd04cfbfaaed1b53a")]
[assembly: AssemblyProduct("WhoseThisTeleport")]
[assembly: AssemblyTitle("WhoseThisTeleport")]
[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 WhoseThisTeleport
{
	[BepInPlugin("com.almafa64.WhoseThisTeleport", "WhoseThisTeleport", "1.0.0")]
	[BepInProcess("BoplBattle.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static Harmony harmony;

		internal static ManualLogSource logger;

		internal static ConfigFile config;

		internal static ConfigEntry<float> fontSize;

		internal static ConfigEntry<bool> showEveryTeleport;

		internal static ConfigEntry<bool> whiteOnly;

		internal static ConfigEntry<string> textType;

		internal static ConfigEntry<Vector2> textOffset;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_014c: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			fontSize = config.Bind<float>("WhoseThisTeleport", "font size", 30f, (ConfigDescription)null);
			showEveryTeleport = config.Bind<bool>("WhoseThisTeleport", "show for every teleport", false, (ConfigDescription)null);
			whiteOnly = config.Bind<bool>("WhoseThisTeleport", "white only", false, "Turns off text coloring");
			textType = config.Bind<string>("WhoseThisTeleport", "text type", "arrow", new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "number", "arrow" }), Array.Empty<object>()));
			textOffset = config.Bind<Vector2>("WhoseThisTeleport", "text offset", new Vector2(15f, 3f), "offset from left of the portal");
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Teleport), "CastAbility", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "CastTeleport_Prefix", (Type[])null), new HarmonyMethod(typeof(Patches), "CastTeleport_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(GameSessionHandler), "SpawnPlayers", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "SpawnPlayers_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}
	internal class Patches
	{
		private static GameObject symbolGameObject;

		private static int thisId;

		private static string GetSymbolForAbility(int index)
		{
			string value = Plugin.textType.Value;
			if (1 == 0)
			{
			}
			string result;
			if (value == "number")
			{
				if (1 == 0)
				{
				}
				string text = index switch
				{
					0 => "1", 
					1 => "3", 
					2 => "2", 
					_ => "something bad happened lol", 
				};
				if (1 == 0)
				{
				}
				result = text;
			}
			else
			{
				if (1 == 0)
				{
				}
				string text = index switch
				{
					0 => "<", 
					1 => ">", 
					2 => "^", 
					_ => "something bad happened lol", 
				};
				if (1 == 0)
				{
				}
				result = text;
			}
			if (1 == 0)
			{
			}
			return result;
		}

		public static bool CastTeleport_Prefix(Teleport __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00f1: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			Traverse val = new Traverse((object)__instance);
			TeleportIndicator value = val.Field("teleportIndicator").GetValue<TeleportIndicator>();
			if ((Object)(object)value == (Object)null || ((MonoUpdatable)value).IsDestroyed)
			{
				InstantAbility value2 = val.Field("instantAbility").GetValue<InstantAbility>();
				SlimeController slimeController = ((AbilityMonoBehaviour)value2).GetSlimeController();
				if (!Plugin.showEveryTeleport.Value && slimeController.GetPlayerId() != thisId)
				{
					return true;
				}
				int index = slimeController.abilities.IndexOf((AbilityMonoBehaviour)(object)value2);
				symbolGameObject = new GameObject("portal button symbol");
				TextMeshPro val2 = symbolGameObject.AddComponent<TextMeshPro>();
				((TMP_Text)val2).text = GetSymbolForAbility(index);
				((TMP_Text)val2).fontSize = Plugin.fontSize.Value;
				((TMP_Text)val2).fontStyle = (FontStyles)1;
				((TMP_Text)val2).font = LocalizedText.localizationTable.GetFont((Language)0, true);
				((TMP_Text)val2).outlineWidth = 0.2f;
				((TMP_Text)val2).outlineColor = Color32.op_Implicit(Color.black);
				if (Plugin.whiteOnly.Value)
				{
					((Graphic)val2).color = Color.white;
				}
				else
				{
					((Graphic)val2).color = slimeController.GetPlayerMaterial().GetColor("_ShadowColor");
				}
			}
			return true;
		}

		public static void CastTeleport_Postfix(Teleport __instance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (Object.op_Implicit((Object)(object)symbolGameObject))
			{
				TeleportIndicator value = new Traverse((object)__instance).Field("teleportIndicator").GetValue<TeleportIndicator>();
				symbolGameObject.transform.SetParent(((Component)value).transform, false);
				symbolGameObject.transform.position = ((Component)value).transform.position + new Vector3(Plugin.textOffset.Value.x, Plugin.textOffset.Value.y);
				symbolGameObject = null;
			}
		}

		public static void SpawnPlayers_Postfix()
		{
			thisId = Object.FindObjectOfType<InputUpdater>().GetClaimerId();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WhoseThisTeleport";

		public const string PLUGIN_NAME = "WhoseThisTeleport";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}