Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KiwiTurkceCeviri v1.0.0
plugins/PoVTurkce.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using PassiveTree; using PassiveTree.UI; [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("PoVTurkce")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PoVTurkce")] [assembly: AssemblyTitle("PoVTurkce")] [assembly: AssemblyVersion("1.0.0.0")] [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 PoVTurkce { public static class Patches { public delegate void Patcher(MethodBase original, MethodInfo prefix, MethodInfo postfix); public static HashSet<string> Seen; private const BindingFlags All = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static MethodInfo num; [ThreadStatic] private static string tail; [ThreadStatic] private static string fullTail; private static readonly Subject[] Pools; private static bool Turkish => L.CurrentLanguage() == "turkish"; public static int Apply(Patcher patch) { Type typeFromHandle = typeof(StatText); Type typeFromHandle2 = typeof(TreeWindow); num = typeFromHandle.GetMethod("Num", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(float), typeof(bool) }, null); int done = 0; P(typeFromHandle, "Num", new Type[2] { typeof(float), typeof(bool) }, null, "NumPost"); P(typeFromHandle, "FallbackName", new Type[1] { typeof(Stat) }, null, "FallbackPost"); P(typeFromHandle, "Join", new Type[2] { typeof(string), typeof(string) }, null, "JoinPost"); P(typeFromHandle, "GateText", new Type[2] { typeof(Gate), typeof(bool) }, "GatePre", null); P(typeFromHandle, "ConditionText", new Type[3] { typeof(Condition), typeof(float), typeof(Subject) }, null, "ConditionPost"); P(typeFromHandle, "AffixSuffix", new Type[3] { typeof(Mod), typeof(Subject), typeof(Subject) }, null, "SuffixPost"); P(typeFromHandle, "DescribeMod", new Type[1] { typeof(Mod) }, "Clear", "DescribeModPost"); P(typeFromHandle, "DescribeHead", new Type[2] { typeof(Mod), typeof(Func<string, string>) }, "DescribeHeadPre", null); P(typeFromHandle, "DescribeTail", new Type[1] { typeof(Mod) }, "DescribeTailPre", "DescribeTailPost"); P(typeFromHandle2, "Described", new Type[2] { typeof(Mod), typeof(string) }, "Clear", "DescribedPost"); return done; void P(Type t, string name, Type[] args, string pre, string post) { MethodBase method = t.GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, args, null); if (!(method == null)) { patch(method, (pre == null) ? null : typeof(Patches).GetMethod(pre, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (post == null) ? null : typeof(Patches).GetMethod(post, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); done++; } } } private static void NumPost(ref string __result, bool pct) { if (__result != null && Turkish) { string text = __result.Replace('.', ','); if (pct && text.EndsWith("%")) { text = "%" + text.Substring(0, text.Length - 1); } __result = text; } } private unsafe static void FallbackPost(Stat s, ref string __result) { if (Turkish) { string text = L.Id("attr." + ((object)(*(Stat*)(&s))/*cast due to .constrained prefix*/).ToString() + ".gen", (string)null); if (text != null) { __result = text; } else { Seen?.Add("fallback\t" + ((object)(*(Stat*)(&s))/*cast due to .constrained prefix*/).ToString() + "\t" + __result); } } } private static void JoinPost(string adj, string gen, ref string __result) { if (!Turkish || string.IsNullOrEmpty(adj) || string.IsNullOrEmpty(gen) || __result == gen || !__result.EndsWith(gen)) { return; } string text = Visible(adj).Trim(); if (!(L.T(text + "|sıfat") != text + "|sıfat")) { string text2 = Possessive(gen); if (text2 == null) { Seen?.Add("gen\t" + Visible(gen).Trim()); } else { __result = __result.Substring(0, __result.Length - gen.Length) + text2; } } } private static string Possessive(string text) { string text2 = Visible(text).Trim(); string text3 = L.T(text2 + "|tamlama"); if (text2.Length == 0 || text3 == text2 + "|tamlama") { return null; } int num = text.LastIndexOf(text2, StringComparison.Ordinal); if (num < 0) { return text3; } return text.Substring(0, num) + text3 + text.Substring(num + text2.Length); } private static bool GatePre(Gate g, bool instant, ref string __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!Turkish || !((Gate)(ref g)).IsEvent) { return true; } string text = Trigger(g.After, g.Over, instant); if (text == null) { return true; } if (!instant) { text = Seconds(text, (g.Threshold > 0f) ? g.Threshold : 3f); } __result = text; return false; } private static void ConditionPost(Condition c, float threshold, Subject over, ref string __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Trigger t = default(Trigger); float num = default(float); if (Turkish && (int)over != 0 && Conditions.After(c, ref t, ref num)) { string text = Trigger(t, over, instant: false); if (text != null) { __result = Seconds(text, (threshold > 0f) ? threshold : num); } } } private unsafe static string Trigger(Trigger t, Subject over, bool instant) { //IL_0056: 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_0093: Unknown result type (might be due to invalid IL or missing references) string text = "trigger." + ((object)(*(Trigger*)(&t))/*cast due to .constrained prefix*/).ToString() + (instant ? ".now" : ".recent"); string text2 = L.Id(text, (string)null); Seen?.Add("trigger\t" + text + "\t" + (((int)over == 0) ? "" : ((object)(*(Subject*)(&over))/*cast due to .constrained prefix*/).ToString()) + ((text2 == null) ? "\tEKSİK" : "")); if (text2 == null) { return null; } string arg = (((int)over == 0) ? "" : (SubjectText.Aim(over) + " ")); return Regex.Replace(string.Format(text2, arg), " {2,}", " ").Trim(); } private static string Seconds(string text, float a) { if (Math.Abs(a - 3f) < 0.001f || Patches.num == null) { return text; } string arg = (string)Patches.num.Invoke(null, new object[2] { a, false }); string text2 = L.Id("ui.stats.recently", "recently"); string text3 = L.Id("ui.stats.recently-seconds", (string)null); int num = text.IndexOf(text2, StringComparison.Ordinal); if (text3 != null && num >= 0) { return text.Substring(0, num) + string.Format(text3, arg) + text.Substring(num + text2.Length); } return text + " " + string.Format(L.Id("ui.stats.s", "({0} s)"), arg); } private static void Clear() { tail = null; fullTail = null; } private static void SuffixPost(string __result) { tail = __result; } private static bool GainAsExtra(Mod m) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 if ((int)Attrs.Canon(m.Key) != 727 || m.Overs == null) { return false; } Subject[] overs = m.Overs; foreach (Subject val in overs) { if ((int)val != 45 && (int)val != 100 && (int)SubjectGroups.Of(val) == 4) { return true; } } return false; } private static bool DescribeHeadPre(Mod m, ref string __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!Turkish || !GainAsExtra(m)) { return true; } __result = StatText.DescribeMod(m); return false; } private static bool DescribeTailPre(Mod m, ref string __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Turkish || !GainAsExtra(m)) { return true; } __result = ""; return false; } private static void DescribeTailPost(string __result) { fullTail = __result; } private static void DescribeModPost(Mod m, ref string __result) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (Turkish) { __result = MoveTail(__result, tail, keepWrapper: false, m); } } private static void DescribedPost(Mod m, ref string __result) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (Turkish) { __result = MoveTail(__result, fullTail, keepWrapper: true, m); } } public static string MoveTail(string s, string t, bool keepWrapper, Mod m) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(t) || Visible(t).Trim().Length == 0) { return s; } string text = null; bool flag = false; if (m.Overs != null) { Subject[] overs = m.Overs; foreach (Subject val in overs) { bool flag2 = Array.IndexOf(Pools, val) >= 0; if (!flag2 && (int)SubjectGroups.Of(val) != 9 && (int)SubjectGroups.Of(val) != 7) { continue; } string text2 = SubjectText.Say(val); if (string.IsNullOrEmpty(text2)) { continue; } Match match = Regex.Match(t, "^\\s*(?:<[^>]+>)*" + Regex.Escape(text2) + "(?:</[^>]+>)*(?=\\s|$)", RegexOptions.IgnoreCase); if (match.Success) { text = text2; flag = flag2; string text3 = t.Substring(match.Length); int num = s.LastIndexOf(t, StringComparison.Ordinal); if (num >= 0) { s = s.Substring(0, num) + text3 + s.Substring(num + t.Length); } t = text3; break; } } } if (text != null) { int num2 = (flag ? (-1) : s.IndexOf("ganimet", StringComparison.Ordinal)); s = ((num2 >= 0) ? (s.Substring(0, num2) + text + s.Substring(num2 + "ganimet".Length)) : InsertPool(s, text, t)); } if (Visible(t).Trim().Length == 0) { return s; } string text4 = Regex.Replace(t, "[Hh]er ([\\d,]+) % eksik sağlık puanı başına", "eksik sağlığın her %$1 kadarı başına"); if (text4 != t) { int num3 = s.LastIndexOf(t, StringComparison.Ordinal); if (num3 >= 0) { s = s.Substring(0, num3) + text4 + s.Substring(num3 + t.Length); } t = text4; } string text5 = ""; if (keepWrapper && s.EndsWith("</color>") && s.Substring(0, s.Length - 8).EndsWith(t)) { text5 = "</color>"; s = s.Substring(0, s.Length - 8); } int num4 = s.LastIndexOf(t, StringComparison.Ordinal); if (num4 < 0) { return s + text5; } string text6 = s.Substring(0, num4).TrimEnd(Array.Empty<char>()); string text7 = s.Substring(num4 + t.Length); string text8 = ""; if (keepWrapper) { Match match2 = Regex.Match(text6, "^(<color=[^>]+>)"); if (match2.Success) { text8 = match2.Value; text6 = text6.Substring(text8.Length); } } return text8 + UpperFirst(t.Trim()) + " " + LowerFirst(text6) + text7 + text5; } private static string InsertPool(string s, string pool, string t) { int num = ((t.Length > 0) ? s.LastIndexOf(t, StringComparison.Ordinal) : (-1)); string input = ((num >= 0) ? s.Substring(0, num) : s); string text = ((num >= 0) ? s.Substring(num) : ""); Match match = Regex.Match(input, "^((?:<[^>]+>)*[+−\\-]?%?[\\d,]+%?(?:</[^>]+>)*)\\s+(.+?)(\\s*)$", RegexOptions.Singleline); if (!match.Success) { return s; } string value = match.Groups[2].Value; string text2 = Possessive(value); return match.Groups[1].Value + " " + pool + " " + (text2 ?? value) + match.Groups[3].Value + text; } private static string Visible(string s) { return Regex.Replace(s ?? "", "<[^>]*>", ""); } private static string UpperFirst(string s) { return ChangeFirst(s, upper: true); } private static string LowerFirst(string s) { return ChangeFirst(s, upper: false); } private static string ChangeFirst(string s, bool upper) { bool flag = false; for (int i = 0; i < s.Length; i++) { char c = s[i]; switch (c) { case '<': flag = true; continue; case '>': flag = false; continue; } if (!flag) { if (!char.IsLetter(c)) { return s; } char c2 = ((!upper) ? (c switch { 'I' => 'ı', 'İ' => 'i', _ => char.ToLowerInvariant(c), }) : (c switch { 'ı' => 'I', 'i' => 'İ', _ => char.ToUpperInvariant(c), })); if (!upper && i + 1 < s.Length && char.IsUpper(s[i + 1])) { return s; } return s.Substring(0, i) + c2 + s.Substring(i + 1); } } return s; } static Patches() { Subject[] array = new Subject[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); Pools = (Subject[])(object)array; } } [BepInPlugin("egebu.povturkce", "PoV Türkçe Düzeltmeleri", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown Harmony harmony = new Harmony("egebu.povturkce"); Patches.Apply(delegate(MethodBase original, MethodInfo prefix, MethodInfo postfix) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) harmony.Patch(original, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(prefix), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(postfix), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); } } }
plugins/RunemarkTurkce.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using GBV.Runemark; 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("RunemarkTurkce")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RunemarkTurkce")] [assembly: AssemblyTitle("RunemarkTurkce")] [assembly: AssemblyVersion("1.0.0.0")] [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 RunemarkTurkce { [BepInPlugin("egebu.runemarkturkce", "Runemark Türkçe", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Texts.Load(Path.Combine(Path.Combine(Paths.ConfigPath, "RunemarkTurkce"), "turkish.txt")); Texts.Apply(new Harmony("egebu.runemarkturkce")); } } public static class Texts { private static readonly Dictionary<string, string> map = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly string[] Classes = new string[12] { "Affixes", "AffixDef", "RunestonePanel", "Enchanting", "NearbyStock", "InventoryGuiDoCraftingPatch", "Runestone", "RunestoneStation", "Materials", "Runecrafting", "Tooltips", "ItemDropHoverTextPatch" }; private static readonly HashSet<FieldInfo> Fields = new HashSet<FieldInfo> { AccessTools.Field(typeof(AffixDef), "Name"), AccessTools.Field(typeof(AffixDef), "Description"), AccessTools.Field(typeof(AffixDef), "Prefix"), AccessTools.Field(typeof(AffixDef), "Suffix"), AccessTools.Field(typeof(RarityTier), "Name") }; private const BindingFlags All = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static int Count => map.Count; public static bool Turkish { get { try { return Localization.instance != null && Localization.instance.GetSelectedLanguage() == "Turkish"; } catch { return false; } } } public static string Tr(string s) { if (s == null || !Turkish) { return s; } if (!map.TryGetValue(s, out var value)) { return s; } return value; } public static void Load(string path) { if (!File.Exists(path)) { return; } string[] array = File.ReadAllLines(path, Encoding.UTF8); for (int i = 0; i < array.Length; i++) { string text = array[i].TrimEnd(new char[1] { '\r' }); int num = text.IndexOf('\t'); if (text.Length != 0 && text[0] != '#' && num > 0) { string text2 = Unescape(text.Substring(num + 1)); if (text2.Length > 0) { map[Unescape(text.Substring(0, num))] = text2; } } } } private static string Unescape(string s) { if (s.IndexOf('\\') < 0) { return s; } StringBuilder stringBuilder = new StringBuilder(s.Length); for (int i = 0; i < s.Length; i++) { if (s[i] == '\\' && i + 1 < s.Length) { char c = s[++i]; stringBuilder.Append(c switch { 't' => '\t', 'n' => '\n', _ => c, }); } else { stringBuilder.Append(s[i]); } } return stringBuilder.ToString(); } public static int Apply(Harmony harmony) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (map.Count == 0) { return 0; } HarmonyMethod val = new HarmonyMethod(typeof(Texts).GetMethod("Transpiler", BindingFlags.Static | BindingFlags.NonPublic)); int num = 0; Type[] types = typeof(Affixes).Assembly.GetTypes(); foreach (Type type in types) { if (!Listed(type)) { continue; } List<MethodBase> list = new List<MethodBase>(); list.AddRange(type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (ConstructorInfo constructorInfo in constructors) { if (!constructorInfo.IsStatic) { list.Add(constructorInfo); } } foreach (MethodBase item in list) { if (item.IsAbstract || item.ContainsGenericParameters || item.GetMethodBody() == null) { continue; } try { List<CodeInstruction> originalInstructions = PatchProcessor.GetOriginalInstructions(item, (ILGenerator)null); bool flag = false; for (int k = 0; k < originalInstructions.Count; k++) { if (flag) { break; } flag = Wanted(originalInstructions[k]) || WorkName((k > 0) ? originalInstructions[k - 1] : null, originalInstructions[k]); } if (flag) { harmony.Patch(item, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } catch { } } } Special(harmony); return num; } private static bool Listed(Type t) { while (t.DeclaringType != null) { t = t.DeclaringType; } if (t.Namespace == "GBV.Runemark") { return Array.IndexOf(Classes, t.Name) >= 0; } return false; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo tr = AccessTools.Method(typeof(Texts), "Tr", (Type[])null, (Type[])null); MethodInfo trWork = AccessTools.Method(typeof(Texts), "TrWork", (Type[])null, (Type[])null); CodeInstruction prev = null; foreach (CodeInstruction i in instructions) { yield return i; if (Wanted(i)) { yield return new CodeInstruction(OpCodes.Call, (object)tr); } else if (WorkName(prev, i)) { yield return new CodeInstruction(OpCodes.Call, (object)trWork); } prev = i; } } private static bool WorkName(CodeInstruction prev, CodeInstruction i) { if (prev != null && (prev.opcode == OpCodes.Constrained || prev.opcode == OpCodes.Box) && prev.operand is Type type && type == typeof(RuneWork) && (i.opcode == OpCodes.Callvirt || i.opcode == OpCodes.Call) && i.operand is MethodInfo { Name: "ToString" } methodInfo) { return methodInfo.GetParameters().Length == 0; } return false; } public static string TrWork(string s) { if (s == null || !Turkish || !map.TryGetValue("work:" + s, out var value)) { return s; } return value; } private static bool Wanted(CodeInstruction i) { if (i.opcode == OpCodes.Ldstr) { if (i.operand is string key) { return map.ContainsKey(key); } return false; } if (i.opcode == OpCodes.Ldfld && i.operand is FieldInfo item) { return Fields.Contains(item); } return false; } private static void Special(Harmony harmony) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(Affixes), "DecorateName", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Texts), "DecoratePre", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(AffixDef), "Describe", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Texts), "PercentPost", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(Affixes).Assembly.GetType("GBV.Shared.Theme"), "Spaced", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Texts), "SpacedPre", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Type type = typeof(Affixes).Assembly.GetType("GBV.Runemark.Runecrafting"); MethodInfo methodInfo2 = ((type == null) ? null : AccessTools.Method(type, "Names", (Type[])null, (Type[])null)); MethodInfo methodInfo3 = ((type == null) ? null : AccessTools.Method(type, "Name", (Type[])null, (Type[])null)); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(Texts), "SkillNamePost", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(Texts), "SkillWordPost", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void SpacedPre(ref string s) { if (s != null && Turkish) { s = s.Replace('i', 'İ').Replace('ı', 'I'); } } private static bool DecoratePre(string baseName, MagicItem magic, ref string __result) { if (!Turkish || magic == null || magic.HasTitle || magic.Affixes == null || magic.Affixes.Count == 0) { return true; } string text = null; string text2 = null; int num = -1; for (int i = 0; i < magic.Affixes.Count; i++) { AffixDef val = Affixes.Get(magic.Affixes[i].Key); if (val != null && !string.IsNullOrEmpty(val.Prefix)) { text = Tr(val.Prefix); num = i; break; } } for (int j = 0; j < magic.Affixes.Count; j++) { if (j != num) { AffixDef val2 = Affixes.Get(magic.Affixes[j].Key); if (val2 != null && !string.IsNullOrEmpty(val2.Suffix)) { text2 = Tr(val2.Suffix); break; } } } string text3 = baseName; if (text != null) { text3 = text + " " + text3; } if (text2 != null) { text3 = text2 + " " + text3; } __result = text3; return false; } private static void PercentPost(ref string __result) { if (Turkish && __result != null) { string input = Regex.Replace(__result, "\\+(\\d+(?:\\.\\d+)?)%", "+%$1"); __result = Regex.Replace(input, "(\\d)\\.(\\d)", "$1,$2"); } } private static void SkillNamePost(bool __result, ref string name) { if (__result && Turkish && map.TryGetValue("skill:Runecrafting", out var value)) { name = value; } } private static void SkillWordPost() { if (!Turkish || !map.TryGetValue("skill:Runecrafting", out var value)) { return; } try { if (AccessTools.Field(typeof(Affixes).Assembly.GetType("GBV.Runemark.Runecrafting"), "NameKey")?.GetValue(null) is string key && AccessTools.Field(typeof(Localization), "m_translations")?.GetValue(Localization.instance) is IDictionary dictionary) { dictionary[key] = value; } } catch { } } } }
plugins/TurkceEk.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; 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("TurkceEk")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TurkceEk")] [assembly: AssemblyTitle("TurkceEk")] [assembly: AssemblyVersion("1.0.0.0")] [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 TurkceEk { public static class Keys { private static readonly Dictionary<string, string> map = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly HashSet<Assembly> scanned = new HashSet<Assembly>(); private static readonly List<FieldInfo[]> registries = new List<FieldInfo[]>(); private const BindingFlags Any = BindingFlags.Public | BindingFlags.NonPublic; public static int Count => map.Count; public static void Load(string dir) { if (!Directory.Exists(dir)) { return; } string[] files = Directory.GetFiles(dir, "*.txt"); for (int i = 0; i < files.Length; i++) { string[] array = File.ReadAllLines(files[i], Encoding.UTF8); for (int j = 0; j < array.Length; j++) { string text = array[j].TrimEnd(new char[1] { '\r' }); int num = text.IndexOf('\t'); if (text.Length != 0 && text[0] != '#' && num > 0) { string text2 = Unescape(text.Substring(num + 1)); if (text2.Length > 0) { map[Unescape(text.Substring(0, num))] = text2; } } } } } private static string Unescape(string s) { if (s.IndexOf('\\') >= 0) { return s.Replace("\\n", "\n").Replace("\\t", "\t"); } return s; } public static void LoadCsvPre() { try { Inject(addNow: false); } catch { } } public static int Inject(bool addNow) { Scan(); object obj = ((!addNow) ? null : AccessTools.Field(typeof(Localization), "m_instance")?.GetValue(null)); Localization val = (Localization)((obj is Localization) ? obj : null); MethodInfo methodInfo = ((val != null && val.GetSelectedLanguage() == "Turkish") ? AccessTools.Method(typeof(Localization), "AddWord", new Type[2] { typeof(string), typeof(string) }, (Type[])null) : null); int num = 0; foreach (FieldInfo[] registry in registries) { if (!(registry[0].GetValue(null) is IEnumerable enumerable)) { continue; } foreach (object item in enumerable) { if (item != null && registry[2].GetValue(item) is Dictionary<string, string> dictionary && dictionary.TryGetValue("English", out var value) && value != null && map.TryGetValue(value, out var value2)) { dictionary["Turkish"] = value2; num++; if (methodInfo != null && registry[1].GetValue(item) is string text) { methodInfo.Invoke(obj, new object[2] { text, value2 }); } } } } return num; } private static void Scan() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!scanned.Add(assembly) || assembly.IsDynamic) { continue; } Type[] types; try { types = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } catch { continue; } Type[] array = types; foreach (Type type in array) { if (!(type == null) && !(type.Name != "LocalizeKey")) { FieldInfo field = type.GetField("keys", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type.GetField("Key", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field3 = type.GetField("Localizations", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field2 != null && field3 != null && typeof(IEnumerable).IsAssignableFrom(field.FieldType) && field3.FieldType == typeof(Dictionary<string, string>)) { registries.Add(new FieldInfo[3] { field, field2, field3 }); } } } } } } [BepInPlugin("egebu.turkceek", "Türkçe Ek Çeviriler", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown Keys.Load(Path.Combine(Paths.ConfigPath, "TurkceEk")); if (Keys.Count != 0) { new Harmony("egebu.turkceek").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Keys), "LoadCsvPre", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Keys.Inject(addNow: true); } } } }
plugins/ImmersiveTraderTurkce.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using ImmersiveTrader; using ImmersiveTrader.Models; using Microsoft.CodeAnalysis; using UnityEngine; using Valheim.UI; [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("ImmersiveTraderTurkce")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ImmersiveTraderTurkce")] [assembly: AssemblyTitle("ImmersiveTraderTurkce")] [assembly: AssemblyVersion("1.0.0.0")] [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 ImmersiveTraderTurkce { public static class Engine { private sealed class Template { public Regex Pattern; public string Turkish; public string Anchor; public int Literal; } private static readonly Dictionary<string, string> exact = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly List<Template> templates = new List<Template>(); private static readonly List<KeyValuePair<string, string>> names = new List<KeyValuePair<string, string>>(); private static readonly Dictionary<string, string> cache = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly Regex Hole = new Regex("\\{(\\d+)\\}"); public static Func<string, string> Creature; public static Func<string, string> Item; public static Func<string, string> Skill; public static Func<bool> IsTurkish = () => false; private static readonly string[] Separators = new string[2] { "\n", " | " }; public static int Count => exact.Count + templates.Count; public static void Load(string dir) { if (!Directory.Exists(dir)) { return; } string[] files = Directory.GetFiles(dir, "*.tsv"); for (int i = 0; i < files.Length; i++) { string[] array = File.ReadAllLines(files[i], Encoding.UTF8); for (int j = 0; j < array.Length; j++) { string text = array[j].TrimEnd(new char[1] { '\r' }); if (text.Length == 0 || text[0] == '#') { continue; } string[] array2 = text.Split(new char[1] { '\t' }); if (array2.Length < 2 || array2[0].Length == 0 || array2[1].Length == 0) { continue; } string text2 = Unescape(array2[0]); string text3 = Unescape(array2[1]); string text4 = ((array2.Length > 2) ? array2[2].Trim() : "exact"); if (text4 == "template" && Hole.IsMatch(text2)) { AddTemplate(text2, text3); continue; } exact[text2] = text3; if (text4 == "name" && text2.Length >= 4) { names.Add(new KeyValuePair<string, string>(text2, text3)); } } } templates.Sort((Template a, Template b) => b.Literal.CompareTo(a.Literal)); names.Sort((KeyValuePair<string, string> a, KeyValuePair<string, string> b) => b.Key.Length.CompareTo(a.Key.Length)); } private static string Unescape(string s) { if (s.IndexOf('\\') >= 0) { return s.Replace("\\n", "\n").Replace("\\t", "\t"); } return s; } private static void AddTemplate(string en, string tr) { StringBuilder stringBuilder = new StringBuilder("^"); int num = 0; int num2 = 0; string text = ""; foreach (Match item in Hole.Matches(en)) { string text2 = en.Substring(num, item.Index - num); stringBuilder.Append(Regex.Escape(text2)); num2 += text2.Length; if (text2.Trim().Length > text.Trim().Length) { text = text2; } stringBuilder.Append("(?<h").Append(item.Groups[1].Value).Append(">[^\\n]+?)"); num = item.Index + item.Length; } string text3 = en.Substring(num); stringBuilder.Append(Regex.Escape(text3)).Append('$'); num2 += text3.Length; if (text3.Trim().Length > text.Trim().Length) { text = text3; } try { templates.Add(new Template { Pattern = new Regex(stringBuilder.ToString(), RegexOptions.Singleline | RegexOptions.CultureInvariant), Turkish = tr, Anchor = text.Trim(), Literal = num2 }); } catch { } } public static string Translate(string s) { if (string.IsNullOrEmpty(s) || !IsTurkish()) { return s; } if (cache.TryGetValue(s, out var value)) { return value; } string text = Run(s, 0, phrases: true); if (cache.Count > 20000) { cache.Clear(); } cache[s] = text; return text; } private static string Run(string s, int depth, bool phrases) { if (string.IsNullOrEmpty(s) || depth > 6) { return s; } if (exact.TryGetValue(s, out var value)) { return value; } string text = s.Trim(); if (text.Length != s.Length && text.Length > 0 && exact.TryGetValue(text, out value)) { return s.Replace(text, value); } string text2 = MatchTemplate(s, depth); if (text2 != null) { return text2; } string[] separators = Separators; foreach (string text3 in separators) { if (s.IndexOf(text3, StringComparison.Ordinal) >= 0) { string[] array = s.Split(new string[1] { text3 }, StringSplitOptions.None); bool flag = false; for (int j = 0; j < array.Length; j++) { string text4 = Run(array[j], depth + 1, phrases); flag |= text4 != array[j]; array[j] = text4; } if (flag) { return string.Join(text3, array); } } } if (!phrases) { return s; } return Phrases(s); } private static string MatchTemplate(string s, int depth) { foreach (Template template in templates) { if (template.Anchor.Length > 0 && s.IndexOf(template.Anchor, StringComparison.Ordinal) < 0) { continue; } Match m = template.Pattern.Match(s); if (m.Success) { return Hole.Replace(template.Turkish, delegate(Match h) { Group obj = m.Groups["h" + h.Groups[1].Value]; return (!obj.Success) ? h.Value : Arg(obj.Value, depth + 1); }); } } return null; } private static string Arg(string v, int depth) { if (v.Length == 0) { return v; } string text = Run(v, depth, phrases: true); if (text != v) { return text; } string text2 = Targets(v); if (text2 != null) { return text2; } if (Item != null && v.IndexOf(' ') < 0) { string text3 = Item(v); if (!string.IsNullOrEmpty(text3)) { return text3; } } if (Skill != null && Regex.IsMatch(v, "^[A-Z][A-Za-z]+$")) { string text4 = Skill(v); if (!string.IsNullOrEmpty(text4)) { return text4; } } return v; } private static string Targets(string v) { if (Creature == null || v.IndexOf(' ') >= 0) { return null; } if (v.IndexOf(';') < 0 && v.IndexOf('|') < 0 && v.IndexOf(':') < 0) { return Creature(v); } List<string> list = new List<string>(); string[] array = v.Split(new char[1] { ';' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); List<string> list2 = new List<string>(); string[] array3 = array2[0].Split(new char[1] { '|' }); foreach (string arg in array3) { string text = Creature(arg); if (text == null) { return null; } if (!list2.Contains(text)) { list2.Add(text); } } list.Add(string.Join(" / ", list2.ToArray()) + ((array2.Length > 1) ? (" ×" + array2[1]) : "")); } return string.Join(", ", list.ToArray()); } private static string Phrases(string s) { string text = s; foreach (KeyValuePair<string, string> name in names) { if (text.IndexOf(name.Key, StringComparison.Ordinal) >= 0) { text = text.Replace(name.Key, name.Value); } } return text; } } [BepInPlugin("egebu.immersivetraderturkce", "ImmersiveTrader Türkçe", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_014c: Expected O, but got Unknown Reward.Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sözleşme ödülü", "Sikkeye çevir", true, "Av sözleşmelerinin beceri seviyesi ödülü yerine sikke ver (Path of Valheiman beceri seviyelerini işlevsiz kıldığı için).").Value; Reward.PerLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Sözleşme ödülü", "Seviye başına sikke", 50, new ConfigDescription("Sözleşmenin vereceği her beceri seviyesi yerine ödenen sikke (sözleşmeler 2 seviye verir).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 400), Array.Empty<object>())).Value; Reward.TierStep = ((BaseUnityPlugin)this).Config.Bind<float>("Sözleşme ödülü", "Biyom başına artış", 0.5f, new ConfigDescription("Sözleşmeyi veren tüccarın biyom kademesi başına ödül artışı (0 = Çayır … 6 = Kül Diyarı). 0,5 ile Çayır 100, Kül Diyarı 400 sikke.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())).Value; Engine.Load(Path.Combine(Paths.ConfigPath, "ImmersiveTraderTurkce")); Engine.IsTurkish = Turkish; Engine.Creature = Creature; Engine.Item = Item; Engine.Skill = Skill; Harmony val = new Harmony("egebu.immersivetraderturkce"); Reward.Apply(val); Sinks.Apply(val); } private static bool Turkish() { try { return Localization.instance != null && Localization.instance.GetSelectedLanguage() == "Turkish"; } catch { return false; } } private static string Creature(string id) { try { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(id) : null); Character val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Character>() : null); if ((Object)(object)val2 == (Object)null || string.IsNullOrEmpty(val2.m_name)) { return null; } string text = Localization.instance.Localize(val2.m_name); return (string.IsNullOrEmpty(text) || text.StartsWith("$")) ? null : text; } catch { return null; } } private static string Item(string id) { try { GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(id) : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); string text = ((!((Object)(object)val2 != (Object)null)) ? null : val2.m_itemData?.m_shared?.m_name); if (string.IsNullOrEmpty(text)) { return null; } string text2 = Localization.instance.Localize(text); return (string.IsNullOrEmpty(text2) || text2.StartsWith("$")) ? null : text2; } catch { return null; } } private static string Skill(string name) { try { if (!Enum.IsDefined(typeof(SkillType), name)) { return null; } string text = Localization.instance.Localize("$skill_" + name.ToLowerInvariant()); return (string.IsNullOrEmpty(text) || text.StartsWith("$") || text.StartsWith("[")) ? null : text; } catch { return null; } } } public static class Reward { public static bool Enabled = true; public static int PerLevel = 50; public static float TierStep = 0.5f; private static readonly Regex Levels = new Regex("\\+(\\d+(?:[.,]\\d+)?) levels \\(\\w+\\)"); private static readonly Regex Granted = new Regex("^\\w+ \\+[\\d.,]+ \\([\\d.,]+\\)"); private static readonly Regex IssuedBy = new Regex("Issued by: <color=yellow>([^<]+)</color>"); [ThreadStatic] private static int lastPaid; [ThreadStatic] private static string lastRadialName; public static int Coins(int tier, float levels) { float num = Mathf.Clamp(tier, 0, 6); return Mathf.Clamp(Mathf.RoundToInt(levels * (float)PerLevel * (1f + TierStep * num)), 1, 999); } private static int TierOfTrader(string traderId) { TraderDefinition val = ((IEnumerable<TraderDefinition>)TraderRegistry.Traders).FirstOrDefault((Func<TraderDefinition, bool>)((TraderDefinition x) => x.Id == traderId)); if (!(val != (TraderDefinition)null)) { return 0; } return val.BiomeTier; } public static int Apply(Harmony h) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown if (!Enabled) { return 0; } return 0 + Patch(h, () => AccessTools.Method(typeof(ContractSkillReward), "TryGrant", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Reward), "GrantPre", (Type[])null), null) + Patch(h, () => AccessTools.Method(typeof(ContractMetadata), "GetProgressText", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(Reward), "ProgressPost", (Type[])null) { priority = 800 }) + Patch(h, () => AccessTools.Method(typeof(TraderRegistry).Assembly.GetType("ImmersiveTrader.TraderReactions"), "ContractCompleted", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Reward), "CompletedPre", (Type[])null) { priority = 800 }, null) + Patch(h, () => AccessTools.PropertySetter(typeof(RadialMenuElement), "Name"), new HarmonyMethod(typeof(Reward), "RadialNamePre", (Type[])null) { priority = 800 }, null); } private static int Patch(Harmony h, Func<MethodBase> find, HarmonyMethod prefix, HarmonyMethod postfix) { try { MethodBase methodBase = find(); if (methodBase == null) { return 0; } h.Patch(methodBase, prefix, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return 1; } catch { return 0; } } private static bool GrantPre(Player player, SkillType type, int levels, ref float before, ref float after, ref bool __result) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) lastPaid = 0; try { int num = 0; string id = default(string); string issuer = default(string); int num2 = default(int); foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (ContractMetadata.TryRead(allItem, ref id, ref issuer, ref num2)) { TraderActivityDefinition val = ((IEnumerable<TraderActivityDefinition>)TraderActivityRegistry.Activities).FirstOrDefault((Func<TraderActivityDefinition, bool>)((TraderActivityDefinition x) => x.Id == id && x.TraderId == issuer)); if (!(val == (TraderActivityDefinition)null) && ContractMetadata.GetRewardSkill(allItem, id, val.RewardSkill) == type && num2 >= ContractMetadata.GetRequiredAmount(allItem, val.RequiredAmount)) { num = Math.Max(num, TierOfTrader(issuer)); } } } int num3 = Coins(num, levels); GameObject val2 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("Coins") : null); Inventory inventory = ((Humanoid)player).GetInventory(); if ((Object)(object)val2 == (Object)null || !inventory.CanAddItem(val2, num3)) { return true; } inventory.AddItem(val2, num3); before = 0f; after = levels; lastPaid = num3; __result = true; return false; } catch { return true; } } private static void CompletedPre(object[] __args) { if (lastPaid > 0 && __args.Length >= 3 && __args[2] is string input) { __args[2] = Granted.Replace(input, lastPaid + " coins"); lastPaid = 0; } } private static void ProgressPost(ItemData item, ref string __result) { if (string.IsNullOrEmpty(__result) || __result.IndexOf(" levels (", StringComparison.Ordinal) < 0) { return; } try { string text = default(string); string traderId = default(string); int num = default(int); if (ContractMetadata.TryRead(item, ref text, ref traderId, ref num)) { int tier = TierOfTrader(traderId); __result = Levels.Replace(__result, (Match m) => Coins(tier, Parse(m.Groups[1].Value)) + " coins"); } } catch { } } private static void RadialNamePre(object[] __args) { if (__args.Length != 0 && __args[0] is string text) { lastRadialName = text; } } public static string Rewrite(string s) { if (!Enabled || string.IsNullOrEmpty(s) || s.IndexOf(" levels (", StringComparison.Ordinal) < 0) { return s; } try { int tier = FindTier(s); return Levels.Replace(s, (Match m) => Coins(tier, Parse(m.Groups[1].Value)) + " coins"); } catch { return s; } } private static int FindTier(string s) { Match m = IssuedBy.Match(s); if (m.Success) { TraderDefinition val = ((IEnumerable<TraderDefinition>)TraderRegistry.Traders).FirstOrDefault((Func<TraderDefinition, bool>)((TraderDefinition x) => x.Name == m.Groups[1].Value)); if (val != (TraderDefinition)null) { return val.BiomeTier; } } TraderActivityDefinition val2 = null; foreach (TraderActivityDefinition activity in TraderActivityRegistry.Activities) { if (s.IndexOf(activity.Title, StringComparison.Ordinal) >= 0 && (val2 == (TraderActivityDefinition)null || activity.Title.Length > val2.Title.Length)) { val2 = activity; } } if (val2 == (TraderActivityDefinition)null && lastRadialName != null) { val2 = ((IEnumerable<TraderActivityDefinition>)TraderActivityRegistry.Activities).FirstOrDefault((Func<TraderActivityDefinition, bool>)((TraderActivityDefinition x) => x.Title == lastRadialName)); } if (!(val2 != (TraderActivityDefinition)null)) { return 0; } return TierOfTrader(val2.TraderId); } private static float Parse(string v) { return float.Parse(v.Replace(',', '.'), CultureInfo.InvariantCulture); } } public static class Sinks { private const string ModAssembly = "ImmersiveTrader"; [ThreadStatic] private static bool inside; public static int Apply(Harmony h) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown int num = 0; HarmonyMethod prefix = new HarmonyMethod(typeof(Sinks), "StringArgs", (Type[])null); HarmonyMethod postfix = new HarmonyMethod(typeof(Sinks), "Result", (Type[])null) { priority = 0 }; num += PatchAll(h, typeof(Player), "Message", prefix, null); num += PatchAll(h, typeof(Chat), "SetNpcText", prefix, null); string[] array = new string[3] { "Name", "SubTitle", "Description" }; foreach (string p in array) { num += Patch(h, Find(() => AccessTools.PropertySetter(typeof(RadialMenuElement), p)), prefix, null); } foreach (MethodInfo item in from m in typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "GetTooltip" && m.ReturnType == typeof(string) select m) { num += Patch(h, item, null, postfix); } num += PatchAll(h, typeof(StatusEffect), "GetTooltipString", null, postfix); num += Patch(h, Find(() => AccessTools.Method(typeof(Localization), "Localize", new Type[1] { typeof(string) }, (Type[])null)), null, new HarmonyMethod(typeof(Sinks), "LocalizeResult", (Type[])null) { priority = 0 }); Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ImmersiveTrader"); if (assembly != null) { Type[] array2; try { array2 = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array2 = ex.Types.Where((Type t) => t != null).ToArray(); } Type type = array2.FirstOrDefault((Type t) => t.Name == "NoticeBoardNotes"); if (type != null) { num += PatchAll(h, type, "Text", prefix, null); } foreach (Type item2 in array2.Where((Type t) => typeof(Hoverable).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)) { num += PatchAll(h, item2, "GetHoverText", null, postfix); num += PatchAll(h, item2, "GetHoverName", null, postfix); } Type[] array3 = array2; for (int i = 0; i < array3.Length; i++) { PropertyInfo property = array3[i].GetProperty("LocalizedName", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.PropertyType == typeof(string) && property.GetGetMethod(nonPublic: true) != null) { num += Patch(h, property.GetGetMethod(nonPublic: true), null, postfix); } } foreach (Type item3 in array2.Where((Type t) => typeof(StatusEffect).IsAssignableFrom(t))) { num += PatchAll(h, item3, "GetTooltipString", null, postfix); } } return num; } private static int PatchAll(Harmony h, Type type, string name, HarmonyMethod prefix, HarmonyMethod postfix) { int num = 0; try { MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == name && !methodInfo.IsAbstract && (postfix == null || methodInfo.ReturnType == typeof(string))) { num += Patch(h, methodInfo, prefix, postfix); } } } catch { } return num; } private static MethodBase Find(Func<MethodBase> f) { try { return f(); } catch { return null; } } private static int Patch(Harmony h, MethodBase m, HarmonyMethod prefix, HarmonyMethod postfix) { if (m == null) { return 0; } try { h.Patch(m, prefix, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return 1; } catch { return 0; } } private static void StringArgs(object[] __args) { if (inside || __args == null) { return; } inside = true; try { for (int i = 0; i < __args.Length; i++) { if (__args[i] is string { Length: >0 } text) { __args[i] = Engine.Translate(Reward.Rewrite(text)); } } } catch { } finally { inside = false; } } private static void Result(ref string __result) { if (inside || string.IsNullOrEmpty(__result)) { return; } inside = true; try { __result = Engine.Translate(Reward.Rewrite(__result)); } catch { } finally { inside = false; } } private static void LocalizeResult(ref string __result) { if (inside || string.IsNullOrEmpty(__result) || __result.Length < 3) { return; } inside = true; try { __result = Engine.Translate(Reward.Rewrite(__result)); } catch { } finally { inside = false; } } } }