bool checkBlock() { if (inventoryIndex_ < block_.InventoryCount) { var inventory = block_.GetInventory(inventoryIndex_); acceptedItems_.Clear(); acceptedItemIndex_ = 0; inventory.GetAcceptedItems(null, (itemType) => { int index = dc_.itemTypeFilter_.FindIndex(x => VISItemType.compareItemTypes(x.type, itemType)); ItemType item = new ItemType(); item.type = itemType; if (index >= 0) { item.amount = dc_.itemTypeFilter_[index].amount; acceptedItems_.Add(item); } else if (dc_.itemTypeFilter_.Count == 0) { long defaultAmount = Default.AmountItems.FirstOrDefault(pair => pair.Key.Equals(item.type)).Value; item.amount = defaultAmount > 0 ? defaultAmount : dc_.defaultMaxAmountItems_; acceptedItems_.Add(item); } return(false); }); if (acceptedItems_.Count > 0) { dc_.inventories_.Add(inventory); dc_.maxVolume_ += (double)inventory.MaxVolume; addBlock = true; } Check = checkInventory; return(false); } if (addBlock) { dc_.Blocks.Add(block_); } return(true); }
bool configMaxAmountItem(string key, string value, Configuration.Options options) { long amount = options.asInteger(0, (int)Default.MaxAmountItems); if (amount <= 0) { return(false); } VISItemType item = $"{Default.MyObjectBuilder}_{value}"; if (item.Valid) { var list = Default.AmountItems.ToList(); var index = list.FindIndex(pair => pair.Key == item); if (index >= 0) { list.RemoveAt(index); } if (!item.Group) { list.Insert(0, new KeyValuePair <VISItemType, long>(item, amount)); } else { list.Add(new KeyValuePair <VISItemType, long>(item, amount)); } Default.AmountItems = list.ToDictionary((ik) => ik.Key, (iv) => iv.Value); return(true); } manager_.log(Console.LogType.Error, $"Invalid item type \"{value}\""); return(false); }