mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 02:13:29 +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
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using UXAssist.Common;
|
|||||||
|
|
||||||
namespace CheatEnabler.Patches;
|
namespace CheatEnabler.Patches;
|
||||||
|
|
||||||
public class FactoryPatch: PatchImpl<FactoryPatch>
|
public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||||
{
|
{
|
||||||
public static ConfigEntry<bool> ImmediateEnabled;
|
public static ConfigEntry<bool> ImmediateEnabled;
|
||||||
public static ConfigEntry<bool> ArchitectModeEnabled;
|
public static ConfigEntry<bool> ArchitectModeEnabled;
|
||||||
@@ -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,10 +118,14 @@ 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);
|
||||||
_beltIds ??= [..LDB.items.dataArray.Where(i => i.prefabDesc.isBelt).Select(i => i.ID)];
|
_beltIds ??= [.. LDB.items.dataArray.Where(i => i.prefabDesc.isBelt).Select(i => i.ID)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnInputUpdate()
|
public static void OnInputUpdate()
|
||||||
@@ -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)
|
||||||
@@ -297,7 +357,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ImmediateBuild: PatchImpl<ImmediateBuild>
|
private class ImmediateBuild : PatchImpl<ImmediateBuild>
|
||||||
{
|
{
|
||||||
protected override void OnEnable()
|
protected override void OnEnable()
|
||||||
{
|
{
|
||||||
@@ -355,7 +415,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ArchitectMode: PatchImpl<ArchitectMode>
|
private class ArchitectMode : PatchImpl<ArchitectMode>
|
||||||
{
|
{
|
||||||
private static bool[] _canBuildItems;
|
private static bool[] _canBuildItems;
|
||||||
|
|
||||||
@@ -409,7 +469,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NoConditionBuild: PatchImpl<NoConditionBuild>
|
private class NoConditionBuild : PatchImpl<NoConditionBuild>
|
||||||
{
|
{
|
||||||
protected override void OnEnable()
|
protected override void OnEnable()
|
||||||
{
|
{
|
||||||
@@ -497,7 +557,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BeltSignalGenerator: PatchImpl<BeltSignalGenerator>
|
public class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||||
{
|
{
|
||||||
private static Dictionary<int, BeltSignal>[] _signalBelts;
|
private static Dictionary<int, BeltSignal>[] _signalBelts;
|
||||||
private static Dictionary<long, int> _portalFrom;
|
private static Dictionary<long, int> _portalFrom;
|
||||||
@@ -1165,7 +1225,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
/* END: Item sources calculation */
|
/* END: Item sources calculation */
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RemovePowerSpaceLimit: PatchImpl<RemovePowerSpaceLimit>
|
private class RemovePowerSpaceLimit : PatchImpl<RemovePowerSpaceLimit>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||||
@@ -1195,7 +1255,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BoostWindPower: PatchImpl<BoostWindPower>
|
private class BoostWindPower : PatchImpl<BoostWindPower>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_Wind))]
|
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_Wind))]
|
||||||
@@ -1220,7 +1280,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BoostSolarPower: PatchImpl<BoostSolarPower>
|
private class BoostSolarPower : PatchImpl<BoostSolarPower>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_PV))]
|
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_PV))]
|
||||||
@@ -1244,7 +1304,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BoostFuelPower: PatchImpl<BoostFuelPower>
|
private class BoostFuelPower : PatchImpl<BoostFuelPower>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_Fuel))]
|
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_Fuel))]
|
||||||
@@ -1285,7 +1345,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BoostGeothermalPower: PatchImpl<BoostGeothermalPower>
|
private class BoostGeothermalPower : PatchImpl<BoostGeothermalPower>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_GTH))]
|
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.EnergyCap_GTH))]
|
||||||
@@ -1368,7 +1428,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GreaterPowerUsageInLogistics: PatchImpl<GreaterPowerUsageInLogistics>
|
private class GreaterPowerUsageInLogistics : PatchImpl<GreaterPowerUsageInLogistics>
|
||||||
{
|
{
|
||||||
protected override void OnEnable()
|
protected override void OnEnable()
|
||||||
{
|
{
|
||||||
@@ -1518,7 +1578,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ControlPanelRemoteLogistics: PatchImpl<ControlPanelRemoteLogistics>
|
private class ControlPanelRemoteLogistics : PatchImpl<ControlPanelRemoteLogistics>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(UIControlPanelDispenserInspector), nameof(UIControlPanelDispenserInspector.OnItemIconMouseDown))]
|
[HarmonyPatch(typeof(UIControlPanelDispenserInspector), nameof(UIControlPanelDispenserInspector.OnItemIconMouseDown))]
|
||||||
|
|||||||
Reference in New Issue
Block a user