public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
        {
            int doggocount = 1;

            var dialog = new StringPromptWindow
            {
                Owner = Application.Current.MainWindow
            };
            var cvm = (StringPromptViewModel)dialog.DataContext;

            cvm.WindowTitle     = "Enter doggo count";
            cvm.PromptMessage   = "Count (integer):";
            cvm.ValueChosen     = "1";
            cvm.OldValueMessage = "";
            dialog.ShowDialog();

            try
            {
                doggocount = int.Parse(cvm.ValueChosen);
                //MessageBox.Show("" + doggocount);

                if (doggocount > 0)
                {
                    int  counter;
                    bool pastSuccess = true; //don't keep running the loop if one run fails
                    for (counter = 0; counter < doggocount && pastSuccess; counter++)
                    {
                        pastSuccess = deleteEnemiesCheat.AddDoggo(rootItem, saveGame);
                    }

                    if (pastSuccess)
                    {
                        MessageBox.Show("Spawned " + counter + " doggo(s) at the host player.");
                        return(true);
                    }
                    else
                    {
                        //failed to spawn some doggos for some reason
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("You can't spawn " + doggocount + " doggos.");
                    return(false);
                }
            }
            catch (Exception)
            {
                if (!(cvm.ValueChosen == "cancel"))
                {
                    MessageBox.Show("Could not parse: " + cvm.ValueChosen);
                }
                return(false);
            }
        }
예제 #2
0
        public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
        {
            var hostPlayerModel = rootItem.FindChild("Char_Player.Char_Player_C", false);

            if (hostPlayerModel == null || hostPlayerModel.Items.Count < 1)
            {
                MessageBox.Show("This save does not contain a host player or it is corrupt.\nTry loading and re-saving the save from within the game.", "Cannot find host player", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            var playerEntityModel = (SaveEntityModel)hostPlayerModel.Items[0];

            int itemStackQuantity = 500;

            var dialog = new StringPromptWindow
            {
                Owner = Application.Current.MainWindow
            };
            var cvm = (StringPromptViewModel)dialog.DataContext;

            cvm.WindowTitle     = "Enter quantity of each item to spawn";
            cvm.PromptMessage   = "Count (integer):";
            cvm.ValueChosen     = "500";
            cvm.OldValueMessage = "";
            dialog.ShowDialog();

            try
            {
                itemStackQuantity = int.Parse(cvm.ValueChosen);

                if (itemStackQuantity <= 0)
                {
                    MessageBox.Show("The quantity you entered is invalid.");
                    return(false);
                }
            }
            catch (Exception)
            {
                if (!(cvm.ValueChosen == "cancel"))
                {
                    MessageBox.Show("Could not parse: " + cvm.ValueChosen);
                }
                return(false);
            }

            ArrayProperty inventory = new ArrayProperty("mInventoryStacks")
            {
                Type = "StructProperty"
            };

            HashSet <string> resourceStrings    = new HashSet <string>();
            HashSet <string> radioactiveStrings = new HashSet <string>();

            //dump all resources in a hashset first to remove duplicates TODO consider making a hashmap to numbers so they maintain order
            foreach (var resource in Resource.GetResources())
            {
                if (resource.IsRadioactive)
                {
                    radioactiveStrings.Add(resource.Path);
                }
                else
                {
                    resourceStrings.Add(resource.Path);
                }
            }

            //Populate the inventory with every item in ResourcesUnfiltered.xml
            foreach (var resource in resourceStrings)
            {
                if (!radioactiveStrings.Contains(resource))//because duplicates can be in the xml file in order, still need to check every string here for radioactivity
                {
                    //MessageBox.Show($"Processing resource {resource}");
                    byte[] bytes = MassDismantleCheat.PrepareForParse(resource, itemStackQuantity); //reuse mass dismantle cheat's parsing method
                    using (MemoryStream ms = new MemoryStream(bytes))
                        using (BinaryReader reader = new BinaryReader(ms))
                        {
                            SerializedProperty prop = SerializedProperty.Parse(reader);
                            inventory.Elements.Add(prop);
                        }
                }
            }

            string skipped = "";

            foreach (string radioactiveResource in radioactiveStrings)
            {
                skipped += $"{radioactiveResource.Split('.')[1]}\n";
            }

            //Use Mass Dismantle Cheat's crate creation function to package the items into a crate entity
            MassDismantleCheat.CreateCrateEntityFromInventory(rootItem, inventory);

            //MessageBox.Show("Player name " + playerEntityModel.Title);
            MessageBox.Show($"Crate created.\nNote that normally unstackable items will visually display as being stacked to 1. Use Ctrl+Click to transfer items out of the crate without deleting part of the stack.\n\nSkipped the following items marked as radioactive:\n\n{skipped}", $"Processed {resourceStrings.Count} resource paths");

            //Ask the player if they'd like the be equipped with a hazmat suit and filters since the box will be radioactive

            /*MessageBoxResult result = MessageBox.Show("A crate with all resources has been generated at your feet. This includes radioactive items. Would you like a Hazmat suit and filters? They will replace your current equipment and first inventory item.", $"Processed {resourceStrings.Count} resource paths", MessageBoxButton.YesNo, MessageBoxImage.Question);
             * if (result == MessageBoxResult.Yes)
             * {
             *  string hazmatPath = "/Game/FactoryGame/Resource/Equipment/HazmatSuit/BP_EquipmentDescriptorHazmatSuit.BP_EquipmentDescriptorHazmatSuit_C";
             *  string filterPath = "/Game/FactoryGame/Resource/Parts/IodineInfusedFilter/Desc_HazmatFilter.Desc_HazmatFilter_C";
             *
             *  //playerEntityModel.FindOrCreateField<ObjectProperty>("mInventory");
             *  var playerName = playerEntityModel.Title;
             *  var playerBackSlot = rootItem.FindChild(playerName + ".BackSlot", true);
             *  if (playerBackSlot == null)
             *  {
             *      MessageBox.Show("Your player does not seem to have an associated back slot.\nThe crate has still been created, but you have not been given Hazmat equipment.", "Cannot find host player inventory.", MessageBoxButton.OK, MessageBoxImage.Warning);
             *  }
             *  else
             *  {
             *      //MessageBox.Show(playerBackSlot.FindOrCreateField<ArrayPropertyViewModel>("mInventoryStacks").Elements[0]);
             *      MessageBox.Show("Currently unimplemented");
             *  }
             * }*/

            return(true);
        }
        public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
        {
            var sinkSubsystem = rootItem.FindChild("Persistent_Level:PersistentLevel.ResourceSinkSubsystem", false);

            if (sinkSubsystem == null)
            {
                MessageBox.Show("This save does not contain a ResourceSinkSubsystem.\nThis means that the loaded save is probably corrupt. Aborting.", "Cannot find ResourceSinkSubsystem", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            var pointsTowardsCurrentTicket = sinkSubsystem.FindOrCreateField <Int64PropertyViewModel>("mTotalResourceSinkPoints");
            var mCurrentPointLevel         = sinkSubsystem.FindOrCreateField <IntPropertyViewModel>("mCurrentPointLevel");

            var dialog = new StringPromptWindow
            {
                Owner = Application.Current.MainWindow
            };
            var cvm = (StringPromptViewModel)dialog.DataContext;

            cvm.WindowTitle     = "Enter earned ticket count";
            cvm.PromptMessage   = "Tickets";
            cvm.ValueChosen     = "0";
            cvm.OldValueMessage = $"Sets the AWESOME Sink ticket prices as if you had earned N tickets.\nFor example, entering 0 sets the price for the next ticket back to 1,000\nCurrent tickets earned: {mCurrentPointLevel.Value}\nMore info on AWESOME Sink wiki page";
            dialog.ShowDialog();

            int requestedTicketCount = 0;

            try
            {
                requestedTicketCount = int.Parse(cvm.ValueChosen);

                if (requestedTicketCount < 0)
                {
                    MessageBox.Show("You must enter a number greater than 0.", "Ticket count unchanged.", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
                else if (requestedTicketCount > 288100000)
                {
                    MessageBox.Show("The highest ticket count supported is about 288,100,000, since the highest supported points per ticket is around 9,223,372,036,854,775,807 (int64 max value)", "That's a lot of tickets!");
                    return(false);
                }

                mCurrentPointLevel.Value = requestedTicketCount; //"point level" is 0 if no tickets have been earned, 1 if one ticket has, etc.

                pointsTowardsCurrentTicket.Value = 0;            //reset progress towards the current ticket so the game GUI doesn't get confused

                long calculatedPointsCount = pointsRequiredFromTicketCount(requestedTicketCount);

                MessageBox.Show($"Earned ticket count set to {requestedTicketCount}.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                //MessageBox.Show($"Ticket count set to {requestedTicketCount}. The next ticket will take {calculatedPointsCount} points to earn.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                return(true);
            }
            catch (Exception)
            {
                if (!(cvm.ValueChosen == "cancel"))
                {
                    MessageBox.Show($"Could not parse: {cvm.ValueChosen}");
                }
                return(false);
            }
        }
예제 #4
0
        public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
        {
            var mapManager = rootItem.FindChild("Persistent_Level:PersistentLevel.MapManager", false);

            if (mapManager == null)
            {
                MessageBox.Show("This save does not contain a MapManager.\nThis means that the loaded save is probably corrupt. Aborting.", "Cannot find MapManager", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            //map data is an Array(Byte) containing 1048576 elements ranging from 0 to 255, where 255 is fully revealed.
            var fogOfWarRawData = mapManager.FindOrCreateField <ArrayPropertyViewModel>("mFogOfWarRawData");

            if (!(fogOfWarRawData is ArrayPropertyViewModel))
            {
                MessageBox.Show("FogOfWarRawData is of wrong type.\nThis means that the loaded save is probably corrupt. Aborting.", "Wrong property type", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (fogOfWarRawData.Elements.Count != 1048576)
            {
                MessageBox.Show($"Expected 1048576 fog of war elements to be present, but there were actually {fogOfWarRawData.Elements.Count}.\nThis does not necessarily mean that the process will fail. Please report this error on the Github Issues page regardless.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            int mapRevealThreshold = 0;

            var dialog = new StringPromptWindow
            {
                Owner = Application.Current.MainWindow
            };
            var cvm = (StringPromptViewModel)dialog.DataContext;

            cvm.WindowTitle     = "Enter map reveal threshold";
            cvm.PromptMessage   = "Enter a number between 0 and 255 (integer):";
            cvm.ValueChosen     = "255";
            cvm.OldValueMessage = "Sets the reveal state of every map region to the value you choose.\n255 is fully explored\n0 is entirely unexplored";
            dialog.ShowDialog();

            try
            {
                mapRevealThreshold = int.Parse(cvm.ValueChosen);
                if (mapRevealThreshold >= 0 && mapRevealThreshold <= 255)
                {
                    for (int i = 0; i < fogOfWarRawData.Elements.Count; i++)
                    {
                        ((BytePropertyViewModel)fogOfWarRawData.Elements[i]).Value = $"{mapRevealThreshold}";
                    }
                }
                else
                {
                    MessageBox.Show("You must enter a number between 0 and 255.");
                    return(false);
                }
            }
            catch (Exception)
            {
                if (!(cvm.ValueChosen == "cancel"))
                {
                    MessageBox.Show($"Could not parse: {cvm.ValueChosen}");
                }
                return(false);
            }

            MessageBox.Show("Map data uncovered. Remember to enable the map as well if desired.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            return(true);
        }