From 2dbf017a5e30dea7598f0cbf6ea044b2f9d18d2d Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Wed, 29 Oct 2025 15:27:53 +0800 Subject: [PATCH] update LogisticMiner to be compatible with latest game update --- LogisticMiner/LogisticMiner.cs | 42 ++++++++++++++--------------- LogisticMiner/LogisticMiner.csproj | 13 +++++++-- LogisticMiner/README.md | 4 +-- LogisticMiner/package/manifest.json | 2 +- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/LogisticMiner/LogisticMiner.cs b/LogisticMiner/LogisticMiner.cs index 28eba56..8afc7aa 100644 --- a/LogisticMiner/LogisticMiner.cs +++ b/LogisticMiner/LogisticMiner.cs @@ -15,11 +15,11 @@ public class LogisticMiner : BaseUnityPlugin private static long _oreEnergyConsume = 2000000; private static long _oilEnergyConsume = 3600000; - private static long _waterEnergyConsume = 20000000; - private static int _waterSpeed = 100; + private static long _waterEnergyConsume = 2000000; + private static int _waterSpeed = 10; private static int _miningScale; private static int _fuelIlsSlot = 3; - private static int _fuelPlsSlot = 2; + private static int _fuelPlsSlot = 3; private static float _frame; private static float _miningCostRateByTech; @@ -31,8 +31,8 @@ public class LogisticMiner : BaseUnityPlugin private static uint _miningCostBarrierOil; private static uint _seed = (uint)Random.Range(int.MinValue, int.MaxValue); - private static readonly Dictionary PlanetVeinCacheData = new(); - private static readonly Dictionary Fuels = new(); + private static readonly Dictionary PlanetVeinCacheData = []; + private static readonly Dictionary Fuels = []; private bool _cfgEnabled = true; @@ -52,11 +52,11 @@ public class LogisticMiner : BaseUnityPlugin .Value; _fuelIlsSlot = Config.Bind("General", "ILSFuelSlot", _fuelIlsSlot + 1, new ConfigDescription("Fuel slot for ILS, set to 0 to disable", - new AcceptableValueRange(0, 5), Array.Empty())) + new AcceptableValueRange(0, 5), [])) .Value - 1; _fuelPlsSlot = Config.Bind("General", "PLSFuelSlot", _fuelPlsSlot + 1, new ConfigDescription("Fuel slot for PLS, set to 0 to disable", - new AcceptableValueRange(0, 4), Array.Empty())) + new AcceptableValueRange(0, 4), [])) .Value - 1; if (!_cfgEnabled) return; @@ -98,8 +98,8 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))] - [HarmonyPatch(typeof(DSPGame), "StartGame", typeof(string))] + [HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartGame), typeof(GameDesc))] + [HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartGame), typeof(string))] private static void OnGameStart() { Logger.LogInfo("Game Start"); @@ -119,7 +119,7 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(GameMain), "Start")] + [HarmonyPatch(typeof(GameMain), nameof(GameMain.Start))] private static void OnGameLoaded() { _frame = 0f; @@ -130,7 +130,7 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(GameHistoryData), "UnlockTechFunction")] + [HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.UnlockTechFunction))] private static void OnUnlockTech(int func) { switch (func) @@ -145,7 +145,7 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(GameData), "GameTick")] + [HarmonyPatch(typeof(GameLogic), nameof(GameLogic.OnFactoryFrameBegin))] private static void FrameTick() { var main = GameMain.instance; @@ -165,7 +165,7 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(GameHistoryData), "UnlockRecipe")] + [HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.UnlockRecipe))] private static void OnUnlockRecipe(int recipeId) { if (recipeId == 119) @@ -175,9 +175,9 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(PlanetFactory), "Init")] - [HarmonyPatch(typeof(PlanetFactory), "RecalculateVeinGroup")] - [HarmonyPatch(typeof(PlanetFactory), "RecalculateAllVeinGroups")] + [HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.Init))] + [HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.RecalculateVeinGroup))] + [HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.RecalculateAllVeinGroups))] private static void NeedRecalcVeins(PlanetFactory __instance) { RecalcVeins(__instance); @@ -204,7 +204,7 @@ public class LogisticMiner : BaseUnityPlugin } [HarmonyPostfix] - [HarmonyPatch(typeof(FactorySystem), "CheckBeforeGameTick")] + [HarmonyPatch(typeof(GameLogic), nameof(GameLogic.FactoryBeforeGameTick))] private static void FactorySystemLogisticMiner(FactorySystem __instance) { if (_miningSpeedScaleLong <= 0) @@ -231,7 +231,7 @@ public class LogisticMiner : BaseUnityPlugin var factoryProductionStat = GameMain.statistics.production.factoryStatPool[__instance.factory.index]; var productRegister = factoryProductionStat?.productRegister; - PerformanceMonitor.BeginSample(ECpuWorkEntry.Miner); + DeepProfiler.BeginSample(DPEntry.Miner); do { for (var j = 1; j < planetTransport.stationCursor; j++) @@ -334,7 +334,7 @@ public class LogisticMiner : BaseUnityPlugin vcd.FrameNext += _miningFrames; } while (vcd.FrameNext <= _frame); - PerformanceMonitor.EndSample(ECpuWorkEntry.Miner); + DeepProfiler.EndSample(DPEntry.Miner); } } @@ -353,9 +353,9 @@ public class LogisticMiner : BaseUnityPlugin public void GenVeins(PlanetFactory factory) { - _veins = new Dictionary>(); + _veins = []; var veinPool = factory.veinPool; - var vg = new Dictionary>(); + Dictionary> vg = []; for (var i = 0; i < veinPool.Length; i++) { if (veinPool[i].amount <= 0 || veinPool[i].type == EVeinType.None) continue; diff --git a/LogisticMiner/LogisticMiner.csproj b/LogisticMiner/LogisticMiner.csproj index 6a12f0e..2397e84 100644 --- a/LogisticMiner/LogisticMiner.csproj +++ b/LogisticMiner/LogisticMiner.csproj @@ -6,7 +6,7 @@ LogisticMiner org.soardev.logisticminer DSP MOD - LogisticMiner - 0.1.0 + 0.2.0 true latest https://nuget.bepinex.dev/v3/index.json @@ -15,10 +15,19 @@ - + + + + ..\AssemblyFromGame\Assembly-CSharp.dll + + + ..\AssemblyFromGame\UnityEngine.UI.dll + + + diff --git a/LogisticMiner/README.md b/LogisticMiner/README.md index af52134..8e60f1c 100644 --- a/LogisticMiner/README.md +++ b/LogisticMiner/README.md @@ -27,7 +27,7 @@ reaches Advanced Mining Machine, otherwise 100. * 100/s for water by default. * Energy costs: 1MW/vein-group & 10MW/water-slot & 1.8MW/oil-seep(configurable) - * Fuels burning slot. Default: 4th for ILS, 3rd for PLS. Set to 0 to disable it. + * Fuels burning slot. Default: 4th for ILS, 4th for PLS. Set to 0 to disable it. ## 使用说明 @@ -47,4 +47,4 @@ 倍率可以设置为0(默认),此时倍率会随科技解锁而变化,默认是100%,解锁高级采矿机后变为300%。 * 水的采集速度默认为100/s。 * 能耗:每矿物组 1MW,单格水 10MW,每油井 1.8MW。 - * 燃料格位置。默认:星际物流塔第4格,行星内物流塔第3格。设为0则关闭燃料补充能量功能。 + * 燃料格位置。默认:星际物流塔第4格,行星内物流塔第4格。设为0则关闭燃料补充能量功能。 diff --git a/LogisticMiner/package/manifest.json b/LogisticMiner/package/manifest.json index b8e713f..b5e8fdf 100644 --- a/LogisticMiner/package/manifest.json +++ b/LogisticMiner/package/manifest.json @@ -1,6 +1,6 @@ { "name": "LogisticMiner", - "version_number": "0.1.0", + "version_number": "0.2.0", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LogisticMiner", "description": "Logistic Storages can mine all ores/water on current planet / 物流塔可以采集当前星球的全部矿产(以及水)", "dependencies": [