Skip to content

Commit

Permalink
Maybe fix error with mods having problems with costlist
Browse files Browse the repository at this point in the history
  • Loading branch information
alextd committed Nov 6, 2023
1 parent 4ef09a0 commit 2997ec8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/PlaceBridges/BridgelikeTerrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ 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);

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.
}
}
Expand Down

0 comments on commit 2997ec8

Please sign in to comment.