1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-03-28 23:07:19 +08:00

fix possible crash

This commit is contained in:
2026-03-22 14:18:15 +08:00
parent a5b2bdedd4
commit 2e6950afb3
2 changed files with 5 additions and 4 deletions

Binary file not shown.

View File

@@ -441,12 +441,13 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.GameTick))] [HarmonyPatch(typeof(GameLogic), nameof(GameLogic.FactoryConstructionSystemGameTick))]
private static void ConstructionSystem_GameTick_Prefix(ConstructionSystem __instance, long time) private static void GameLogic_FactoryConstructionSystemGameTick_Prefix(GameLogic __instance)
{ {
var time = __instance.timei;
if (time % 6 != 0) return; if (time % 6 != 0) return;
var factory = __instance.factory; var factory = GameMain.localPlanet?.factory;
if (factory.prebuildCount <= 0) return; if (factory == null || factory.prebuildCount <= 0) return;
var player = GameMain.mainPlayer; var player = GameMain.mainPlayer;
if (player == null) return; if (player == null) return;
var total = factory.prebuildCursor - 1; var total = factory.prebuildCursor - 1;