Decompiled source of Sound Pack Name Fix v1.0.0

SoundPackNameFix.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("SoundPackNameFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SoundPackNameFix")]
[assembly: AssemblyTitle("SoundPackNameFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 SoundPackNameFix
{
	[BepInPlugin("themorningstar.soundpacknamefix", "Sound Pack Name Fix", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "themorningstar.soundpacknamefix";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				Type type = AccessTools.TypeByName("loaforcsSoundAPI.SoundPacks.Data.SoundPack");
				MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "Validate", (Type[])null, (Type[])null) : null);
				if (methodInfo == null)
				{
					Log.LogError((object)"SoundPackNameFix: SoundPack.Validate not found; no patch applied.");
					return;
				}
				new Harmony("themorningstar.soundpacknamefix").Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Patch).GetMethod("AllowDigits")), (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)"SoundPackNameFix: sound-pack names may now contain digits (IsLetter -> IsLetterOrDigit).");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("SoundPackNameFix failed: " + ex));
			}
		}
	}
	internal static class Patch
	{
		public static IEnumerable<CodeInstruction> AllowDigits(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo isLetter = AccessTools.Method(typeof(char), "IsLetter", new Type[1] { typeof(char) }, (Type[])null);
			MethodInfo isLetterOrDigit = AccessTools.Method(typeof(char), "IsLetterOrDigit", new Type[1] { typeof(char) }, (Type[])null);
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, isLetter))
				{
					yield return new CodeInstruction(OpCodes.Call, (object)isLetterOrDigit);
				}
				else
				{
					yield return instruction;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}