private void Craft()
        {
            ItemCollection craftCollection = m_Collections[m_CraftingCollectionIndex];
            ItemBlueprint  blueprint       = ItemDatabase.GetBlueprint(craftCollection.ToArray());

            if (blueprint == null)
            {
                return;
            }

            ItemCollection defaultCollection = m_Collections[m_DefaultCollectionIndex];

            if (defaultCollection.IsFull(blueprint.Output))
            {
                return;
            }
            if (!defaultCollection.IsAllowed(blueprint.Output))
            {
                return;
            }

            craftCollection.Clear(true);

            GameObject    obj  = NetworkController.Instance.Scene.CreateForClient(Identity.OwnerConnection, blueprint.Output.gameObject, Vector3.zero, Quaternion.identity);
            InventoryItem item = obj.GetComponent <InventoryItem>();

            Add(item, defaultCollection);

            NetworkController.Instance.RemoteProcedures.Call(Identity, RPCType.Target, nameof(ClientRpcClearCollection), Identity.OwnerConnection, GetCollectionIndex(craftCollection));
        }
        private void Add(InventoryItem item, ItemCollection collection)
        {
            if (item.Stack <= 0)
            {
                return;
            }

            if (!collection.IsAllowed(item))
            {
                return;
            }

            if (collection.IsFull(item))
            {
                return;
            }

            InventoryItem[] foundItems    = Array.FindAll(collection.ToArray(), x => x != null && x.ItemID == item.ItemID && x.Stack < x.MaxStack);
            bool            amountChanged = false;

            if (foundItems.Length > 0)
            {
                for (int i = 0; i < foundItems.Length; i++)
                {
                    InventoryItem foundItem = foundItems[i];
                    int           count     = foundItem.MaxStack - foundItem.Stack;

                    for (int j = 0; j < count; j++)
                    {
                        foundItem.Stack++;
                        item.Stack--;
                        amountChanged = true;

                        if (item.Stack == 0)
                        {
                            NetworkController.Instance.Scene.Destroy(item.gameObject);
                            NotifyStackChanged(foundItem, collection);
                            return;
                        }
                    }

                    if (amountChanged)
                    {
                        NotifyStackChanged(foundItem, collection);
                    }
                }
            }

            if (amountChanged)
            {
                NotifyStackChanged(item, collection);
            }

            int slot = collection.FirstEmptySlot(item.Category);

            if (slot == -1)
            {
                return;
            }

            collection[slot] = item;
            NetworkController.Instance.Scene.RegisterObjectAuthority(Identity.OwnerConnection, item.Identity);
            ItemAdded?.Invoke(collection, item, slot);

            int collectionIndex = GetCollectionIndex(collection);

            NetworkController.Instance.RemoteProcedures.Call(Identity, RPCType.Target, nameof(ClientRpcMoveItem), Identity.OwnerConnection, item.InstanceID, collectionIndex, collectionIndex, slot, slot);
            NetworkController.Instance.RemoteProcedures.Call(Identity, RPCType.All, nameof(SharedRpcClientClaim), item.InstanceID);
            SharedRpcClientClaim(item.InstanceID);
        }