Decompiled source of PSE Fix v1.0.0

PSEFix.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PSEFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("PSEFix")]
[assembly: AssemblyCopyright("Copyright © Geezt Lifetime")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PSEFix;

[BepInPlugin("GeeztJeez.PSEFix", "PSEFix", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			new Harmony("PSEFix").PatchAll(Assembly.GetExecutingAssembly());
			Debug.Log((object)"[PSEFix] Harmony patched successfully!");
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[PSEFix] Harmony patch failed: " + ex));
			Debug.Log((object)"Please contact Geezt Jeez or try reloading the game for proper installation...");
		}
	}
}
[HarmonyPatch(typeof(PlaySoundEffect), "Go")]
public class PlaySoundEffectPSEPatch
{
	private static bool Prefix(PlaySoundEffect __instance)
	{
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		MethodInfo method = typeof(PlaySoundEffect).GetMethod("Init", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method != null)
		{
			method.Invoke(__instance, null);
		}
		FieldInfo field = typeof(PlaySoundEffect).GetField("soundRef", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field2 = typeof(PlaySoundEffect).GetField("soundPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
		string text = ((field != null) ? field.GetValue(__instance) : null) as string;
		object? obj = ((field2 != null) ? field2.GetValue(__instance) : null);
		SoundPlayer val = (SoundPlayer)((obj is SoundPlayer) ? obj : null);
		if (string.IsNullOrEmpty(text) || (Object)(object)val == (Object)null)
		{
			return false;
		}
		float num = 1f;
		float num2 = 1f;
		Match match = Regex.Match(text, "\\(p=([\\d.]+)\\)");
		Match match2 = Regex.Match(text, "\\(v=([\\d.]+)\\)");
		if (match.Success && float.TryParse(match.Groups[1].Value, out var result))
		{
			num = result;
		}
		if (match2.Success && float.TryParse(match2.Groups[1].Value, out var result2))
		{
			num2 = result2;
		}
		string text2 = Regex.Replace(text, "\\(p=[\\d.]+\\)|\\(v=[\\d.]+\\)", "").Trim();
		val.PlaySoundEffect(text2, num2, ((Component)__instance).transform.position, (MaterialType)0, (Transform)null, num);
		return false;
	}
}