1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 06:53:31 +08:00

crash fix

This commit is contained in:
2025-10-29 21:51:52 +08:00
parent cf3117e0da
commit 61811f9a8c
2 changed files with 3 additions and 3 deletions

View File

@@ -124,7 +124,7 @@ public class Miner : PatchImpl<Miner>
[HarmonyPrefix]
[HarmonyPatch(typeof(GameLogic), nameof(GameLogic.OnFactoryFrameBegin))]
private static void GameData_GameTick_Prefix()
private static void GameLogic_OnFactoryFrameBegin_Prefix()
{
var main = GameMain.instance;
if (main.isMenuDemo) return;
@@ -139,7 +139,7 @@ public class Miner : PatchImpl<Miner>
DeepProfiler.BeginSample(DPEntry.Miner);
var data = GameMain.data;
if (data.factoryCount > _mineIndex.Length)
if (_mineIndex == null || data.factoryCount > _mineIndex.Length)
Array.Resize(ref _mineIndex, data.factoryCount);
var factoryStatPool = GameMain.statistics.production.factoryStatPool;
for (var factoryIndex = data.factoryCount - 1; factoryIndex >= 0; factoryIndex--)

View File

@@ -6,7 +6,7 @@
## Usage
* Miner(and fuel burning) functions
+Inspired by [PlanetMiner](https://dsp.thunderstore.io/package/blacksnipebiu/PlanetMiner)([github](https://github.com/blacksnipebiu/PlanetMiner))
+ Inspired by [PlanetMiner](https://dsp.thunderstore.io/package/blacksnipebiu/PlanetMiner)([github](https://github.com/blacksnipebiu/PlanetMiner))
But it is heavily optimized to resolve performance, accuracy and other issues in PlanetMiner.
+ (Optimization to PlanetMiner) Only recalculate count of veins when vein chunks are changed (added/removed by foundations/Sandbox-Mode, or exhausted), so this removes Dictionary allocation on each planet for every frame.
+ (Optimization to PlanetMiner) More accurate frame counting by use float number.