Decompiled source of StackTooltips v1.0.2

StackTooltips.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("StackTooltips")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+70f2d6543e008e9820cf9bc47705d1fcdba3ab80")]
[assembly: AssemblyProduct("StackTooltips")]
[assembly: AssemblyTitle("StackTooltips")]
[assembly: AssemblyVersion("1.0.2.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 StackTooltips
{
	[BepInPlugin("thereborngeek.stacktooltips", "Stack Tooltips", "1.0.2")]
	public class StackTooltipsPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetSceneAwakePatch
		{
			private static void Postfix(ZNetScene __instance)
			{
				List<string> list = new List<string>();
				foreach (GameObject prefab in __instance.m_prefabs)
				{
					if (Object.op_Implicit((Object)(object)prefab))
					{
						Piece component = prefab.GetComponent<Piece>();
						if (Object.op_Implicit((Object)(object)component) && IsStackOrPile(component.m_name) && prefab.GetComponentInChildren<Hoverable>(true) == null)
						{
							prefab.AddComponent<HoverText>().m_text = component.m_name;
							list.Add(((Object)prefab).name);
						}
					}
				}
				if (list.Count > 0)
				{
					s_log.LogInfo((object)string.Format("Added hover names to {0} pieces: {1}", list.Count, string.Join(", ", list)));
				}
			}
		}

		public const string Guid = "thereborngeek.stacktooltips";

		public const string Name = "Stack Tooltips";

		public const string Version = "1.0.2";

		private const string TokenPrefix = "$piece_";

		private static ManualLogSource s_log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			s_log = ((BaseUnityPlugin)this).Logger;
			new Harmony("thereborngeek.stacktooltips").PatchAll(typeof(StackTooltipsPlugin).Assembly);
		}

		internal static bool IsStackOrPile(string pieceName)
		{
			if (pieceName != null && pieceName.StartsWith("$piece_", StringComparison.Ordinal))
			{
				if (!pieceName.EndsWith("stack", StringComparison.Ordinal))
				{
					return pieceName.EndsWith("pile", StringComparison.Ordinal);
				}
				return true;
			}
			return false;
		}
	}
}