From 2997ec8d8a6c450c620a1951a1f32e38d864b19a Mon Sep 17 00:00:00 2001 From: Alex Tearse-Doyle Date: Mon, 6 Nov 2023 11:00:35 -0800 Subject: [PATCH] Maybe fix error with mods having problems with costlist --- Source/PlaceBridges/BridgelikeTerrain.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/PlaceBridges/BridgelikeTerrain.cs b/Source/PlaceBridges/BridgelikeTerrain.cs index fd0d2a8..2039076 100644 --- a/Source/PlaceBridges/BridgelikeTerrain.cs +++ b/Source/PlaceBridges/BridgelikeTerrain.cs @@ -124,10 +124,10 @@ public static TerrainDef FindBridgeFor(TerrainDef tDef, TerrainAffordanceDef nee foreach (TerrainDef bridge in allBridgeTerrains) if (bridges.Contains(bridge)) { - if(backupBridge == null) backupBridge = bridge; //First possible option + if (backupBridge == null) backupBridge = bridge; //First possible option ThingDefCount cost = bridge.CostList?.FirstOrDefault(); - if (cost == null) //Free bridge? Okay. + if (cost.ThingDef == null) //Free bridge? Okay. Or some mod's error. Not my fault. return bridge; int resourceCount = map.resourceCounter.GetCount(cost.ThingDef); @@ -135,7 +135,7 @@ public static TerrainDef FindBridgeFor(TerrainDef tDef, TerrainAffordanceDef nee if (resourceCount > cost.Count * 10) return bridge;//Plently. Use this. - if( resourceCount > 0 ) + if (resourceCount > 0) bestBridge = bridge;//Not enough but at least this will work. } }