Skip to content

Commit

Permalink
Fix for running with no saved settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alextd committed Feb 18, 2022
1 parent a9bba33 commit 0c2c1b1
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,23 @@ public override void ExposeData()
Scribe_Collections.Look(ref defNames, "bridgePrefNames");

//Gotta wait for DefOfs to load to use DefDatabase
if(defNames != null)
LongEventHandler.ExecuteWhenFinished(() =>
{
List<TerrainDef> loadedBridgeOrder = defNames.Select(n => DefDatabase<TerrainDef>.GetNamed(n, false)).ToList();
loadedBridgeOrder.RemoveAll(d => d == null);//Any removed mods, forget about em.
//To merge with maybe new modded bridges:
//Take all from known loadedBridgeOrder and push to front:
//Any new modded terrains will be in back - which is normal for modded terrain anyway.
//TODO: order default list by cost or something. Meh.
loadedBridgeOrder.Reverse();
foreach (TerrainDef terDef in loadedBridgeOrder)
{
BridgelikeTerrain.allBridgeTerrains.Remove(terDef);
BridgelikeTerrain.allBridgeTerrains.Insert(0, terDef);
}
});
List<TerrainDef> loadedBridgeOrder = defNames.Select(n => DefDatabase<TerrainDef>.GetNamed(n, false)).ToList();
loadedBridgeOrder.RemoveAll(d => d == null);//Any removed mods, forget about em.
//To merge with maybe new modded bridges:
//Take all from known loadedBridgeOrder and push to front:
//Any new modded terrains will be in back - which is normal for modded terrain anyway.
//TODO: order default list by cost or something. Meh.
loadedBridgeOrder.Reverse();
foreach (TerrainDef terDef in loadedBridgeOrder)
{
BridgelikeTerrain.allBridgeTerrains.Remove(terDef);
BridgelikeTerrain.allBridgeTerrains.Insert(0, terDef);
}
});
}
}
}
Expand Down

0 comments on commit 0c2c1b1

Please sign in to comment.