From 34c37eabed5d6f453a4d436b273e7e2516e1c763 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Fri, 15 Sep 2023 00:40:57 +0800 Subject: [PATCH] bug fixes --- CheatEnabler/PlanetFunctions.cs | 35 ++++++++++++++++++++++----------- LogisticMiner/LogisticMiner.cs | 5 ----- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CheatEnabler/PlanetFunctions.cs b/CheatEnabler/PlanetFunctions.cs index 16cec77..5bd6d9a 100644 --- a/CheatEnabler/PlanetFunctions.cs +++ b/CheatEnabler/PlanetFunctions.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System.Threading; +using UnityEngine; namespace CheatEnabler; public static class PlanetFunctions { @@ -71,7 +72,7 @@ public static class PlanetFunctions { if (factory == null) return; //planet.data = new PlanetRawData(planet.precision); //planet.data.CalcVerts(); - for (var id = 1; id < factory.entityCursor; id++) + for (var id = factory.entityCursor - 1; id > 0; id--) { var ed = factory.entityPool[id]; if (ed.id != id) continue; @@ -100,9 +101,10 @@ public static class PlanetFunctions { } } - if (factory.transport != null && factory.transport.stationPool != null) + var stationPool = factory.transport?.stationPool; + if (stationPool != null) { - foreach (var sc in factory.transport.stationPool) + foreach (var sc in stationPool) { if (sc == null || sc.id <= 0) continue; sc.storage = new StationStore[sc.storage.Length]; @@ -112,16 +114,18 @@ public static class PlanetFunctions { } } - if (GameMain.gameScenario != null) + var gameScenario = GameMain.gameScenario; + if (gameScenario != null) { - if (factory.powerSystem != null && factory.powerSystem.genPool != null) + var genPool = factory.powerSystem?.genPool; + if (genPool != null) { - foreach (var pgc in factory.powerSystem.genPool) + foreach (var pgc in genPool) { if (pgc.id <= 0) continue; int protoId = factory.entityPool[pgc.entityId].protoId; - GameMain.gameScenario.achievementLogic.NotifyBeforeDismantleEntity(planet.id, protoId, pgc.entityId); - GameMain.gameScenario.NotifyOnDismantleEntity(planet.id, protoId, pgc.entityId); + gameScenario.achievementLogic.NotifyBeforeDismantleEntity(planet.id, protoId, pgc.entityId); + gameScenario.NotifyOnDismantleEntity(planet.id, protoId, pgc.entityId); } } } @@ -133,10 +137,12 @@ public static class PlanetFunctions { planet.UnloadFactory(); var index = factory.index; - for (var i = 1; i < GameMain.data.warningSystem.warningCursor; i++) + var warningSystem = GameMain.data.warningSystem; + var warningPool = warningSystem.warningPool; + for (var i = warningSystem.warningCursor - 1; i > 0; i--) { - if (GameMain.data.warningSystem.warningPool[i].factoryId == index) - GameMain.data.warningSystem.RemoveWarningData(GameMain.data.warningSystem.warningPool[i].id); + if (warningPool[i].id == i && warningPool[i].factoryId == index) + warningSystem.RemoveWarningData(warningPool[i].id); } factory.entityCursor = 1; @@ -156,5 +162,10 @@ public static class PlanetFunctions { factory.digitalSystem = new DigitalSystem(planet); //GameMain.data.statistics.production.CreateFactoryStat(index); planet.LoadFactory(); + while (!planet.factoryLoaded) + { + PlanetModelingManager.Update(); + Thread.Sleep(0); + } } } \ No newline at end of file diff --git a/LogisticMiner/LogisticMiner.cs b/LogisticMiner/LogisticMiner.cs index 96717dd..e0b035e 100644 --- a/LogisticMiner/LogisticMiner.cs +++ b/LogisticMiner/LogisticMiner.cs @@ -60,11 +60,6 @@ public class LogisticMiner : BaseUnityPlugin .Value - 1; if (!_cfgEnabled) return; - if (_miningScale < 100) - { - _miningScale = 100; - } - Harmony.CreateAndPatchAll(typeof(LogisticMiner)); }