mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 15:33:31 +08:00
CheatEnabler: optimization
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
* 2.3.30
|
* 2.3.30
|
||||||
+ Fix a warning issue while `No condition build` or `No collision` is enabled.
|
+ Fix a warning issue while `No condition build` or `No collision` is enabled.
|
||||||
+ Optimized `Finish build immediately` for better performance.
|
+ Increase performance for `Finish build immediately` greatly on pasting large blueprints.
|
||||||
* 2.3.29
|
* 2.3.29
|
||||||
+ Fix compatibility with game update 0.10.32.25779
|
+ Fix compatibility with game update 0.10.32.25779
|
||||||
* 2.3.28
|
* 2.3.28
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
* 2.3.30
|
* 2.3.30
|
||||||
+ 修复了启用`无条件建造`或`无碰撞`时的警告问题
|
+ 修复了启用`无条件建造`或`无碰撞`时的警告问题
|
||||||
+ 优化了`立即完成建造`的性能表现
|
+ 粘贴大规模蓝图时大幅提升`立即完成建造`的性能表现
|
||||||
* 2.3.29
|
* 2.3.29
|
||||||
+ 修复了与游戏更新0.10.32.25779的兼容性
|
+ 修复了与游戏更新0.10.32.25779的兼容性
|
||||||
* 2.3.28
|
* 2.3.28
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
GreaterPowerUsageInLogistics.Enable(GreaterPowerUsageInLogisticsEnabled.Value);
|
GreaterPowerUsageInLogistics.Enable(GreaterPowerUsageInLogisticsEnabled.Value);
|
||||||
ControlPanelRemoteLogistics.Enable(ControlPanelRemoteLogisticsEnabled.Value);
|
ControlPanelRemoteLogistics.Enable(ControlPanelRemoteLogisticsEnabled.Value);
|
||||||
Enable(true);
|
Enable(true);
|
||||||
|
CargoTrafficPatch.Enable(true);
|
||||||
GameLogic.OnGameBegin += GameMain_Begin_Postfix_For_ImmBuild;
|
GameLogic.OnGameBegin += GameMain_Begin_Postfix_For_ImmBuild;
|
||||||
GameLogic.OnDataLoaded += OnDataLoaded;
|
GameLogic.OnDataLoaded += OnDataLoaded;
|
||||||
}
|
}
|
||||||
@@ -100,6 +101,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
{
|
{
|
||||||
GameLogic.OnDataLoaded -= OnDataLoaded;
|
GameLogic.OnDataLoaded -= OnDataLoaded;
|
||||||
GameLogic.OnGameBegin -= GameMain_Begin_Postfix_For_ImmBuild;
|
GameLogic.OnGameBegin -= GameMain_Begin_Postfix_For_ImmBuild;
|
||||||
|
CargoTrafficPatch.Enable(false);
|
||||||
Enable(false);
|
Enable(false);
|
||||||
ImmediateBuild.Enable(false);
|
ImmediateBuild.Enable(false);
|
||||||
ArchitectMode.Enable(false);
|
ArchitectMode.Enable(false);
|
||||||
@@ -116,6 +118,10 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static HashSet<int> _beltIds = [];
|
private static HashSet<int> _beltIds = [];
|
||||||
|
private static HashSet<int> _alterBeltRendererIds;
|
||||||
|
private static HashSet<int> _alterPathRendererIds;
|
||||||
|
private static HashSet<int> _refreshPathUVIds;
|
||||||
|
|
||||||
private static void OnDataLoaded()
|
private static void OnDataLoaded()
|
||||||
{
|
{
|
||||||
WindTurbinesPowerGlobalCoverage.Enable(WindTurbinesPowerGlobalCoverageEnabled.Value);
|
WindTurbinesPowerGlobalCoverage.Enable(WindTurbinesPowerGlobalCoverageEnabled.Value);
|
||||||
@@ -163,6 +169,10 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
{
|
{
|
||||||
var anyBelt = false;
|
var anyBelt = false;
|
||||||
var anyBuilt = false;
|
var anyBuilt = false;
|
||||||
|
_alterBeltRendererIds ??= [];
|
||||||
|
_alterPathRendererIds ??= [];
|
||||||
|
_refreshPathUVIds ??= [];
|
||||||
|
CargoTrafficPatch.IsBatchBuilding = true;
|
||||||
factory.BeginFlattenTerrain();
|
factory.BeginFlattenTerrain();
|
||||||
factory.cargoTraffic._batch_buffer_no_refresh = true;
|
factory.cargoTraffic._batch_buffer_no_refresh = true;
|
||||||
PlanetFactory.batchBuild = true;
|
PlanetFactory.batchBuild = true;
|
||||||
@@ -187,6 +197,25 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
factory.cargoTraffic._batch_buffer_no_refresh = false;
|
factory.cargoTraffic._batch_buffer_no_refresh = false;
|
||||||
factory.EndFlattenTerrain();
|
factory.EndFlattenTerrain();
|
||||||
|
CargoTrafficPatch.IsBatchBuilding = false;
|
||||||
|
var cargoTraffic = factory.cargoTraffic;
|
||||||
|
var entityPool = factory.entityPool;
|
||||||
|
var colChunks = factory.planet.physics?.colChunks;
|
||||||
|
foreach (var beltId in _alterBeltRendererIds)
|
||||||
|
{
|
||||||
|
cargoTraffic.AlterBeltRenderer(beltId, entityPool, colChunks, false);
|
||||||
|
}
|
||||||
|
foreach (var pathId in _alterPathRendererIds)
|
||||||
|
{
|
||||||
|
cargoTraffic.AlterPathRenderer(pathId, false);
|
||||||
|
}
|
||||||
|
foreach (var pathId in _refreshPathUVIds)
|
||||||
|
{
|
||||||
|
cargoTraffic.RefreshPathUV(pathId);
|
||||||
|
}
|
||||||
|
_alterBeltRendererIds.Clear();
|
||||||
|
_alterPathRendererIds.Clear();
|
||||||
|
_refreshPathUVIds.Clear();
|
||||||
if (anyBuilt)
|
if (anyBuilt)
|
||||||
{
|
{
|
||||||
factory.planet.physics?.raycastLogic?.NotifyBatchObjectRemove();
|
factory.planet.physics?.raycastLogic?.NotifyBatchObjectRemove();
|
||||||
@@ -205,6 +234,37 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CargoTrafficPatch : PatchImpl<CargoTrafficPatch>
|
||||||
|
{
|
||||||
|
public static bool IsBatchBuilding;
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterBeltRenderer))]
|
||||||
|
private static bool CargoTraffic_AlterBeltRenderer_Prefix(int beltId)
|
||||||
|
{
|
||||||
|
if (!IsBatchBuilding) return true;
|
||||||
|
_alterBeltRendererIds.Add(beltId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterPathRenderer))]
|
||||||
|
private static bool CargoTraffic_AlterPathRenderer_Prefix(int pathId)
|
||||||
|
{
|
||||||
|
if (!IsBatchBuilding) return true;
|
||||||
|
_alterPathRendererIds.Add(pathId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathUV))]
|
||||||
|
private static bool CargoTraffic_RefreshPathUV_Prefix(int pathId)
|
||||||
|
{
|
||||||
|
if (!IsBatchBuilding) return true;
|
||||||
|
_refreshPathUVIds.Add(pathId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))]
|
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))]
|
||||||
private static void PlanetData_NotifyFactoryLoaded_Postfix(PlanetData __instance)
|
private static void PlanetData_NotifyFactoryLoaded_Postfix(PlanetData __instance)
|
||||||
|
|||||||
Reference in New Issue
Block a user