From 11ed5cc14d7ece4031ae10b9ca2ee5d525e6fa86 Mon Sep 17 00:00:00 2001 From: Awbugl Date: Tue, 17 Jan 2023 22:39:07 +0800 Subject: [PATCH] Update 2.4.6 --- CHANGELOG.md | 13 ++- ProjectGenesis.csproj | 3 +- dependencies/strings.json | 4 +- src/Compatibility/IncompatibleCheckPatch.cs | 6 ++ .../MoreMegaStructureCompatibilityPatch.cs | 101 ++++++++++++++++++ src/Patches/MegaPumpPatches.cs | 1 + src/Patches/OceanDischargePatches.cs | 1 + src/Patches/PlanetGasPatches.cs | 1 + src/Patches/ProductionPatches.cs | 14 +++ src/Patches/UIPatches.cs | 1 + src/ProjectGenesis.cs | 6 +- src/Utils/PrefabFixUtils.cs | 4 +- .../ProtoIDUsedByPatches.cs | 6 +- 13 files changed, 150 insertions(+), 11 deletions(-) create mode 100644 src/Compatibility/MoreMegaStructureCompatibilityPatch.cs rename src/{Patches => Utils}/ProtoIDUsedByPatches.cs (82%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 447d462..01b3ea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +- v2.4.6 + + 大幅提高了电解水配方的耗电量 + + 完成与巨构MOD的互相兼容,且加入了部分新配方 + + + Hugely improved the power consumption when electrolyze water + + Completed the compatibility with the MoreMegaStructure MOD and added some new recipes + + +
+ 点击展开日志 | Click to view all + - v2.4.5 + 添加了MOD冲突提示与加载提示 + 小幅提高了MOD兼容性 @@ -5,8 +16,6 @@ + Added conflict tips and loading tips + Slightly improved compatibility -
- 点击展开日志 | Click to view all - v2.4.4 + 修复文本错误 diff --git a/ProjectGenesis.csproj b/ProjectGenesis.csproj index efdd442..cbaf681 100644 --- a/ProjectGenesis.csproj +++ b/ProjectGenesis.csproj @@ -94,6 +94,7 @@ + @@ -108,7 +109,6 @@ - @@ -123,6 +123,7 @@ + diff --git a/dependencies/strings.json b/dependencies/strings.json index 05c13f1..58866c3 100644 --- a/dependencies/strings.json +++ b/dependencies/strings.json @@ -21,8 +21,8 @@ }, { "Name": "GenesisBookLoadMessage", - "ZHCN": "若您在主界面中看到了创世之书的图标,说明创世之书已成功加载。\n如果您在游玩创世之书MOD时遇到了任何问题,或者对MOD有宝贵的意见或建议,欢迎加入我们的QQ群:991895539(可在README.md文件中复制)", - "ENUS": "If you see the GenesisBook icon in the main menu, it means GenesisBook is successfully loaded.\nIf you have any problems or suggestions about the mod, please join our discord server: https://discord.gg/QwMEeaRZZR (You can copy the link in README.md)" + "ZHCN": "若您在主界面中看到了创世之书的图标,说明创世之书已成功加载。\n如果您在游玩创世之书MOD时遇到了任何问题,或者对MOD有宝贵的意见或建议,\n欢迎加入我们的QQ群:991895539(可在README.md文件中复制)", + "ENUS": "If the GenesisBook icon appears in the main menu, it means GenesisBook is successfully loaded.\nIf have any problems or suggestions about the mod, \nplease join our discord server: https://discord.gg/QwMEeaRZZR (You can copy the link in README.md)" }, { "Name": "Ok", diff --git a/src/Compatibility/IncompatibleCheckPatch.cs b/src/Compatibility/IncompatibleCheckPatch.cs index 9ed5b5d..879e84f 100644 --- a/src/Compatibility/IncompatibleCheckPatch.cs +++ b/src/Compatibility/IncompatibleCheckPatch.cs @@ -41,10 +41,14 @@ public void Awake() 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()); @@ -54,5 +58,7 @@ public static void OnMainMenuOpen() 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 new file mode 100644 index 0000000..63e7785 --- /dev/null +++ b/src/Compatibility/MoreMegaStructureCompatibilityPatch.cs @@ -0,0 +1,101 @@ +using BepInEx; +using HarmonyLib; +using ProjectGenesis.Utils; +using xiaoye97; + +// ReSharper disable InconsistentNaming +// ReSharper disable MemberCanBeInternal +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable ClassNeverInstantiated.Global +// ReSharper disable LoopCanBePartlyConvertedToQuery + +namespace ProjectGenesis.Compatibility +{ + [BepInPlugin(MODGUID, MODNAME, VERSION)] + [BepInDependency(MoreMegaStructureGUID)] + public class MoreMegaStructureCompatibilityPatch : BaseUnityPlugin + { + public const string MODGUID = "org.LoShin.GenesisBook.MoreMegaStructureCompatibilityPatch"; + public const string MODNAME = "GenesisBook.MoreMegaStructureCompatibilityPatch"; + public const string VERSION = "1.0.0"; + + 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(); + } + } + } +} diff --git a/src/Patches/MegaPumpPatches.cs b/src/Patches/MegaPumpPatches.cs index 692fcc2..ef60961 100644 --- a/src/Patches/MegaPumpPatches.cs +++ b/src/Patches/MegaPumpPatches.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Reflection.Emit; using HarmonyLib; +using ProjectGenesis.Utils; namespace ProjectGenesis.Patches { diff --git a/src/Patches/OceanDischargePatches.cs b/src/Patches/OceanDischargePatches.cs index 05b069d..8fc5c75 100644 --- a/src/Patches/OceanDischargePatches.cs +++ b/src/Patches/OceanDischargePatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using ProjectGenesis.Utils; // ReSharper disable InconsistentNaming diff --git a/src/Patches/PlanetGasPatches.cs b/src/Patches/PlanetGasPatches.cs index 40f6ba2..4eeff96 100644 --- a/src/Patches/PlanetGasPatches.cs +++ b/src/Patches/PlanetGasPatches.cs @@ -4,6 +4,7 @@ using System.Reflection.Emit; using HarmonyLib; using ProjectGenesis.Compatibility; +using ProjectGenesis.Utils; // ReSharper disable InconsistentNaming diff --git a/src/Patches/ProductionPatches.cs b/src/Patches/ProductionPatches.cs index 7aa0567..6a606ff 100644 --- a/src/Patches/ProductionPatches.cs +++ b/src/Patches/ProductionPatches.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Reflection.Emit; using HarmonyLib; +using ProjectGenesis.Utils; // ReSharper disable InconsistentNaming @@ -8,6 +9,19 @@ namespace ProjectGenesis.Patches { public static class ProductionPatches { + private static readonly long workEnergyPerTick_Original = 12000, workEnergyPerTick_MegaOriginal = 500000; + + [HarmonyPatch(typeof(AssemblerComponent), "SetPCState")] + [HarmonyPrefix] + public static void AssemblerComponent_SetPCState_Prefix(AssemblerComponent __instance, PowerConsumerComponent[] pcPool) + { + var workEnergyPerTick = __instance.speed < MegaAssemblerPatches.MegaAssemblerSpeed + ? workEnergyPerTick_Original + : workEnergyPerTick_MegaOriginal; + + pcPool[__instance.pcId].workEnergyPerTick = __instance.recipeId == ProtoIDUsedByPatches.R水电解 ? workEnergyPerTick * 10 : workEnergyPerTick; + } + [HarmonyPatch(typeof(AssemblerComponent), "InternalUpdate")] [HarmonyTranspiler] public static IEnumerable AssemblerComponent_InternalUpdate_Transpiler( diff --git a/src/Patches/UIPatches.cs b/src/Patches/UIPatches.cs index 69ac1b9..a67da4a 100644 --- a/src/Patches/UIPatches.cs +++ b/src/Patches/UIPatches.cs @@ -1,6 +1,7 @@ using System; using System.Text; using HarmonyLib; +using ProjectGenesis.Utils; using UnityEngine; using ERecipeType_1 = ERecipeType; diff --git a/src/ProjectGenesis.cs b/src/ProjectGenesis.cs index 3bd696b..c4d93ee 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.5"; + public const string VERSION = "2.4.6"; public string Version => VERSION; @@ -58,13 +58,13 @@ public void Awake() logger = Logger; logger.Log(LogLevel.Info, "GenesisBook Awake"); - if(IncompatibleCheckPatch.GalacticScaleInstalled) + if (IncompatibleCheckPatch.GalacticScaleInstalled) { logger.Log(LogLevel.Error, "Galactic Scale is installed, which is incompatible with GenesisBook. Load Cancelled."); return; } - if(IncompatibleCheckPatch.DSPBattleInstalled) + if (IncompatibleCheckPatch.DSPBattleInstalled) { logger.Log(LogLevel.Error, "They Come From Void is installed, which is incompatible with GenesisBook. Load Cancelled."); return; diff --git a/src/Utils/PrefabFixUtils.cs b/src/Utils/PrefabFixUtils.cs index 77efadd..bace2ad 100644 --- a/src/Utils/PrefabFixUtils.cs +++ b/src/Utils/PrefabFixUtils.cs @@ -13,8 +13,8 @@ internal static void ItemPostFix(ItemProtoSet itemProtos) LDB.items.OnAfterDeserialize(); itemProtos.Select(2317).prefabDesc.assemblerRecipeType = (ERecipeType_1)ERecipeType.高分子化工; - itemProtos.Select(2317).prefabDesc.idleEnergyPerTick = itemProtos.Select(物品.化工厂).prefabDesc.idleEnergyPerTick * 2; - itemProtos.Select(2317).prefabDesc.workEnergyPerTick = itemProtos.Select(物品.化工厂).prefabDesc.workEnergyPerTick * 2; + itemProtos.Select(2317).prefabDesc.idleEnergyPerTick = 800; + itemProtos.Select(2317).prefabDesc.workEnergyPerTick = 24000; itemProtos.Select(物品.二级制造台).prefabDesc.assemblerRecipeType = (ERecipeType_1)ERecipeType.电路蚀刻; itemProtos.Select(物品.三级制造台).prefabDesc.assemblerRecipeType = (ERecipeType_1)ERecipeType.高精度加工; diff --git a/src/Patches/ProtoIDUsedByPatches.cs b/src/Utils/ProtoIDUsedByPatches.cs similarity index 82% rename from src/Patches/ProtoIDUsedByPatches.cs rename to src/Utils/ProtoIDUsedByPatches.cs index e802843..f20ddb1 100644 --- a/src/Patches/ProtoIDUsedByPatches.cs +++ b/src/Utils/ProtoIDUsedByPatches.cs @@ -1,4 +1,4 @@ -namespace ProjectGenesis.Patches +namespace ProjectGenesis.Utils { internal static class ProtoIDUsedByPatches { @@ -17,7 +17,11 @@ internal static class ProtoIDUsedByPatches internal const int I大气采集器 = 6267, I轨道采集器 = 2105, + I人造恒星 = 2210, + I巨型精密组装厂 = 6260, + I巨型对撞机 = 6265, I氧 = 7019, + R水电解 = 702, R物质分解 = 429, R原油裂化 = 701, R焦油分馏 = 713,