using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using YuanAPI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("MainloadTool")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1f825f177c23d6f93d7a76f880b6b634e3dbc61b")] [assembly: AssemblyProduct("MainloadTool")] [assembly: AssemblyTitle("MainloadTool")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 MainloadTool { [HarmonyPatch(typeof(BuildPosiGet))] public class BuildPosiGetPatch { private static int _counter; private static PerBackMapScene _scene; [HarmonyPostfix] [HarmonyPatch("Update")] public static void Postfix(BuildPosiGet __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (++_counter >= 9) { _counter = 0; Vector3 val = Camera.main.ScreenToWorldPoint(Input.mousePosition); if ((Object)(object)_scene == (Object)null) { _scene = ((Component)((Component)__instance).transform.parent).GetComponent(); } MainloadTool.Logger.LogInfo((object)$"[DebugTool] Current Position: {Vector2.op_Implicit(val)} | ({_scene.PoisA_mouse}, {_scene.PoisB_mouse})"); } } } internal class CsvWriter { private readonly List _lines; private readonly List _currentLine; private readonly string _filePath; public int LineCount => _lines.Count; public int CurrentFieldCount => _currentLine.Count; public string FilePath => _filePath; public CsvWriter(string fileName) { if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentException("文件名不能为空", "fileName"); } _filePath = Path.Combine("Output", fileName.Trim() + ".csv"); _lines = new List(); _currentLine = new List(); } public void WriteLine(List fields) { if (fields == null) { throw new ArgumentNullException("fields"); } string item = FormatCsvLine(fields); _lines.Add(item); } public void WriteLine(params string[] fields) { WriteLine(fields.ToList()); } public void WriteField(string field) { _currentLine.Add(field ?? string.Empty); } public void WriteField(List fields) { if (fields == null) { throw new ArgumentNullException("fields"); } _currentLine.AddRange(fields); } public void WriteField(params string[] fields) { WriteField(fields.ToList()); } public void EndRow() { if (_currentLine.Count > 0) { string item = FormatCsvLine(_currentLine); _lines.Add(item); _currentLine.Clear(); } } public void Save() { string directoryName = Path.GetDirectoryName(_filePath); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } try { File.WriteAllLines(_filePath, _lines, Encoding.UTF8); MainloadTool.Logger.LogInfo((object)("CSV文件已保存到: " + _filePath)); } catch (Exception ex) { throw new IOException("保存CSV文件失败: " + ex.Message, ex); } } private string FormatCsvLine(List fields) { IEnumerable values = fields.Select(delegate(string field) { if (field == null) { return string.Empty; } return (field.Contains(",") || field.Contains("\"") || field.Contains("\n") || field.Contains("\r")) ? ("\"" + field.Replace("\"", "\"\"") + "\"") : field; }); return string.Join(",", values); } } internal class DumpAllText { internal static List _languages; private static void DumpText(string name, List> texts) { CsvWriter csvWriter = new CsvWriter(name + MainloadTool.GameVersion); List list = new List { "序号" }; list.AddRange(_languages); csvWriter.WriteLine(list); int count = texts.Count; for (int i = 0; i < count; i++) { csvWriter.WriteField(i.ToString()); csvWriter.WriteField(texts[i]); csvWriter.EndRow(); } csvWriter.Save(); } public static void Text_AllBuild() { CsvWriter csvWriter = new CsvWriter("Text_AllBuild" + MainloadTool.GameVersion); List list = new List { "序号" }; foreach (string language in _languages) { list.Add(language + "建筑"); list.Add(language + "简介"); } csvWriter.WriteLine(list); int count = AllText.Text_AllBuild.Count; for (int i = 0; i < count; i++) { csvWriter.WriteField(i.ToString()); foreach (string item in AllText.Text_AllBuild[i]) { csvWriter.WriteField(item.Split(new char[1] { '|' })); } csvWriter.EndRow(); } csvWriter.Save(); } public static void Text_AllProp() { DumpText("Text_AllProp", AllText.Text_AllProp); } public static void Text_AllPropClass() { DumpText("Text_AllPropClass", AllText.Text_AllPropClass); } public static void Text_TipShow() { DumpText("Text_TipShow", AllText.Text_TipShow); } public static void Text_UIA() { DumpText("Text_UIA", AllText.Text_UIA); } } internal static class DumpMainload { public static void AllPropdata() { CsvWriter csvWriter = new CsvWriter("AllPropdata" + MainloadTool.GameVersion); csvWriter.WriteLine(new List { "序号", "价格", "分类", "文", "武", "商", "艺", "健康", "心情", "魅力", "幸运", "寿命", "计谋", "巫", "医", "相", "卜", "魅", "工" }); int count = Mainload.AllPropdata.Count; for (int i = 0; i < count; i++) { csvWriter.WriteField(i.ToString()); csvWriter.WriteField(Mainload.AllPropdata[i][0]); csvWriter.WriteField(Mainload.AllPropdata[i][1]); csvWriter.WriteField(Mainload.AllPropdata[i][2].Split(new char[1] { '|' })); csvWriter.EndRow(); } csvWriter.Save(); } public static void AllBuilddata() { CsvWriter csvWriter = new CsvWriter("AllBuilddata" + MainloadTool.GameVersion); CsvWriter csvWriter2 = new CsvWriter("AllBuilddata[7]" + MainloadTool.GameVersion); csvWriter.WriteLine(new List { "序号", "null_1", "价格", "升级基准", "列3", "解锁等级", "分类", "null_2", "属性", "生活品质", "列9" }); List list = new List { "序号" }; Dictionary dictionary = new Dictionary { { 0, "文" }, { 1, "武" }, { 2, "商" }, { 3, "艺" }, { 4, "长寿" }, { 5, "爱情" }, { 6, "幸运" }, { 7, "多子" }, { 8, "魅力" }, { 10, "繁荣" }, { 11, "声望" }, { 12, "环境" }, { 13, "安全" }, { 14, "便捷" }, { 16, "教化" }, { 17, "厢房" }, { 18, "农舍" }, { 19, "仓库" }, { 20, "马厩" } }; Dictionary dictionary2 = new Dictionary { { 1, "刚正" }, { 3, "善良" }, { 4, "真诚" }, { 6, "高洁" } }; int num = Mainload.AllBuilddata[0][7].Split(new char[1] { '|' }).Length; for (int i = 0; i < num; i++) { if (i != 9) { list.Add(dictionary.TryGetValue(i, out var value) ? value : $"{i}"); continue; } int num2 = Mainload.AllBuilddata[0][7].Split(new char[1] { '|' })[9].Split(new char[1] { '@' }).Length; for (int j = 0; j < num2; j++) { list.Add(dictionary2.TryGetValue(j, out var value2) ? value2 : $"{i}_{j}"); } } csvWriter2.WriteLine(list); int count = Mainload.AllBuilddata.Count; for (int k = 0; k < count; k++) { csvWriter.WriteField(k.ToString()); csvWriter2.WriteField(k.ToString()); if (k != 161) { csvWriter.WriteField(Mainload.AllBuilddata[k]); string[] array = Mainload.AllBuilddata[k][7].Split(new char[1] { '|' }); for (int l = 0; l < num; l++) { if (l != 9) { csvWriter2.WriteField(array[l]); continue; } csvWriter2.WriteField(array[9].Split(new char[1] { '@' })); } } csvWriter.EndRow(); csvWriter2.EndRow(); } csvWriter.Save(); csvWriter2.Save(); } } [BepInPlugin("cc.lymone.HoL.MainloadTool", "MainloadTool", "3.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MainloadTool : BaseUnityPlugin { public const string MODNAME = "MainloadTool"; public const string MODGUID = "cc.lymone.HoL.MainloadTool"; public const string VERSION = "3.0.0"; internal static ManualLogSource Logger; internal static string GameVersion; internal static ConfigEntry OpenMenuKey; internal static ConfigEntry AutoLoadSaveName; internal static ConfigEntry IsPreventRemoveSave; internal static ConfigEntry IsPrintCurrentPosition; private Rect _windowRect = new Rect(150f, 100f, 800f, 600f); internal bool ShowMenu { get; private set; } private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; GameVersion = "_v" + Mainload.Vision_now.Substring(2); BindConfig(); Harmony val = new Harmony("cc.lymone.HoL.MainloadTool"); val.PatchAll(); Localization.Initialize(); } private void Start() { DumpAllText._languages = Localization.GetAllLocales(); } private void BindConfig() { OpenMenuKey = ((BaseUnityPlugin)this).Config.Bind("加载工具 Mainload Tool", "菜单按键 Open Menu Key", (KeyCode)278, ""); AutoLoadSaveName = ((BaseUnityPlugin)this).Config.Bind("存档工具 Save Tool", "自动加载存档 Auto Load Save Name", "", "打开游戏自动加载存档,0-5为原版支持的存档,留空关闭\n可以自定义其他存档名,需要自行确保文件存在"); IsPreventRemoveSave = ((BaseUnityPlugin)this).Config.Bind("存档工具 Save Tool", "阻止删除存档 Prevent Remove Save", true, "当加载存档出错时,是否阻止删除存档文件"); IsPrintCurrentPosition = ((BaseUnityPlugin)this).Config.Bind("调试工具 Debug Tool", "打印坐标 Print Position", false, "在建筑模式时输出当前坐标到日志 世界坐标|逻辑坐标"); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(OpenMenuKey.Value)) { ShowMenu = !ShowMenu; if (ShowMenu) { Mainload.isMapPanelOpen = false; } Logger.LogInfo((object)("MainloadTool窗口已" + (ShowMenu ? "打开" : "关闭"))); } if (ShowMenu && (Input.mouseScrollDelta.y != 0f || Input.GetMouseButton(0) || Input.GetMouseButton(1) || (Input.GetMouseButton(2) && Input.anyKeyDown && !Input.GetKeyDown((KeyCode)283)))) { Input.ResetInputAxes(); } } private void OnGUI() { //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_002d: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if (ShowMenu) { Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f, 0.95f); GUI.BeginGroup(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height)); GUI.color = new Color(0f, 0f, 0f, 0.1f); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.EndGroup(); GUI.skin.window.padding = new RectOffset(Mathf.RoundToInt(20f), Mathf.RoundToInt(20f), Mathf.RoundToInt(10f), Mathf.RoundToInt(10f)); int fontSize = Mathf.RoundToInt(18f); GUI.skin.textField.fontSize = fontSize; GUI.skin.window.fontSize = fontSize; GUI.skin.label.fontSize = fontSize; GUI.skin.button.fontSize = fontSize; GUI.skin.button.alignment = (TextAnchor)4; _windowRect = GUI.Window(0, _windowRect, new WindowFunction(DrawWindow), "", GUI.skin.window); GUI.backgroundColor = backgroundColor; } } private void DrawWindow(int windowID) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.FlexibleSpace(); GUIStyle val = new GUIStyle(GUI.skin.label); GUILayout.Label("Mainload Tool v3.0.0 for Game " + GameVersion.Substring(1), val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(20f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.BeginVertical(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(0f), GUILayout.ExpandWidth(true) }); GUILayout.Label("Dump AllText", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(350f) }); GUILayout.Space(5f); if (GUILayout.Button("Text_AllProp", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpAllText.Text_AllProp(); } GUILayout.Space(5f); if (GUILayout.Button("Text_AllBuild", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpAllText.Text_AllBuild(); } GUILayout.Space(5f); if (GUILayout.Button("Text_AllPropClass", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpAllText.Text_AllPropClass(); } GUILayout.Space(5f); if (GUILayout.Button("Text_TipShow", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpAllText.Text_TipShow(); } if (GUILayout.Button("Text_UIA", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpAllText.Text_UIA(); } GUILayout.EndVertical(); GUILayout.Space(10f); GUILayout.BeginVertical(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(0f), GUILayout.ExpandWidth(true) }); GUILayout.Label("Dump Mainload", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(350f) }); GUILayout.Space(5f); if (GUILayout.Button("AllPropData", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpMainload.AllPropdata(); } GUILayout.Space(5f); if (GUILayout.Button("AllBuilddata", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(30f) })) { DumpMainload.AllBuilddata(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height)); } } [HarmonyPatch] public class PerDangBTPatch { [HarmonyPrefix] [HarmonyPatch(typeof(PerDangBT), "OnEnableData")] public static bool PreventRemoveSaveWhenCheckError(PerDangBT __instance, ref bool ___isHaveData) { if (!MainloadTool.IsPreventRemoveSave.Value) { return true; } bool flag = true; try { if (ES3.FileExists("FW/" + ((Object)__instance).name + "/GameData.es3")) { ES3.Load>("FamilyData", "FW/" + ((Object)__instance).name + "/GameData.es3"); } else { flag = false; } } catch (Exception ex) { flag = false; MainloadTool.Logger.LogError((object)("Error when load save " + ((Object)__instance).name + ", file remove has been prevented: " + ex.Message)); } ___isHaveData = flag; return false; } } [HarmonyPatch] public class StartGameUIPatch { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string saveName; private GameObject 5__1; private Transform 5__2; private Transform 5__3; private GameObject 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = GameObject.Find("MainUI"); 5__2 = 5__1.transform.Find("CunDangUI"); 5__3 = 5__2.Find("0"); 5__4 = Object.Instantiate(((Component)5__3).gameObject, 5__2); ((Object)5__4).name = saveName; ((Component)5__2).gameObject.SetActive(true); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; ((UnityEvent)((Component)5__4.transform.Find("BackBT")).GetComponent