public Pickupable RemoveItemFromContainer(TechType techType, int amount) { if (ContainsItem(techType)) { var itemData = ContainerItems.FirstOrDefault(x => x.TechType == techType); var item = InventoryHelpers.ConvertToPickupable(itemData); ContainerItems.Remove(itemData); //OnContainerUpdate?.Invoke(GetTotalCount(),_maxItems); return(item); } return(null); }
public bool AddItemToContainer(InventoryItem item) { try { ContainerItems.Add(InventoryHelpers.CovertToItemData(item, true)); //OnContainerUpdate?.Invoke(GetTotalCount(), _maxItems); } catch (Exception e) { QuickLogger.Error($"Class: [Storage Container] | Method: [AddItemToContainer] | Error: ${e.Message}"); return(false); } return(true); }
internal void AttemptToTakeItem(TechType techType) { var amount = GetItemCount(techType); QuickLogger.Debug($"Container returned {amount} item/s for TechType {techType}"); #if SUBNAUTICA var itemSize = CraftData.GetItemSize(techType); #elif BELOWZERO var itemSize = TechData.GetItemSize(techType); #endif if (Inventory.main.HasRoomFor(itemSize.x, itemSize.y)) { if (amount > 0) { QuickLogger.Debug($"Attempting to take {_multiplier} item/s"); for (int i = 0; i < _multiplier; i++) { var itemData = ContainerItems.FirstOrDefault(x => x.TechType == techType); Pickupable pickup = InventoryHelpers.ConvertToPickupable(itemData); if (pickup == null) { QuickLogger.Debug($"There are 0 {techType} in the container while using first or default Current Amount of {techType} is: {GetItemCount(techType)}", true); return; } Inventory.main.Pickup(pickup); ContainerItems.Remove(itemData); //OnContainerUpdate?.Invoke(GetTotalCount(),_maxItems); } } else { QuickLogger.Debug($"There are 0 {techType} in the container.", true); } } }
private void FlushContainer() { ContainerItems.Clear(); }
internal int GetItemCount(TechType techType) { var items = ContainerItems.Where(x => x.TechType == techType); return(items.Count()); }
public bool ContainsItem(TechType techType) { return(ContainerItems != null && ContainerItems.Any(x => x.TechType == techType)); }
public Dictionary <TechType, int> GetItemsWithin() { var lookup = ContainerItems?.Where(x => x != null).ToLookup(x => x.TechType).ToArray(); return(lookup?.ToDictionary(count => count.Key, count => count.Count())); }