Decompiled source of NametagModifier v1.0.3

NametagModifier.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 HarmonyLib;
using Microsoft.CodeAnalysis;
using NametagModifier.Patches;
using NametagModifier.Settings;
using SettingsExtender;
using Unity.Mathematics;
using UnityEngine;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("NametagModifier")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+324e92bbe96cf97ac042ddad24b4da687cb39601")]
[assembly: AssemblyProduct("NametagModifier")]
[assembly: AssemblyTitle("NametagModifier")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NametagModifier
{
	[BepInPlugin("club.freewifi.void.NameTagModifier", "NametagModifier", "1.0.2")]
	public class NametagModifier : BaseUnityPlugin
	{
		private const string ModGUID = "club.freewifi.void.NameTagModifier";

		private const string ModName = "NametagModifier";

		private const string ModVersion = "1.0.2";

		private static ConfigEntry<KeyCode> overrideKey = null;

		private static float lastOverrideTime = float.MinValue;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			overrideKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "Override Key", (KeyCode)116, "Pressing this key will show all nametags of all players for a set amount of time defined in the game settings, regardless of distance or camera angle.");
			SettingsRegistry.Register("NametagModifier");
			new Harmony("club.freewifi.void.NameTagModifier").PatchAll(typeof(ModifyNametag));
		}

		private void Start()
		{
			SettingsHandler.Instance.AddSetting((Setting)(object)new VisibleDistance());
			SettingsHandler.Instance.AddSetting((Setting)(object)new VisibleAngle());
			SettingsHandler.Instance.AddSetting((Setting)(object)new OverrideTime());
		}

		public static bool IsOverriding()
		{
			//IL_0032: 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)
			float value = ((FloatSetting)SettingsHandler.Instance.GetSetting<OverrideTime>()).Value;
			bool flag = Time.realtimeSinceStartup - lastOverrideTime < value;
			if (GUIManager.instance.windowBlockingInput)
			{
				return false;
			}
			if (Input.GetKeyDown(overrideKey.Value) && flag)
			{
				lastOverrideTime = float.MinValue;
				return false;
			}
			if (flag)
			{
				return true;
			}
			if (Input.GetKeyDown(overrideKey.Value))
			{
				lastOverrideTime = Time.realtimeSinceStartup;
				return true;
			}
			return false;
		}
	}
}
namespace NametagModifier.Settings
{
	public class OverrideTime : FloatSetting, IExposedSetting
	{
		public string GetDisplayName()
		{
			return "Override Time";
		}

		public string GetCategory()
		{
			return SettingsRegistry.GetPageId("NametagModifier");
		}

		protected override float GetDefaultValue()
		{
			return 20f;
		}

		protected override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(1f, 720f);
		}

		public override void ApplyValue()
		{
		}
	}
	public class VisibleAngle : FloatSetting, IExposedSetting
	{
		public string GetDisplayName()
		{
			return "Visible Angle";
		}

		public string GetCategory()
		{
			return SettingsRegistry.GetPageId("NametagModifier");
		}

		protected override float GetDefaultValue()
		{
			return 45f;
		}

		protected override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0f, 160f);
		}

		public override void ApplyValue()
		{
		}
	}
	public class VisibleDistance : FloatSetting, IExposedSetting
	{
		public string GetDisplayName()
		{
			return "Visible Distance";
		}

		public string GetCategory()
		{
			return SettingsRegistry.GetPageId("NametagModifier");
		}

		protected override float GetDefaultValue()
		{
			return 8f;
		}

		protected override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0f, 4000f);
		}

		public override void ApplyValue()
		{
		}
	}
}
namespace NametagModifier.Patches
{
	[HarmonyPatch(typeof(IsLookedAt), "Update")]
	public class ModifyNametag
	{
		public static void Prefix(IsLookedAt __instance)
		{
			float value = ((FloatSetting)SettingsHandler.Instance.GetSetting<VisibleDistance>()).Value;
			float value2 = ((FloatSetting)SettingsHandler.Instance.GetSetting<VisibleAngle>()).Value;
			if (NametagModifier.IsOverriding())
			{
				__instance.visibleDistance = 4000f;
				__instance.visibleAngle = 80f;
			}
			else
			{
				__instance.visibleDistance = value;
				__instance.visibleAngle = value2 / 2f;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}