Decompiled source of LangFix v1.0.0

DspLangFix.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using JetBrains.Annotations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace DspLangFix;

[BepInPlugin("LangFix_configuration", "LangFix", "1.0")]
public class LangFix : BaseUnityPlugin
{
	private const string PluginGuid = "LangFix_configuration";

	private const string PluginName = "LangFix";

	private const string PluginVersion = "1.0";

	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LangFix is loaded!");
		Harmony val = new Harmony("LangFix");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(Localization))]
[HarmonyPatch("Translate")]
public static class TranslateOverride
{
	[UsedImplicitly]
	public static bool Prefix()
	{
		int currentLanguageIndex = -1;
		bool flag = false;
		Language[] languages = Localization.Languages;
		if (languages != null)
		{
			for (int i = 0; i < languages.Length; i++)
			{
				Language val = languages[i];
				if (val.lcId == 1033)
				{
					currentLanguageIndex = i;
					flag = true;
					break;
				}
			}
		}
		if (flag)
		{
			Localization.CurrentLanguageIndex = currentLanguageIndex;
		}
		return true;
	}
}