From 4a10e03f8c9da688a1921f59389a2676614ad28f Mon Sep 17 00:00:00 2001 From: Awbugl Date: Tue, 17 Jan 2023 23:20:40 +0800 Subject: [PATCH] Update 2.4.7 --- CHANGELOG.md | 11 ++- ProjectGenesis.csproj | 2 + src/Compatibility/IncompatibleCheckPatch.cs | 30 +------ .../MoreMegaStructureCompatibilityPatch.cs | 81 +----------------- .../MoreMegaStructureEditDataPatches.cs | 84 +++++++++++++++++++ src/Patches/UIMainMenuPatches.cs | 22 +++++ src/ProjectGenesis.cs | 8 +- 7 files changed, 125 insertions(+), 113 deletions(-) create mode 100644 src/Patches/MoreMegaStructureEditDataPatches.cs create mode 100644 src/Patches/UIMainMenuPatches.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b3ea4..7e85ebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +- v2.4.7 + + 修复了启动红字问题 + + + Fix the problem when starting + +
+ 点击展开日志 | Click to view all + - v2.4.6 + 大幅提高了电解水配方的耗电量 + 完成与巨构MOD的互相兼容,且加入了部分新配方 @@ -6,9 +14,6 @@ + Completed the compatibility with the MoreMegaStructure MOD and added some new recipes -
- 点击展开日志 | Click to view all - - v2.4.5 + 添加了MOD冲突提示与加载提示 + 小幅提高了MOD兼容性 diff --git a/ProjectGenesis.csproj b/ProjectGenesis.csproj index cbaf681..3730b1c 100644 --- a/ProjectGenesis.csproj +++ b/ProjectGenesis.csproj @@ -105,11 +105,13 @@ + + diff --git a/src/Compatibility/IncompatibleCheckPatch.cs b/src/Compatibility/IncompatibleCheckPatch.cs index 879e84f..4f6bbb5 100644 --- a/src/Compatibility/IncompatibleCheckPatch.cs +++ b/src/Compatibility/IncompatibleCheckPatch.cs @@ -1,9 +1,6 @@ using System.Collections.Generic; -using System.Text; using BepInEx; using HarmonyLib; -using ProjectGenesis.Patches; -using ProjectGenesis.Utils; namespace ProjectGenesis.Patches { @@ -33,32 +30,7 @@ public void Awake() Dictionary pluginInfos = BepInEx.Bootstrap.Chainloader.PluginInfos; GalacticScaleInstalled = pluginInfos.ContainsKey(GalacticScaleGUID); DSPBattleInstalled = pluginInfos.ContainsKey(DSPBattleGUID); - - Harmony.CreateAndPatchAll(typeof(UIMainMenuPatch)); + Harmony.CreateAndPatchAll(typeof(UIMainMenuPatches)); } } } - -public static class UIMainMenuPatch -{ - private static bool _shown; - - [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] - [HarmonyPostfix] - public static void OnMainMenuOpen() - { - if(_shown) return; - - var sb = new StringBuilder(); - - if (IncompatibleCheckPatch.GalacticScaleInstalled) sb.AppendLine("GalacticScaleInstalled".TranslateFromJson()); - - if (IncompatibleCheckPatch.DSPBattleInstalled) sb.AppendLine("DSPBattleInstalled".TranslateFromJson()); - - sb.AppendLine("GenesisBookLoadMessage".TranslateFromJson()); - - UIMessageBox.Show("GenesisBookLoadTitle".TranslateFromJson(), sb.ToString(), "Ok".TranslateFromJson(), UIMessageBox.INFO); - - _shown = true; - } -} diff --git a/src/Compatibility/MoreMegaStructureCompatibilityPatch.cs b/src/Compatibility/MoreMegaStructureCompatibilityPatch.cs index 63e7785..d15a43e 100644 --- a/src/Compatibility/MoreMegaStructureCompatibilityPatch.cs +++ b/src/Compatibility/MoreMegaStructureCompatibilityPatch.cs @@ -1,13 +1,11 @@ using BepInEx; using HarmonyLib; -using ProjectGenesis.Utils; -using xiaoye97; +using ProjectGenesis.Patches; // ReSharper disable InconsistentNaming // ReSharper disable MemberCanBeInternal // ReSharper disable MemberCanBePrivate.Global // ReSharper disable ClassNeverInstantiated.Global -// ReSharper disable LoopCanBePartlyConvertedToQuery namespace ProjectGenesis.Compatibility { @@ -21,81 +19,6 @@ public class MoreMegaStructureCompatibilityPatch : BaseUnityPlugin private const string MoreMegaStructureGUID = "Gnimaerd.DSP.plugin.MoreMegaStructure"; - public void Awake() => Harmony.CreateAndPatchAll(typeof(EditDataPatch)); - } - - internal static class EditDataPatch - { - private static readonly int[] AddedRecipes = new[] - { - 330, 331, 332, 333, 334, 335, 336, 337, 350, 338, 339, 340, 341, 342, 554, 351, 556, 558, - 562, 559, 561, 553, 560, 557, 555, 552, 376, 377, 378, 379, 380, 381, 343, 344, 345, 346, - 347, 348, 349, 363, 364, 375 - }; - - private static readonly int[] AddedItems = new[] - { - 9480, 9481, 9482, 9483, 9484, 9485, 9486, 9487, 9488, 9489, 9490, 9491, 9492, 9500, 9493, 9494, - 9495, 9496, 9497, 9498, 9499, 9501, 9502, 9512 - }; - - [HarmonyPostfix] - [HarmonyAfter(LDBToolPlugin.MODGUID)] - [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] - public static void LDBToolOnPostAddDataAction() - { - foreach (var strings in LDB.strings.dataArray) - { - switch (strings.Name) - { - case "引力钻头描述": - strings.ZHCN = "借助黑洞本身的引力,引力钻头能够将物质从黑洞中取出。借助谐振盘,黑洞原质将能够被解压并在星系内输送。"; - strings.ENUS - = "The graviton drill can pull matter out of the black hole using the gravity of the black hole itself. With the help of the resonant disc, the matter from the black hole will be able to be decompressed and transported within the galaxy."; - break; - - case "物质解压器功能文本": - strings.ZHCN = "产出一些基础资源(例如铁块),可被对应的物质重构器接收。"; - break; - - case "单极磁石重构装置": - strings.ZHCN = "钨矿重构装置"; - strings.ENUS = "Tungsten receiver"; - break; - } - } - - foreach (var recipeID in AddedRecipes) - { - var recipeProto = LDB.recipes.Select(recipeID); - recipeProto.Type = (ERecipeType)10; - recipeProto.name = recipeProto.Name.Translate(); - recipeProto.description = recipeProto.Description.Translate(); - - if (recipeProto.Results.Length > 0) - { - var recipeProtoResult = recipeProto.Results[0]; - - switch (recipeProtoResult) - { - case ProtoIDUsedByPatches.I巨型精密组装厂: - case ProtoIDUsedByPatches.I巨型对撞机: - recipeProto.ItemCounts[0] = 60; - continue; - - case ProtoIDUsedByPatches.I人造恒星: - recipeProto.ItemCounts[0] = 30; - continue; - } - } - } - - foreach (var itemID in AddedItems) - { - var itemProto = LDB.items.Select(itemID); - itemProto.name = itemProto.Name.Translate(); - itemProto.description = itemProto.Description.Translate(); - } - } + public void Awake() => Harmony.CreateAndPatchAll(typeof(MoreMegaStructureEditDataPatches)); } } diff --git a/src/Patches/MoreMegaStructureEditDataPatches.cs b/src/Patches/MoreMegaStructureEditDataPatches.cs new file mode 100644 index 0000000..651537b --- /dev/null +++ b/src/Patches/MoreMegaStructureEditDataPatches.cs @@ -0,0 +1,84 @@ +using HarmonyLib; +using ProjectGenesis.Compatibility; +using ProjectGenesis.Utils; +using xiaoye97; + +// ReSharper disable LoopCanBePartlyConvertedToQuery + +namespace ProjectGenesis.Patches +{ + internal static class MoreMegaStructureEditDataPatches + { + private static readonly int[] AddedRecipes = new[] + { + 330, 331, 332, 333, 334, 335, 336, 337, 350, 338, 339, 340, 341, 342, 554, 351, 556, 558, + 562, 559, 561, 553, 560, 557, 555, 552, 376, 377, 378, 379, 380, 381, 343, 344, 345, 346, + 347, 348, 349, 363, 364, 375 + }; + + private static readonly int[] AddedItems = new[] + { + 9480, 9481, 9482, 9483, 9484, 9485, 9486, 9487, 9488, 9489, 9490, 9491, 9492, 9500, 9493, 9494, + 9495, 9496, 9497, 9498, 9499, 9501, 9502, 9512 + }; + + [HarmonyPostfix] + [HarmonyAfter(LDBToolPlugin.MODGUID)] + [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] + public static void LDBToolOnPostAddDataAction() + { + foreach (var strings in LDB.strings.dataArray) + { + switch (strings.Name) + { + case "引力钻头描述": + strings.ZHCN = "借助黑洞本身的引力,引力钻头能够将物质从黑洞中取出。借助谐振盘,黑洞原质将能够被解压并在星系内输送。"; + strings.ENUS + = "The graviton drill can pull matter out of the black hole using the gravity of the black hole itself. With the help of the resonant disc, the matter from the black hole will be able to be decompressed and transported within the galaxy."; + break; + + case "物质解压器功能文本": + strings.ZHCN = "产出一些基础资源(例如铁块),可被对应的物质重构器接收。"; + break; + + case "单极磁石重构装置": + strings.ZHCN = "钨矿重构装置"; + strings.ENUS = "Tungsten receiver"; + break; + } + } + + foreach (var recipeID in AddedRecipes) + { + var recipeProto = LDB.recipes.Select(recipeID); + recipeProto.Type = (ERecipeType)10; + recipeProto.name = recipeProto.Name.Translate(); + recipeProto.description = recipeProto.Description.Translate(); + + if (recipeProto.Results.Length > 0) + { + var recipeProtoResult = recipeProto.Results[0]; + + switch (recipeProtoResult) + { + case ProtoIDUsedByPatches.I巨型精密组装厂: + case ProtoIDUsedByPatches.I巨型对撞机: + recipeProto.ItemCounts[0] = 60; + continue; + + case ProtoIDUsedByPatches.I人造恒星: + recipeProto.ItemCounts[0] = 30; + continue; + } + } + } + + foreach (var itemID in AddedItems) + { + var itemProto = LDB.items.Select(itemID); + itemProto.name = itemProto.Name.Translate(); + itemProto.description = itemProto.Description.Translate(); + } + } + } +} diff --git a/src/Patches/UIMainMenuPatches.cs b/src/Patches/UIMainMenuPatches.cs new file mode 100644 index 0000000..dfe9e10 --- /dev/null +++ b/src/Patches/UIMainMenuPatches.cs @@ -0,0 +1,22 @@ +using System.Text; +using HarmonyLib; +using ProjectGenesis.Patches; +using ProjectGenesis.Utils; + +public static class UIMainMenuPatches +{ + [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] + [HarmonyPostfix] + public static void OnMainMenuOpen() + { + var sb = new StringBuilder(); + + if (IncompatibleCheckPatch.GalacticScaleInstalled) sb.AppendLine("GalacticScaleInstalled".TranslateFromJson()); + + if (IncompatibleCheckPatch.DSPBattleInstalled) sb.AppendLine("DSPBattleInstalled".TranslateFromJson()); + + sb.AppendLine("GenesisBookLoadMessage".TranslateFromJson()); + + UIMessageBox.Show("GenesisBookLoadTitle".TranslateFromJson(), sb.ToString(), "Ok".TranslateFromJson(), UIMessageBox.INFO); + } +} diff --git a/src/ProjectGenesis.cs b/src/ProjectGenesis.cs index c4d93ee..847ec63 100644 --- a/src/ProjectGenesis.cs +++ b/src/ProjectGenesis.cs @@ -41,7 +41,7 @@ public class ProjectGenesis : BaseUnityPlugin, IModCanSave, IMultiplayerModWithS { public const string MODGUID = "org.LoShin.GenesisBook"; public const string MODNAME = "GenesisBook"; - public const string VERSION = "2.4.6"; + public const string VERSION = "2.4.7"; public string Version => VERSION; @@ -95,7 +95,11 @@ public void Awake() Harmony = new Harmony(MODGUID); - foreach (var type in executingAssembly.GetTypes()) Harmony.PatchAll(type); + foreach (var type in executingAssembly.GetTypes()) + { + if (type == typeof(MoreMegaStructureEditDataPatches) || type == typeof(UIMainMenuPatches)) continue; + Harmony.PatchAll(type); + } LDBTool.PreAddDataAction += PreAddDataAction; LDBTool.PostAddDataAction += PostAddDataAction;