public void AddItem(ItemSlot fromSlot)
        {
            if (fromSlot == null || fromSlot.IsEmpty || fromSlot.ItemObject.GetComponent <Fermentable>() == null || closed)
            {
                return;
            }

            ItemSlot storageSlot = itemStorage.GetNextFreeIndexedSlot();
            bool     added       = false;
            // If there's a stackable component, add one at a time.
            Stackable stack = fromSlot.ItemObject.GetComponent <Stackable>();

            if (stack == null || stack.Amount == 1)
            {
                added = Inventory.ServerTransfer(fromSlot, storageSlot);
            }
            else
            {
                var item = stack.ServerRemoveOne();
                Inventory.ServerAdd(item, storageSlot);
            }
            if (storageSlot.ItemObject.TryGetComponent(out Fermentable fermentable))
            {
                storedFermentables.Add(storageSlot, fermentable);
            }
        }
Esempio n. 2
0
        public void AddItem(ItemSlot fromSlot)
        {
            if (fromSlot == null || fromSlot.IsEmpty || ((fromSlot.ItemObject.GetComponent <Grindable>() == null && fromSlot.ItemObject.GetComponent <Juiceable>() == null) && !fromSlot.ItemAttributes.HasTrait(CommonTraits.Instance.Beaker)))
            {
                return;
            }


            if (fromSlot.ItemAttributes.HasTrait(CommonTraits.Instance.Beaker))
            {
                if (itemSlot.IsEmpty)
                {
                    Inventory.ServerTransfer(fromSlot, itemStorage.GetIndexedItemSlot(0));
                }
                return;
            }

            // If there's a stackable component, add one at a time.
            Stackable stack = fromSlot.ItemObject.GetComponent <Stackable>();

            if (stack == null || stack.Amount == 1)
            {
                Inventory.ServerTransfer(fromSlot, itemStorage.GetNextFreeIndexedSlot());
            }
            else
            {
                var item = stack.ServerRemoveOne();
                Inventory.ServerAdd(item, itemStorage.GetNextFreeIndexedSlot());
            }
        }
Esempio n. 3
0
        private void AddItem(ItemSlot fromSlot)
        {
            if (fromSlot == null || fromSlot.IsEmpty || fromSlot.ItemObject.GetComponent <Processable>() == null)
            {
                return;
            }

            // If there's a stackable component, add one at a time.
            Stackable stack = fromSlot.ItemObject.GetComponent <Stackable>();

            if (stack == null || stack.Amount == 1)
            {
                Inventory.ServerTransfer(fromSlot, storage.GetNextFreeIndexedSlot());
            }
            else
            {
                var item = stack.ServerRemoveOne();
                Inventory.ServerAdd(item, storage.GetNextFreeIndexedSlot());
            }
        }