Exemple #1
0
        private void UpdateQuantities()
        {
            //  Initialize all quantities back to zero
            foreach (Object Placeholder in Placeholders.SelectMany(x => x.Value.Values))
            {
                Placeholder.Stack = 0;
            }

            //  Set quantities of the placeholder items to match the corresponding amount of the item currently stored in the bag
            foreach (Object Item in Bag.Contents)
            {
                if (Placeholders.TryGetValue(Item.ParentSheetIndex, out Dictionary <ObjectQuality, Object> Group))
                {
                    ObjectQuality Quality = (ObjectQuality)Item.Quality;
                    if (Group.TryGetValue(Quality, out Object Placeholder))
                    {
                        ItemBag.ForceSetQuantity(Placeholder, Item.Stack);

                        if (Placeholder.Price != Item.Price)
                        {
#if DEBUG
                            string WarningMsg = string.Format("Warning - GroupedLayout placeholder item '{0}' does not have a matching price to the corresponding item in the bag."
                                                              + " Placeholder.Price={1}, BagItem.Price={2}", Placeholder.DisplayName, Placeholder.Price, Item.Price);
                            ItemBagsMod.ModInstance.Monitor.Log(WarningMsg, LogLevel.Warn);
#endif
                            Placeholder.Price = Item.Price;
                        }
                    }
                }
            }
        }