Decompiled source of DescriptionOverride v1.0.0

BepInEx/plugins/DescriptionOverride.dll

Decompiled 5 days 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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DescriptionOverride")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0")]
[assembly: AssemblyProduct("DescriptionOverride")]
[assembly: AssemblyTitle("DescriptionOverride")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 DescriptionOverride
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DescriptionOverride";

		public const string PLUGIN_NAME = "DescriptionOverride";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}
namespace DescriptionOverrideMod
{
	[BepInPlugin("com.yourname.descriptionoverride", "DescriptionOverride", "1.0.0")]
	[MycoMod(/*Could not decode attribute arguments.*/)]
	public class DescriptionOverridePlugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> EnableOverride;

		internal static ConfigEntry<bool> EnableHashetty;

		internal static ManualLogSource Logger;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			EnableOverride = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDescriptionOverride", true, "If true, uses the serialized _description field instead of TextBlocks.");
			EnableHashetty = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableHashettyOverride", true, "If true, applies Hashetty font toggles in descriptions.");
			Harmony val = new Harmony("com.yourname.descriptionoverride");
			val.PatchAll();
			Logger.LogInfo((object)(val.Id + " loaded!"));
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public static class DescriptionPatch
	{
		private static bool Prefix(Upgrade __instance, ref string __result)
		{
			if (!DescriptionOverridePlugin.EnableOverride.Value)
			{
				return true;
			}
			string text = null;
			FieldInfo fieldInfo = null;
			try
			{
				GearUpgrade val = (GearUpgrade)(object)((__instance is GearUpgrade) ? __instance : null);
				if (val != null)
				{
					fieldInfo = AccessTools.Field(typeof(GearUpgrade), "_description");
					if (fieldInfo != null)
					{
						text = (string)fieldInfo.GetValue(val);
					}
				}
				else
				{
					PlayerUpgrade val2 = (PlayerUpgrade)(object)((__instance is PlayerUpgrade) ? __instance : null);
					if (val2 != null)
					{
						fieldInfo = AccessTools.Field(typeof(PlayerUpgrade), "_description");
						if (fieldInfo != null)
						{
							text = (string)fieldInfo.GetValue(val2);
						}
					}
				}
			}
			catch (Exception ex)
			{
				DescriptionOverridePlugin.Logger.LogWarning((object)("DescriptionPatch: Failed to get raw desc for " + __instance.APIName + ": " + ex.Message));
			}
			if (!string.IsNullOrEmpty(text))
			{
				__result = text;
				return false;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}