mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(compat): restore wind coverage startup and entity hiding
Defer wind coverage changes until prefab data is ready and preserve retryable activation state. Replace fixed raycast local slots with semantic entity-field matching and guard fallback paths.
This commit is contained in:
1 parent
8a10fc909a
commit
60d54ac918
5 files changed
+44
-33
No files matched your search
@@ -3,6 +3,8 @@
|
||||
|
||||
## Changlog
|
||||
|
||||
* Unreleased
|
||||
* `PowerGlobalCoverage`: Fix a startup crash before wind-turbine prefabs finish loading. Retry after preload without corrupting activation state or the original power ranges, and tolerate unallocated factory data.
|
||||
* 2.4.5
|
||||
* Support Dyson Sphere Program 0.10.35.29057.
|
||||
* Update `Terraform anyway` for the separate foundation and Restore Terrain workflows. Preserve soil gains and prevent negative soil balances when resources are insufficient.
|
||||
|
||||
@@ -181,25 +181,27 @@ internal static class WindTurbinesPowerGlobalCoverage
|
||||
if (enable)
|
||||
{
|
||||
if (_patched) return;
|
||||
var prefabDesc = LDB.items?.Select(WindTurbineId)?.prefabDesc;
|
||||
if (prefabDesc == null) return;
|
||||
_oldCoverRadius = prefabDesc.powerCoverRadius;
|
||||
_oldConnectDistance = prefabDesc.powerConnectDistance;
|
||||
prefabDesc.powerCoverRadius = WindTurbineNewCoverageDistance;
|
||||
prefabDesc.powerConnectDistance = WindTurbineNewCoverageDistance;
|
||||
_prefabdesc = prefabDesc;
|
||||
_patched = true;
|
||||
var itemProto = LDB.items.Select(WindTurbineId);
|
||||
_oldCoverRadius = itemProto.prefabDesc.powerCoverRadius;
|
||||
_oldConnectDistance = itemProto.prefabDesc.powerConnectDistance;
|
||||
itemProto.prefabDesc.powerCoverRadius = WindTurbineNewCoverageDistance;
|
||||
itemProto.prefabDesc.powerConnectDistance = WindTurbineNewCoverageDistance;
|
||||
_prefabdesc = itemProto.prefabDesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_patched) return;
|
||||
_patched = false;
|
||||
_prefabdesc.powerCoverRadius = _oldCoverRadius;
|
||||
_prefabdesc.powerConnectDistance = _oldConnectDistance;
|
||||
_patched = false;
|
||||
}
|
||||
|
||||
// Iterate all factories and update wind turbines power nodes
|
||||
if (GameMain.data == null) return;
|
||||
foreach (var factory in GameMain.data.factories)
|
||||
var factories = GameMain.data?.factories;
|
||||
if (factories == null) return;
|
||||
foreach (var factory in factories)
|
||||
{
|
||||
var powerSystem = factory?.powerSystem;
|
||||
if (powerSystem == null) continue;
|
||||
|
||||
Reference in new issue
Block a user