Decompiled source of AlwaysShowTamingHUD v0.1.1

plugins/AlwaysShowTamingHUD.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("AlwaysShowTamingHUD")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AlwaysShowTamingHUD")]
[assembly: AssemblyTitle("AlwaysShowTamingHUD")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 AlwaysShowTaming
{
	[BepInPlugin("com.yourname.alwaysshowtaminghud", "Always Show Taming HUD", "1.0.0")]
	public class TamingOverlayPlugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.yourname.alwaysshowtaminghud";

		public const string ModName = "Always Show Taming HUD";

		public const string ModVersion = "1.0.0";

		public static ConfigEntry<float> OverlayRange;

		public static ConfigEntry<bool> RequireLineOfSight;

		public static ConfigEntry<int> FontSize;

		private GUIStyle _textStyle;

		private GUIStyle _shadowStyle;

		private void Awake()
		{
			OverlayRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "OverlayRange", 25f, "Maximum distance (in meters) to display the taming overlay.");
			RequireLineOfSight = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RequireLineOfSight", true, "If true, text will be hidden if the animal is behind solid obstacles.");
			FontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Display", "FontSize", 14, "Font size for the overhead status label.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Always Show Taming HUD 1.0.0 initialized.");
		}

		private void SetupStyles()
		{
			//IL_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0056: 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_0071: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (_textStyle == null)
			{
				_textStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = FontSize.Value,
					fontStyle = (FontStyle)1
				};
				_textStyle.normal.textColor = new Color(1f, 0.85f, 0.2f);
				_shadowStyle = new GUIStyle(_textStyle);
				_shadowStyle.normal.textColor = new Color(0f, 0f, 0f, 0.85f);
			}
		}

		private void OnGUI()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_009c: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Camera.main == (Object)null || Hud.IsUserHidden())
			{
				return;
			}
			SetupStyles();
			Camera main = Camera.main;
			Vector3 position = ((Component)main).transform.position;
			LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Default", "static_solid", "piece" }));
			Rect val4 = default(Rect);
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if ((Object)(object)allCharacter == (Object)null || allCharacter.IsDead())
				{
					continue;
				}
				Vector3 position2 = ((Component)allCharacter).transform.position;
				float num = Vector3.Distance(position, position2);
				if (num > OverlayRange.Value)
				{
					continue;
				}
				Tameable component = ((Component)allCharacter).GetComponent<Tameable>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				ZNetView component2 = ((Component)allCharacter).GetComponent<ZNetView>();
				if ((Object)(object)component2 == (Object)null || !component2.IsValid() || component2.GetZDO().GetBool(ZDOVars.s_tamed, false))
				{
					continue;
				}
				float num2 = component2.GetZDO().GetFloat(ZDOVars.s_tameTimeLeft, -1f);
				if (num2 < 0f)
				{
					continue;
				}
				Vector3 val2 = allCharacter.GetTopPoint() + Vector3.up * 0.4f;
				if (RequireLineOfSight.Value && Physics.Raycast(position, val2 - position, num, LayerMask.op_Implicit(val)))
				{
					continue;
				}
				Vector3 val3 = main.WorldToScreenPoint(val2);
				if (!(val3.z <= 0f))
				{
					float num3 = Mathf.Clamp01(1f - num2 / component.m_tamingTime) * 100f;
					string text = "";
					MonsterAI component3 = ((Component)allCharacter).GetComponent<MonsterAI>();
					if ((Object)(object)component3 != (Object)null && ((BaseAI)component3).IsAlerted())
					{
						text = " <color=red>[Frightened]</color>";
					}
					else if (component.IsHungry())
					{
						text = " <color=orange>[Hungry]</color>";
					}
					string text2 = allCharacter.GetHoverName() + text + "\n" + $"Taming: {num3:0}%\n" + "Time Left: " + FormatTime(num2);
					float num4 = (float)Screen.height - val3.y;
					((Rect)(ref val4))..ctor(val3.x - 125f, num4 - 45f, 250f, 70f);
					GUI.Label(new Rect(((Rect)(ref val4)).x + 1f, ((Rect)(ref val4)).y + 1f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text2, _shadowStyle);
					GUI.Label(val4, text2, _textStyle);
				}
			}
		}

		private static string FormatTime(float seconds)
		{
			int num = Mathf.Max(0, (int)seconds);
			int num2 = num / 60;
			int num3 = num % 60;
			return $"{num2}m {num3:00}s";
		}
	}
}