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); }
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); } } }