Decompiled source of LethalCompanyPL v1.3.0

plugins/LethalCompanyPL.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("local.lethalcompany.polskiterminal", "Lethal Company PL", "1.3.0")]
public sealed class PolskiTerminal : BaseUnityPlugin
{
	[Serializable]
	private sealed class Wpis
	{
		public string Original = "";

		public string Polish = "";
	}

	[Serializable]
	private sealed class Slownik
	{
		public Wpis[] Entries = new Wpis[0];
	}

	private static readonly Dictionary<string, string> Teksty = new Dictionary<string, string>(StringComparer.Ordinal);

	private static readonly Dictionary<string, string> Wstawki = new Dictionary<string, string>(StringComparer.Ordinal)
	{
		{ "No data collected on wildlife. Scans are required.", "Brak danych o stworzeniach. Zeskanuj je, aby uzupełnić bestiariusz." },
		{ "[No items in stock!]", "[Brak towaru!]" },
		{ "[ALL DATA HAS BEEN CORRUPTED OR OVERWRITTEN]", "[WSZYSTKIE DANE ZOSTAŁY USZKODZONE LUB NADPISANE]" },
		{ "[No items available]", "[Brak dostępnych przedmiotów]" },
		{ "[No items stored. While moving an object with B, press X to store it.]", "[Schowek jest pusty. Podczas przesuwania przedmiotu klawiszem B naciśnij X, aby go schować.]" },
		{ "You have a free warranty!", "Masz darmową gwarancję!" },
		{ "  //  Price: $", "  //  Cena: $" },
		{ "mild weather", "spokojna pogoda" }
	};

	private static readonly Regex Obnizka = new Regex(" \\((\\d+)% OFF!\\)", RegexOptions.CultureInvariant);

	private static readonly Regex Dostawa = new Regex("(\\d+) purchased items on route\\.", RegexOptions.CultureInvariant);

	private static readonly Regex SkanStatku = new Regex("There are (\\d+) objects in the ship, totalling at \\$([0-9,.]+)\\.", RegexOptions.CultureInvariant);

	private static readonly Regex SkanZewnatrz = new Regex("There are (\\d+) objects outside the ship, totalling at an approximate value of \\$([0-9,.]+)\\.", RegexOptions.CultureInvariant);

	private Harmony harmony;

	private string zasoby;

	private TMP_FontAsset polskieZnaki;

	private bool probaLadowaniaCzcionki;

	private void Awake()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Expected O, but got Unknown
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Resources");
		zasoby = (Directory.Exists(text) ? text : Paths.ConfigPath);
		harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		if (zasoby == text)
		{
			new PolskieJezykiModow(harmony, ((BaseUnityPlugin)this).Logger, zasoby).Wlacz();
		}
		SceneManager.sceneLoaded += DodajCzcionke;
		DodajCzcionke(default(Scene), (LoadSceneMode)0);
		string path = Path.Combine(zasoby, "PolskiTerminal.json");
		try
		{
			Slownik slownik = JsonUtility.FromJson<Slownik>(File.ReadAllText(path));
			Wpis[] entries = slownik.Entries;
			foreach (Wpis wpis in entries)
			{
				Teksty[Normalizuj(wpis.Original)] = wpis.Polish;
			}
			Type type = AccessTools.TypeByName("Terminal");
			Type type2 = AccessTools.TypeByName("TerminalNode");
			MethodInfo methodInfo = AccessTools.Method(type, "TextPostProcess", new Type[2]
			{
				typeof(string),
				type2
			}, (Type[])null);
			if (methodInfo == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Brak metody TextPostProcess w tej wersji gry.");
				return;
			}
			HarmonyMethod val = new HarmonyMethod(typeof(PolskiTerminal), "Przetlumacz", (Type[])null);
			val.priority = 0;
			HarmonyMethod val2 = new HarmonyMethod(typeof(PolskiTerminal), "PrzetlumaczWstawki", (Type[])null);
			val2.priority = 0;
			harmony.Patch((MethodBase)methodInfo, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Wczytano odpowiedzi terminala: " + Teksty.Count));
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Nie udalo sie wlaczyc tlumaczenia terminala: " + ex));
		}
	}

	private static string Normalizuj(string tekst)
	{
		return tekst.Replace("\r\n", "\n").Replace('\r', '\n').Trim();
	}

	private static void Przetlumacz(ref string __0)
	{
		if (!string.IsNullOrEmpty(__0) && Teksty.TryGetValue(Normalizuj(__0), out var value))
		{
			int i = 0;
			int num;
			for (num = __0.Length; i < num && char.IsWhiteSpace(__0[i]); i++)
			{
			}
			while (num > i && char.IsWhiteSpace(__0[num - 1]))
			{
				num--;
			}
			__0 = __0.Substring(0, i) + value + __0.Substring(num);
		}
	}

	private static void PrzetlumaczWstawki(ref string __result)
	{
		if (string.IsNullOrEmpty(__result))
		{
			return;
		}
		foreach (KeyValuePair<string, string> item in Wstawki)
		{
			__result = __result.Replace(item.Key, item.Value);
		}
		__result = Obnizka.Replace(__result, " (RABAT $1%!)");
		__result = Dostawa.Replace(__result, "Zakupione przedmioty w drodze: $1.");
		__result = SkanStatku.Replace(__result, "Przedmioty na statku: $1. Łączna wartość: $$$2.");
		__result = SkanZewnatrz.Replace(__result, "Przedmioty poza statkiem: $1. Szacowana wartość: $$$2.");
	}

	private void DodajCzcionke(Scene scene, LoadSceneMode mode)
	{
		try
		{
			if ((Object)(object)TMP_Settings.instance == (Object)null || TMP_Settings.fallbackFontAssets == null)
			{
				return;
			}
			if ((Object)(object)polskieZnaki == (Object)null)
			{
				if (probaLadowaniaCzcionki)
				{
					return;
				}
				probaLadowaniaCzcionki = true;
				AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(zasoby, "arialuni_sdf_u2022"));
				if ((Object)(object)val == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Nie mozna otworzyc pliku czcionki zapasowej.");
					return;
				}
				try
				{
					TMP_FontAsset[] array = val.LoadAllAssets<TMP_FontAsset>();
					foreach (TMP_FontAsset val2 in array)
					{
						if (val2.HasCharacter('ą', false, false) && val2.HasCharacter('ź', false, false) && val2.HasCharacter('Ł', false, false))
						{
							polskieZnaki = val2;
							break;
						}
					}
				}
				finally
				{
					val.Unload(false);
				}
				if ((Object)(object)polskieZnaki == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Nie znaleziono czcionki z polskimi znakami.");
					return;
				}
				Object.DontDestroyOnLoad((Object)(object)polskieZnaki);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Dodano czcionke zapasowa dla polskich znakow.");
			}
			List<TMP_FontAsset> fallbackFontAssets = TMP_Settings.fallbackFontAssets;
			if (!fallbackFontAssets.Contains(polskieZnaki))
			{
				fallbackFontAssets.Add(polskieZnaki);
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Czcionka zapasowa: " + ex.Message));
		}
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= DodajCzcionke;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		if ((Object)(object)polskieZnaki != (Object)null && (Object)(object)TMP_Settings.instance != (Object)null && TMP_Settings.fallbackFontAssets != null)
		{
			TMP_Settings.fallbackFontAssets.Remove(polskieZnaki);
		}
	}
}
internal sealed class PolskieJezykiModow
{
	internal const string InputUtils = "com.rune580.LethalCompanyInputUtils";

	internal const string Biodiversity = "com.github.biodiversitylc.Biodiversity";

	internal const string Coroner = "com.elitemastereric.coroner";

	internal const string BaconRpg = "baconrpg";

	private static Dictionary<string, string> sterowanie;

	private static Dictionary<string, string> bestiariusz;

	private static Dictionary<string, string[]> raport;

	private readonly Harmony harmony;

	private readonly ManualLogSource logger;

	private readonly string zasoby;

	internal PolskieJezykiModow(Harmony harmony, ManualLogSource logger, string zasoby)
	{
		this.harmony = harmony;
		this.logger = logger;
		this.zasoby = zasoby;
	}

	internal void Wlacz()
	{
		WlaczJesliZainstalowany("com.rune580.LethalCompanyInputUtils", "InputUtils", WlaczInputUtils);
		WlaczJesliZainstalowany("com.github.biodiversitylc.Biodiversity", "Biodiversity", WlaczBiodiversity);
		WlaczJesliZainstalowany("com.elitemastereric.coroner", "Coroner", WlaczCoroner);
		WlaczJesliZainstalowany("baconrpg", "BaconRPG", (Assembly assembly) => BaconRpgPanel.Wlacz(assembly, harmony, Path.Combine(zasoby, "BaconRPG.tsv")));
	}

	private void WlaczJesliZainstalowany(string guid, string nazwa, Func<Assembly, int> dodaj)
	{
		if (!Chainloader.PluginInfos.TryGetValue(guid, out var value) || (Object)(object)value.Instance == (Object)null)
		{
			return;
		}
		try
		{
			int num = dodaj(((object)value.Instance).GetType().Assembly);
			logger.LogInfo((object)("Polski język: " + nazwa + " (" + num + " wpisów)."));
		}
		catch (Exception ex)
		{
			logger.LogWarning((object)("Język moda " + nazwa + ": " + ex.GetBaseException().Message));
		}
	}

	private int WlaczInputUtils(Assembly assembly)
	{
		Type type = assembly.GetType("LethalCompanyInputUtils.Localization.LocaleManager", throwOnError: true);
		FieldInfo fieldInfo = AccessTools.Field(type, "LocaleEntries");
		MethodInfo methodInfo = AccessTools.Method(type, "LoadLocaleData", Type.EmptyTypes, (Type[])null);
		if (fieldInfo == null || methodInfo == null)
		{
			throw new MissingMemberException("InputUtils używa innej struktury słownika.");
		}
		Dictionary<string, string> __LocaleEntries = (Dictionary<string, string>)fieldInfo.GetValue(null);
		JObject val = JObject.Parse(File.ReadAllText(Path.Combine(zasoby, "InputUtils.pl_PL.json")));
		sterowanie = val["entries"].ToObject<Dictionary<string, string>>();
		harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, NowaLatka("PodmienSterowanie"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		PodmienSterowanie(__LocaleEntries);
		return sterowanie.Count;
	}

	private static void PodmienSterowanie(Dictionary<string, string> ___LocaleEntries)
	{
		foreach (KeyValuePair<string, string> item in sterowanie)
		{
			___LocaleEntries[item.Key] = item.Value;
		}
	}

	private int WlaczBiodiversity(Assembly assembly)
	{
		Type type = assembly.GetType("Biodiversity.Core.Lang.LangParser", throwOnError: true);
		MethodInfo methodInfo = AccessTools.Method(type, "GetTranslation", new Type[1] { typeof(string) }, (Type[])null);
		if (methodInfo == null)
		{
			throw new MissingMethodException(type.FullName, "GetTranslation");
		}
		bestiariusz = ((JToken)JObject.Parse(File.ReadAllText(Path.Combine(zasoby, "Biodiversity.pl.json")))).ToObject<Dictionary<string, string>>();
		harmony.Patch((MethodBase)methodInfo, NowaLatka("PodmienBestiariusz"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		return bestiariusz.Count;
	}

	private static bool PodmienBestiariusz(string __0, ref string __result)
	{
		if (__0 == null || !bestiariusz.TryGetValue(__0, out var value))
		{
			return true;
		}
		__result = value;
		return false;
	}

	private int WlaczCoroner(Assembly assembly)
	{
		Type type = assembly.GetType("Coroner.LanguageHandler", throwOnError: true);
		MethodInfo methodInfo = AccessTools.Method(type, "GetFirstValueByTag", new Type[1] { typeof(string) }, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(type, "GetValuesByTag", new Type[1] { typeof(string) }, (Type[])null);
		if (methodInfo == null || methodInfo2 == null)
		{
			throw new MissingMemberException("Coroner używa innych metod odczytu raportów.");
		}
		XDocument val = XDocument.Load(Path.Combine(zasoby, "Coroner.pl-pl.xml"));
		raport = ((XContainer)((XContainer)val.Root).Element(XName.op_Implicit("strings"))).Elements().GroupBy<XElement, string>((XElement wpis) => wpis.Name.LocalName, StringComparer.Ordinal).ToDictionary<IGrouping<string, XElement>, string, string[]>((IGrouping<string, XElement> grupa) => grupa.Key, (IGrouping<string, XElement> grupa) => grupa.Select((XElement wpis) => (string)wpis.Attribute(XName.op_Implicit("text"))).ToArray(), StringComparer.Ordinal);
		harmony.Patch((MethodBase)methodInfo, NowaLatka("PodmienPierwszaLinieRaportu"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		harmony.Patch((MethodBase)methodInfo2, NowaLatka("PodmienWariantyRaportu"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		return raport.Values.Sum((string[] warianty) => warianty.Length);
	}

	private static bool PodmienPierwszaLinieRaportu(string __0, ref string __result)
	{
		if (__0 == null || !raport.TryGetValue(__0, out var value))
		{
			return true;
		}
		__result = value[0];
		return false;
	}

	private static bool PodmienWariantyRaportu(string __0, ref string[] __result)
	{
		if (__0 == null || !raport.TryGetValue(__0, out var value))
		{
			return true;
		}
		__result = (string[])value.Clone();
		return false;
	}

	private static HarmonyMethod NowaLatka(string metoda)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		return new HarmonyMethod(typeof(PolskieJezykiModow), metoda, (Type[])null);
	}
}
internal sealed class BaconRpgSlownik
{
	private readonly Dictionary<string, string> teksty = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

	private readonly List<KeyValuePair<Regex, string>> reguly = new List<KeyValuePair<Regex, string>>();

	private static readonly Regex Ozdoba = new Regex("^[★◆◇♦✦❖•>]+[ \\t]*");

	private static readonly Regex Znaczniki = new Regex("(<[^<>]+>)");

	private static readonly Regex Sekcje = new Regex("(\\s*·\\s*|\\n)");

	private static readonly Regex Dzial = new Regex("^(JOIN|TRANSFER (?:TO|FROM)) ([\\s\\S]+)$");

	private static readonly Regex Odblokowanie = new Regex("^Unlock it: (.+?)\\. (.+) \\((\\d+/\\d+)\\)$");

	private static readonly Regex PelnyDzial = new Regex("^Every slot in (.+?) is taken\\. Unemployed always has room\\.$");

	private static readonly Regex ZwrotPunktow = new Regex("^A transfer gives back the points you spent in (.+?)\\.$");

	internal int Count => teksty.Count + reguly.Count;

	internal BaconRpgSlownik(string sciezka)
	{
		foreach (string item in File.ReadLines(sciezka))
		{
			if (!string.IsNullOrWhiteSpace(item) && !item.StartsWith("#", StringComparison.Ordinal))
			{
				string[] array = item.Split(new char[1] { '\t' }, 2);
				if (array.Length != 2 || array[0].Length == 0 || array[1].Length == 0)
				{
					throw new FormatException("Brak pary tekstów BaconRPG: " + item);
				}
				string value = array[1].Replace("\\n", "\n");
				if (array[0].StartsWith("r:", StringComparison.Ordinal))
				{
					reguly.Add(new KeyValuePair<Regex, string>(new Regex(array[0].Substring(2), RegexOptions.CultureInvariant), value));
				}
				else
				{
					teksty.Add(array[0].Replace("\\n", "\n"), value);
				}
			}
		}
	}

	internal string Tlumacz(string tekst)
	{
		if (string.IsNullOrWhiteSpace(tekst))
		{
			return tekst;
		}
		string text = TlumaczFragment(tekst);
		if (text.IndexOf('<') < 0)
		{
			return text;
		}
		string[] array = Znaczniki.Split(text);
		for (int i = 0; i < array.Length; i += 2)
		{
			array[i] = TlumaczFragment(array[i]);
		}
		return string.Concat(array);
	}

	private string TlumaczFragment(string wartosc)
	{
		string text = wartosc.Trim();
		if (text.Length == 0)
		{
			return wartosc;
		}
		string text2 = TlumaczBezOdstepow(text);
		if (text2 == text)
		{
			return wartosc;
		}
		int num = wartosc.Length - wartosc.TrimStart().Length;
		return wartosc.Substring(0, num) + text2 + wartosc.Substring(num + text.Length);
	}

	private string TlumaczBezOdstepow(string tekst)
	{
		if (Szukaj(tekst, out var pl))
		{
			return pl;
		}
		Match match = Ozdoba.Match(tekst);
		if (match.Success)
		{
			string text = tekst.Substring(match.Length);
			pl = TlumaczBezOdstepow(text);
			if (pl != text)
			{
				return match.Value + pl;
			}
		}
		Match match2 = Dzial.Match(tekst);
		if (match2.Success && Szukaj(match2.Groups[2].Value, out pl))
		{
			string value = match2.Groups[1].Value;
			string text2 = ((value == "JOIN") ? "DOŁĄCZ: " : ((value == "TRANSFER TO") ? "PRZENIEŚ DO: " : "PRZENIESIENIE Z: "));
			return text2 + pl.ToUpperInvariant();
		}
		Match match3 = Odblokowanie.Match(tekst);
		if (match3.Success)
		{
			return "Odblokuj: " + ZnajdzLubZachowaj(match3.Groups[1].Value) + ". " + ZnajdzLubZachowaj(match3.Groups[2].Value) + " (" + match3.Groups[3].Value + ")";
		}
		Match match4 = PelnyDzial.Match(tekst);
		if (match4.Success)
		{
			return "Brak miejsc w dziale „" + ZnajdzLubZachowaj(match4.Groups[1].Value) + "”. Zawsze możesz zostać bez przydziału.";
		}
		Match match5 = ZwrotPunktow.Match(tekst);
		if (match5.Success)
		{
			return "Odzyskasz punkty wydane w dziale „" + ZnajdzLubZachowaj(match5.Groups[1].Value) + "”.";
		}
		string[] array = tekst.Split(new string[1] { ", " }, StringSplitOptions.None);
		if (array.Length > 1)
		{
			string[] array2 = array.Select(ZnajdzLubZachowaj).ToArray();
			if (array.Zip(array2, (string en, string text3) => en != text3).All((bool zmieniony) => zmieniony))
			{
				return string.Join(", ", array2);
			}
		}
		foreach (KeyValuePair<Regex, string> item in reguly)
		{
			Match match6 = item.Key.Match(tekst);
			if (match6.Success)
			{
				return match6.Result(item.Value);
			}
		}
		string[] array3 = Sekcje.Split(tekst);
		if (array3.Length > 1)
		{
			for (int num = 0; num < array3.Length; num += 2)
			{
				array3[num] = TlumaczFragment(array3[num]);
			}
			return string.Concat(array3);
		}
		return tekst;
	}

	private bool Szukaj(string tekst, out string pl)
	{
		if (!teksty.TryGetValue(tekst, out pl))
		{
			return false;
		}
		if (tekst == tekst.ToUpperInvariant())
		{
			pl = pl.ToUpperInvariant();
		}
		return true;
	}

	private string ZnajdzLubZachowaj(string tekst)
	{
		if (!Szukaj(tekst, out var pl))
		{
			return tekst;
		}
		return pl;
	}
}
internal static class BaconRpgPanel
{
	private static BaconRpgSlownik slownik;

	private static readonly string[] TypyWyswietlania = new string[17]
	{
		"BaconRPG.CareerScreen", "BaconRPG.Tablet", "BaconRPG.OpsConsole", "BaconRPG.HackerTablet", "BaconRPG.DepartmentGuide", "BaconRPG.Lockpick", "BaconRPG.Hud", "BaconRPG.HudLane", "BaconRPG.Reticle", "BaconRPG.Markers",
		"BaconRPG.TabletBadge", "BaconRPG.SkillPresence", "BaconRPG.CrewList", "BaconRPG.Awards", "BaconRPG.Plaque", "BaconRPG.Bets", "BaconRPG.Ceremony"
	};

	internal static int Wlacz(Assembly bacon, Harmony harmony, string sciezka)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		Type type = bacon.GetType("BaconRPG.Ui", throwOnError: true);
		MethodInfo methodInfo = AccessTools.DeclaredMethod(type, "Text", (Type[])null, (Type[])null);
		if (methodInfo == null || methodInfo.GetParameters().Length < 2 || methodInfo.GetParameters()[1].ParameterType != typeof(string))
		{
			throw new MissingMethodException(type.FullName, "Text");
		}
		slownik = new BaconRpgSlownik(sciezka);
		HarmonyMethod val = new HarmonyMethod(typeof(BaconRpgPanel), "PrzetlumaczEtykiete", (Type[])null);
		harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		HarmonyMethod val2 = new HarmonyMethod(typeof(BaconRpgPanel), "PrzekierujOdswiezanie", (Type[])null);
		MethodInfo ustawTekst = AccessTools.PropertySetter(typeof(TMP_Text), "text");
		string[] typyWyswietlania = TypyWyswietlania;
		foreach (string name in typyWyswietlania)
		{
			Type type2 = bacon.GetType(name);
			if (type2 == null)
			{
				continue;
			}
			MethodInfo[] methods = type2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo2 in methods)
			{
				if (!methodInfo2.ContainsGenericParameters && methodInfo2.GetMethodBody() != null && PatchProcessor.GetOriginalInstructions((MethodBase)methodInfo2, (ILGenerator)null).Any((CodeInstruction val3) => CodeInstructionExtensions.Calls(val3, ustawTekst)))
				{
					harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}
		return slownik.Count;
	}

	private static void PrzetlumaczEtykiete(ref string __1)
	{
		__1 = slownik.Tlumacz(__1);
	}

	private static IEnumerable<CodeInstruction> PrzekierujOdswiezanie(IEnumerable<CodeInstruction> instrukcje)
	{
		MethodInfo ustawTekst = AccessTools.PropertySetter(typeof(TMP_Text), "text");
		MethodInfo ustawPolskiTekst = AccessTools.DeclaredMethod(typeof(BaconRpgPanel), "UstawPolskiTekst", (Type[])null, (Type[])null);
		foreach (CodeInstruction instrukcja in instrukcje)
		{
			if (CodeInstructionExtensions.Calls(instrukcja, ustawTekst))
			{
				instrukcja.opcode = OpCodes.Call;
				instrukcja.operand = ustawPolskiTekst;
			}
			yield return instrukcja;
		}
	}

	private static void UstawPolskiTekst(TMP_Text etykieta, string tekst)
	{
		etykieta.text = slownik.Tlumacz(tekst);
	}
}

patchers/PolskiJsonPreloader.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("1.3.0.0")]
public static class PolskiJsonPreloader
{
	public static IEnumerable<string> TargetDLLs => new string[0];

	public static void Initialize()
	{
		ManualLogSource val = Logger.CreateLogSource("LethalCompanyPL start");
		try
		{
			Assembly assembly = Assembly.LoadFrom(Path.Combine(Paths.ManagedPath, "Newtonsoft.Json.dll"));
			if (assembly.GetType("Newtonsoft.Json.Utilities.AotHelper") == null)
			{
				throw new InvalidOperationException("Biblioteka JSON nie zawiera dodatków Unity: " + assembly.Location);
			}
			val.LogInfo((object)"Wybrano bibliotekę JSON gry z obsługą Unity.");
		}
		catch (Exception ex)
		{
			val.LogError((object)("Nie udało się wybrać biblioteki JSON gry: " + ex.Message));
		}
	}

	public static void Patch(AssemblyDefinition assembly)
	{
	}
}