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 BepInEx; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ChestESP_CN")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChestESP_CN")] [assembly: AssemblyTitle("ChestESP_CN")] [assembly: AssemblyVersion("1.0.0.0")] namespace ChestESP_CN; [BepInPlugin("Jamie.chestesp.simplifiedchinese", "ChestESP_SimplifiedChinese", "1.0.0")] public class Plugin : BaseUnityPlugin { private Harmony harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown harmony = new Harmony("Jamie.chestesp.simplifiedchinese"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ChestESP_SimplifiedChinese 1.0.0 is Loaded"); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } [HarmonyPatch] internal static class DrawMenuPatch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("ESP.Menu"); if (type == null) { throw new Exception("找不到 ESP.Menu"); } MethodInfo methodInfo = AccessTools.Method(type, "DrawMenu", (Type[])null, (Type[])null); if (methodInfo == null) { throw new Exception("找不到 ESP.Menu.DrawMenu"); } return methodInfo; } private static IEnumerable Transpiler(IEnumerable instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldstr && instruction.operand is string text && text == "ESP Settings") { instruction.operand = "ESP 设置"; } yield return instruction; } } } [HarmonyPatch] internal static class MenuWindowPatch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("ESP.Menu"); if (type == null) { throw new Exception("找不到 ESP.Menu"); } MethodInfo methodInfo = AccessTools.Method(type, "MenuWindow", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo == null) { throw new Exception("找不到 ESP.Menu.MenuWindow(int)"); } return methodInfo; } private static IEnumerable Transpiler(IEnumerable instructions) { Dictionary translations = new Dictionary { { "General Settings", "常规设置" }, { "Label Size: {0}", "标签大小:{0}" }, { " Alternative Look", " 替代显示样式" }, { "Alt Text:", "替代文本:" }, { " Text Shadow", " 文字阴影" }, { "Main Toggles", "主要显示项目" }, { " Chests", " 宝箱" }, { "Show Item Names", "显示物品名称" }, { " Temp Chests", " 临时宝箱" }, { "Shops", "商店" }, { "Printers", "打印机" }, { "Scrappers", "回收机" }, { "Teleporters", "传送器" }, { "Drones & Turrets", "无人机与炮塔" }, { "Drone Combiners", "无人机合成器" }, { " Shrines", " 神龛" }, { " Altars", " 祭坛" }, { "Pressure Plates", "压力板" }, { "Vulture Eggs", "秃鹫蛋" }, { "Barrels", "木桶" }, { "All Other Interactions", "其他所有可交互物" }, { "Item & Equipment Colors", "物品与装备颜色" }, { "Common", "普通(白)" }, { "Uncommon", "稀有(绿)" }, { "Legendary", "传奇(红)" }, { "Boss", "首领(黄)" }, { "Lunar", "月球物品" }, { "Void Common", "虚空普通" }, { "Void Uncommon", "虚空稀有" }, { "Void Legendary", "虚空传奇" }, { "Void Boss", "虚空首领" }, { "Equipment", "主动装备" }, { "Lunar Equipment", "月球装备" }, { "Shrine Settings", "神龛设置" }, { "Shrine of Blood", "鲜血神龛" }, { "Shrine of Chance", "机会神龛" }, { "Shrine of Combat", "战斗神龛" }, { "Shrine of Gold", "黄金神龛" }, { "Shrine of the Mountain", "山之神龛" }, { "Shrine of Healing", "治疗神龛" }, { "Cleansing Pool", "净化池" }, { "Halcyon Shrine", "翠绿神龛" }, { "Revive Shrine", "复活神龛" }, { "Altar Settings", "祭坛设置" }, { "Newt Altar", "纽特祭坛" }, { "Gold Altar", "黄金祭坛" }, { "Access Node", "访问节点" } }; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldstr && instruction.operand is string key && translations.TryGetValue(key, out var value)) { instruction.operand = value; } yield return instruction; } } } [HarmonyPatch] internal static class DrawLabelPatch { private static readonly Dictionary Translations = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "Shop", "商店" }, { "Drone Shop", "无人机商店" }, { "Temp Chest", "临时宝箱" }, { "Encrusted Cache", "结壳宝箱" }, { "Void Potential", "虚空潜能" }, { "Adaptive Chest", "自适应宝箱" }, { "Shrine of Blood", "鲜血神龛" }, { "Shrine of Chance", "机会神龛" }, { "Shrine of Combat", "战斗神龛" }, { "Shrine of the mountain", "山之神龛" }, { "Shrine of Healing", "治疗神龛" }, { "Cleansing Pool", "净化池" }, { "Halcyon Shrine", "翠绿神龛" }, { "Shrine of Gold", "黄金神龛" }, { "Revive Shrine", "复活神龛" }, { "Newt Altar", "纽特祭坛" }, { "Gold Altar", "黄金祭坛" }, { "Printer", "打印机" }, { "Scrapper", "回收机" }, { "Drone Scrapper", "无人机回收机" }, { "Teleporter", "传送器" }, { "Pressure Plate", "压力板" }, { "Barrel", "木桶" }, { "Access Node", "访问节点" }, { "Vulture Egg", "秃鹫蛋" }, { "Drone Combiner", "无人机合成器" } }; private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("ESP.ESP"); if (type == null) { throw new Exception("找不到 ESP.ESP 类型"); } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "drawLabel")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 4 && parameters[1].ParameterType == typeof(string)) { return methodInfo; } } } throw new Exception("找不到 ESP.drawLabel(Vector3,string,Color,Vector2)"); } private static void Prefix(ref string labelText) { if (!string.IsNullOrEmpty(labelText) && Translations.TryGetValue(labelText, out var value)) { labelText = value; } } }