From 0c2c1b1b83ff4256945135601c19f7f51e35d08b Mon Sep 17 00:00:00 2001 From: Alex Tearse-Doyle Date: Fri, 18 Feb 2022 01:14:43 -0800 Subject: [PATCH] Fix for running with no saved settings --- Source/Settings.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/Settings.cs b/Source/Settings.cs index 33dc8f0..a827955 100644 --- a/Source/Settings.cs +++ b/Source/Settings.cs @@ -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 loadedBridgeOrder = defNames.Select(n => DefDatabase.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 loadedBridgeOrder = defNames.Select(n => DefDatabase.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); + } + }); } } }