protected virtual bool CanRemoveRequiredItems(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.removeItemsFromCollection != null && craftInfo.removeItemsFromCollection.useReferences == false)
            {
                foreach (var item in craftInfo.blueprint.requiredItems)
                {
                    uint count = craftInfo.removeItemsFromCollection.GetItemCount(item.item.ID);
                    if (count < item.amount * craftInfo.craftAmount)
                    {
                        return(false);
                    }
                }

                return(true);
            }

            foreach (var item in craftInfo.blueprint.requiredItems)
            {
                uint count = InventoryManager.GetItemCount(item.item.ID, craftInfo.category.alsoScanBankForRequiredItems);
                if (count < item.amount * craftInfo.craftAmount)
                {
                    return(false);
                }
            }

            return(true);
        }
 protected virtual void NotifyOnCraftStart(CraftingProgressContainer.CraftInfo craftInfo)
 {
     if (OnCraftStart != null)
     {
         OnCraftStart(craftInfo);
     }
 }
 protected virtual void NotifyOnCraftCancelled(CraftingProgressContainer.CraftInfo craftInfo, float progress)
 {
     if (OnCraftCancelled != null)
     {
         OnCraftCancelled(craftInfo, progress);
     }
 }
        protected virtual bool CanAddItemsRewardItems(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.storeItemsInCollection != null)
            {
                var before = craftInfo.storeItemsInCollection.canPutItemsInCollection;
                craftInfo.storeItemsInCollection.canPutItemsInCollection = true;


                var l = new List <ItemAmountRow>();
                for (int i = 0; i < craftInfo.craftAmount; i++)
                {
                    l.AddRange(craftInfo.blueprint.resultItems);
                }

                if (craftInfo.storeItemsInCollection.CanAddItems(l.ToArray()) == false)
                {
                    return(false);
                }

                bool stored = craftInfo.storeItemsInCollection.CanAddItems(l.ToArray());

                craftInfo.storeItemsInCollection.canPutItemsInCollection = before;
                return(stored);
            }

            if (InventoryManager.IsInventoryCollection(removeItemsFromCollection))
            {
                return(InventoryManager.CanRemoveItemsThenAdd(craftInfo.blueprint.resultItems, craftInfo.blueprint.requiredItems));
            }

            return(InventoryManager.CanAddItems(craftInfo.blueprint.resultItems));
        }
 protected virtual void NotifyOnCraftFailed(CraftingProgressContainer.CraftInfo craftInfo)
 {
     if (OnCraftFailed != null)
     {
         OnCraftFailed(craftInfo);
     }
 }
        public virtual void GiveCraftReward(CraftingProgressContainer.CraftInfo craftInfo)
        {
            var itemsToAdd = InventoryItemUtility.RowsToItems(craftInfo.blueprint.resultItems, true);

#if UFPS_MULTIPLAYER
            foreach (var item in itemsToAdd)
            {
                var i = item as Devdog.InventoryPro.Integration.UFPS.UFPSInventoryItemBase;
                if (i != null && Devdog.InventoryPro.Integration.UFPS.Multiplayer.InventoryMPUFPSPickupManager.instance != null)
                {
                    Devdog.InventoryPro.Integration.UFPS.Multiplayer.InventoryMPUFPSPickupManager.instance.InstantiateAndRegisterPickupOnAllClients(i);
                }
            }
#endif

            if (craftInfo.storeItemsInCollection != null)
            {
                var before = craftInfo.storeItemsInCollection.canPutItemsInCollection;
                craftInfo.storeItemsInCollection.canPutItemsInCollection = true;

                bool added = craftInfo.storeItemsInCollection.AddItems(itemsToAdd);

                craftInfo.storeItemsInCollection.canPutItemsInCollection = before;

                Assert.IsTrue(added, "Couldn't add items even though check passed. Please report this error + stack trace.");
            }
            else
            {
                // Store crafted item
                bool added = InventoryManager.AddItems(itemsToAdd);
                Assert.IsTrue(added, "Couldn't add items even though check passed. Please report this error + stack trace.");
            }
        }
        protected virtual void NotifyOnCraftProgress(CraftingProgressContainer.CraftInfo craftInfo, float progress)
        {
            blueprintCraftingProgress.Repaint(progress, 1f);

            if (OnCraftProgress != null)
            {
                OnCraftProgress(craftInfo, progress);
            }
        }
        private void NotifyOnCraftCancelled(CraftingProgressContainer.CraftInfo craftInfo, float progress)
        {
            if (craftInfo.validator.gameObject != gameObject)
            {
                return;
            }

            if (OnCraftCancelled != null)
            {
                OnCraftCancelled(craftInfo, progress);
            }
        }
        private void NotifyOnCraftSuccess(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.validator.gameObject != gameObject)
            {
                return;
            }

            if (OnCraftSuccess != null)
            {
                OnCraftSuccess(craftInfo);
            }
        }
        private void NotifyOnCraftStart(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.validator.gameObject != gameObject)
            {
                return;
            }

            Debug.Log("On craft start on " + gameObject.name + " validator : " + craftInfo.validator.gameObject.name, gameObject);
            if (OnCraftStart != null)
            {
                OnCraftStart(craftInfo);
            }
        }
Пример #11
0
        /// <summary>
        /// Does the inventory contain the required items?
        /// </summary>
        public override bool CanCraftBlueprint(InventoryPlayer player, CraftingProgressContainer.CraftInfo craftInfo)
        {
            bool can = base.CanCraftBlueprint(player, craftInfo);

            if (can == false)
            {
                return(false);
            }

            // No blueprint found
            if (GetBlueprintFromCurrentLayout(craftInfo.removeItemsFromCollection ?? mainItemsCollection, craftInfo.category) == null)
            {
                return(false);
            }

            return(true);
        }
        public virtual void RemoveRequiredCraftItemsAndCurrency(CraftingProgressContainer.CraftInfo craftInfo)
        {
            craftInfo.removedCraftItems = true;

            if (craftInfo.removeItemsFromCollection != null && craftInfo.removeItemsFromCollection.useReferences == false)
            {
                foreach (var item in craftInfo.blueprint.requiredItems)
                {
                    craftInfo.removeItemsFromCollection.RemoveItem(item.item.ID, item.amount);
                }
            }
            else
            {
                foreach (var item in craftInfo.blueprint.requiredItems)
                {
                    InventoryManager.RemoveItem(item.item.ID, item.amount, craftInfo.category.alsoScanBankForRequiredItems);
                }
            }

            InventoryManager.RemoveCurrency(craftInfo.blueprint.craftingCost);
        }
        public virtual bool CanCraftBlueprint(InventoryPlayer player, CraftingProgressContainer.CraftInfo craftInfo)
        {
            // Required properties?
            if (player.characterUI != null)
            {
                foreach (var propLookup in craftInfo.blueprint.usageRequirement)
                {
                    if (propLookup.CanUse(player) == false)
                    {
                        InventoryManager.langDatabase.craftingCannotStatNotValid.Show(craftInfo.blueprint.name, craftInfo.blueprint.description, propLookup.stat.statName);
                        return(false);
                    }
                }
            }

            if (CanRemoveRequiredItems(craftInfo) == false)
            {
                InventoryManager.langDatabase.craftingDontHaveRequiredItems.Show(craftInfo.blueprint.requiredItems[0].item.name, craftInfo.blueprint.requiredItems[0].item.description, craftInfo.blueprint.name);
                return(false);
            }

            if (CanAddItemsRewardItems(craftInfo) == false)
            {
                InventoryManager.langDatabase.collectionFull.Show(craftInfo.blueprint.name, craftInfo.blueprint.description, "Reward collection");
                return(false);
            }

            // Enough currency?
            if (CanRemoveRequiredCurrency(craftInfo) == false)
            {
                InventoryManager.langDatabase.userNotEnoughGold.Show(craftInfo.blueprint.name, craftInfo.blueprint.description, craftInfo.craftAmount, craftInfo.blueprint.craftingCost.ToString(craftInfo.craftAmount));
                return(false);
            }

            return(true);
        }
 private void UpdateTrigger(CraftingProgressContainer.CraftInfo craftInfo)
 {
     craftingWindow.UseWithTrigger(craftInfo.category, progressContainer, this, craftingItemsCollection, craftingRewardItemsCollection);
 }
 private void CraftingWindowOnCraftSuccess(CraftingProgressContainer.CraftInfo craftInfo)
 {
     UpdateTrigger(craftInfo);
 }
 private void CraftingWindowOnOnCraftCancelled(CraftingProgressContainer.CraftInfo craftInfo, float progress)
 {
     UpdateTrigger(craftInfo);
 }
 public void GiveCraftReward(CraftingProgressContainer.CraftInfo craftInfo)
 {
     craftingWindow.GiveCraftReward(craftInfo);
 }
 public void RemoveRequiredCraftItemsAndCurrency(CraftingProgressContainer.CraftInfo craftInfo)
 {
     craftingWindow.RemoveRequiredCraftItemsAndCurrency(craftInfo);
 }
 public bool CanCraftBlueprint(InventoryPlayer player, CraftingProgressContainer.CraftInfo craftInfo)
 {
     return(craftingWindow.CanCraftBlueprint(player, craftInfo));
 }
 /// <summary>
 /// Does the inventory contain the required items?
 /// </summary>
 public virtual bool CanCraftBlueprint(CraftingProgressContainer.CraftInfo craftInfo)
 {
     return(CanCraftBlueprint(PlayerManager.instance.currentPlayer.inventoryPlayer, craftInfo));
 }
 private bool CanRemoveRequiredCurrency(CraftingProgressContainer.CraftInfo craftInfo)
 {
     return(InventoryManager.CanRemoveCurrency(craftInfo.blueprint.craftingCost, true, craftInfo.category.alsoScanBankForRequiredItems));
 }