From c6d102c111b3bffbdccba0a295a43bf2148b288e Mon Sep 17 00:00:00 2001 From: Shohei Wada Date: Sun, 26 Dec 2021 03:36:23 +0900 Subject: [PATCH] * Removed the miner's extracting depot refering code because the field is not existing anymore and was causing a crash * Improving the performance by reducing the number of calls to FindChild() method * Add the vehicles and beams as the dismantle target object --- .../Cheats/MassDismantleCheat.cs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/SatisfactorySaveEditor/Cheats/MassDismantleCheat.cs b/SatisfactorySaveEditor/Cheats/MassDismantleCheat.cs index f45867c..c77dfa2 100644 --- a/SatisfactorySaveEditor/Cheats/MassDismantleCheat.cs +++ b/SatisfactorySaveEditor/Cheats/MassDismantleCheat.cs @@ -163,17 +163,16 @@ private int MassDismantle(List objects, ArrayProperty inventory inventory.Elements.AddRange(((ArrayProperty)rootItem.FindChild(item.FindField("mInputInventory").Str2, false).FindField("mInventoryStacks").Model).Elements); if (item.FindField("mOutputInventory") != null) inventory.Elements.AddRange(((ArrayProperty)rootItem.FindChild(item.FindField("mOutputInventory").Str2, false).FindField("mInventoryStacks").Model).Elements); - // Unlink miners & geysers - if (item.Model.TypePath.StartsWith("/Game/FactoryGame/Buildable/Factory/Miner") || item.Model.TypePath.StartsWith("/Game/FactoryGame/Buildable/Factory/GeneratorGeoThermal") || item.Model.TypePath.StartsWith("/Game/FactoryGame/Buildable/Factory/OilPump")) - { - string resourceNode = item.FindField("mExtractResourceNode").Str2; - rootItem.FindChild(resourceNode, false).FindField("mIsOccupied", property => property.Value = false); - } - var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.BP_GameState_C_*", false); if (item.Model.TypePath.StartsWith("/Game/FactoryGame/Buildable/Factory/TradingPost/Build_TradingPost.Build_TradingPost_C")) + { + var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.BP_GameState_C_*", false); gameState.FindField("mIsTradingPostBuilt", property => property.Value = false); + } if (item.Model.TypePath.StartsWith("/Game/FactoryGame/Buildable/Factory/SpaceElevator/Build_SpaceElevator.Build_SpaceElevator_C")) + { + var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.BP_GameState_C_*", false); gameState.FindField("mIsSpaceElevatorBuilt", property => property.Value = false); + } rootItem.Remove(item); count++; } @@ -193,28 +192,38 @@ public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame) { Type = "StructProperty" }; - int countFactory = 0, countBuilding = 0, countCrate = 0; + int countFactory = 0, countBuilding = 0, countCrate = 0, countVehicle = 0; try { countFactory = MassDismantle(rootItem.FindChild("Buildable", true).FindChild("Factory", true).DescendantSelfViewModel, inventory, rootItem, saveGame.Header.BuildVersion); } catch (NullReferenceException) { } try + { + countFactory += MassDismantle(rootItem.FindChild("Prototype", true).FindChild("Buildable", true).FindChild("Beams", true).DescendantSelfViewModel, inventory, rootItem, saveGame.Header.BuildVersion); + } + catch (NullReferenceException) { } + try { countBuilding = MassDismantle(rootItem.FindChild("Buildable", true).FindChild("Building", true).DescendantSelfViewModel, inventory, rootItem, saveGame.Header.BuildVersion); } catch (NullReferenceException) { } try + { + countVehicle = MassDismantle(rootItem.FindChild("Buildable", true).FindChild("Vehicle", true).DescendantSelfViewModel, inventory, rootItem, saveGame.Header.BuildVersion); + } + catch (NullReferenceException) { } + try { countCrate = MassDismantle(rootItem.FindChild("-Shared", true).FindChild("BP_Crate.BP_Crate_C", true).DescendantSelfViewModel, inventory, rootItem, saveGame.Header.BuildVersion); } catch (NullReferenceException) { } - if(countFactory + countBuilding + countCrate == 0) + if(countFactory + countBuilding + countCrate + countVehicle == 0) { MessageBox.Show("Nothing was dismantled. Make sure the coordinates are correct and in clockwise order.", "Mass dismantle", MessageBoxButton.OK, MessageBoxImage.Error); return false; } - MessageBoxResult result = MessageBox.Show($"Dismantled {countFactory} factory buildings, {countBuilding} foundations and {countCrate} crates. Drop the items (including items in storages) in a single crate?", "Dismantled", MessageBoxButton.YesNo, MessageBoxImage.Question); + MessageBoxResult result = MessageBox.Show($"Dismantled {countFactory} factory buildings, {countBuilding} foundations, {countVehicle} vehicles and {countCrate} crates. Drop the items (including items in storages) in a single crate?", "Dismantled", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { CreateCrateEntityFromInventory(rootItem, inventory, saveGame.Header.BuildVersion);