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

CheatEnabler: minor changes

This commit is contained in:
2025-04-26 01:58:50 +08:00
parent 6877b8e9ac
commit d61b40216c

View File

@@ -176,6 +176,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
factory.BeginFlattenTerrain(); factory.BeginFlattenTerrain();
factory.cargoTraffic._batch_buffer_no_refresh = true; factory.cargoTraffic._batch_buffer_no_refresh = true;
PlanetFactory.batchBuild = true; PlanetFactory.batchBuild = true;
CargoTrafficPatch.DisableRefreshBatchesBuffers = true;
for (var i = factory.prebuildCursor - 1; i > 0; i--) for (var i = factory.prebuildCursor - 1; i > 0; i--)
{ {
ref var pb = ref prebuilds[i]; ref var pb = ref prebuilds[i];
@@ -190,11 +191,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
anyBuilt = true; anyBuilt = true;
} }
PlanetFactory.batchBuild = false; PlanetFactory.batchBuild = false;
if (anyBelt)
{
factory.cargoTraffic.RefreshBeltBatchesBuffers();
factory.cargoTraffic.RefreshPathBatchesBuffers();
}
factory.cargoTraffic._batch_buffer_no_refresh = false; factory.cargoTraffic._batch_buffer_no_refresh = false;
factory.EndFlattenTerrain(); factory.EndFlattenTerrain();
CargoTrafficPatch.IsBatchBuilding = false; CargoTrafficPatch.IsBatchBuilding = false;
@@ -216,6 +212,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_alterBeltRendererIds.Clear(); _alterBeltRendererIds.Clear();
_alterPathRendererIds.Clear(); _alterPathRendererIds.Clear();
_refreshPathUVIds.Clear(); _refreshPathUVIds.Clear();
CargoTrafficPatch.DisableRefreshBatchesBuffers = false;
if (anyBelt)
{
factory.cargoTraffic.RefreshBeltBatchesBuffers();
factory.cargoTraffic.RefreshPathBatchesBuffers();
}
if (anyBuilt) if (anyBuilt)
{ {
factory.planet.physics?.raycastLogic?.NotifyBatchObjectRemove(); factory.planet.physics?.raycastLogic?.NotifyBatchObjectRemove();
@@ -237,7 +239,9 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
private class CargoTrafficPatch : PatchImpl<CargoTrafficPatch> private class CargoTrafficPatch : PatchImpl<CargoTrafficPatch>
{ {
public static bool IsBatchBuilding; public static bool IsBatchBuilding;
public static bool DisableRefreshBatchesBuffers;
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterBeltRenderer))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterBeltRenderer))]
private static bool CargoTraffic_AlterBeltRenderer_Prefix(int beltId) private static bool CargoTraffic_AlterBeltRenderer_Prefix(int beltId)
{ {
@@ -247,6 +251,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterPathRenderer))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterPathRenderer))]
private static bool CargoTraffic_AlterPathRenderer_Prefix(int pathId) private static bool CargoTraffic_AlterPathRenderer_Prefix(int pathId)
{ {
@@ -256,6 +261,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathUV))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathUV))]
private static bool CargoTraffic_RefreshPathUV_Prefix(int pathId) private static bool CargoTraffic_RefreshPathUV_Prefix(int pathId)
{ {
@@ -263,6 +269,15 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_refreshPathUVIds.Add(pathId); _refreshPathUVIds.Add(pathId);
return false; return false;
} }
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshBeltBatchesBuffers))]
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathBatchesBuffers))]
private static bool CargoTraffic_RefreshBeltBatchesBuffers_Prefix()
{
return !DisableRefreshBatchesBuffers;
}
} }
[HarmonyPostfix] [HarmonyPostfix]