Example #1
0
        internal virtual void ReplaceWithFake(int type)
        {
            if (real && item.stack > 0)
            {
                //	Main.player[Main.myPlayer].QuickSpawnItem(RecipeBrowserWindow.lookupItemSlot.item.type, RecipeBrowserWindow.lookupItemSlot.item.stack);

                Player player = Main.player[Main.myPlayer];
                item.position = player.Center;
                Item item2 = player.GetItem(player.whoAmI, item, false, true);
                if (item2.stack > 0)
                {
                    int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false);
                    Main.item[num].newAndShiny = false;
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(21, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0);
                    }
                }
                item = new Item();
            }

            item.SetDefaults(type);
            real = type == 0;
            backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake;
            OnItemChanged?.Invoke();
        }
        internal virtual void ReplaceWithFake(int type)
        {
            if (real && item.stack > 0)
            {
                //	Main.player[Main.myPlayer].QuickSpawnItem(RecipeBrowserWindow.lookupItemSlot.item.type, RecipeBrowserWindow.lookupItemSlot.item.stack);

                Player player = Main.player[Main.myPlayer];
                item.position = player.Center;
                Item item2 = player.GetItem(player.whoAmI, item, false, true);
                if (item2.stack > 0)
                {
                    int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false);
                    Main.item[num].newAndShiny = false;
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        NetMessage.SendData(MessageID.SyncItem, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0);
                    }
                    else
                    {
                        // TODO: Detect PreSaveAndQuit only.
                        RecipeBrowser.instance.Logger.Warn("You left an item in the recipe browser with a full inventory and have lost the item: " + item2.Name);
                    }
                }
                item = new Item();
            }

            item.SetDefaults(type);
            real = type == 0;
            backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake;
            OnItemChanged?.Invoke();
        }
 public bool AddToInventory(Item item)
 {
     //Debug.Log("Attempting to add item to inventory...");
     if (inventoryItems.Count >= maxInventorySpace)
     {
         // Debug.Log("Could not add to inventory");
         GameManager.instance.player.DisplayPopupText("Inventory full!");
         return(false);
     }
     else
     {
         inventoryItems.Add(item);
         onItemChangedCallback?.Invoke(item); // '?' = a check to see if the variable is true or not, if so perform the operation
         return(true);
     }
 }
Example #4
0
    public bool Add(Item item)
    {
        if (!item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                Debug.Log("Not enough space in the inventory!");
                return(false);
            }

            items.Add(item);
            onItemChangedCallback?.Invoke();
        }

        return(true);
    }
        public override void Click(UIMouseEvent evt)
        {
            Player player = Main.LocalPlayer;

            if (player.itemAnimation == 0 && player.itemTime == 0)
            {
                if (real)
                {
                    Item item = Main.mouseItem.Clone();
                    Main.mouseItem = this.item.Clone();
                    if (Main.mouseItem.type > 0)
                    {
                        Main.playerInventory = true;
                    }
                    this.item = item.Clone();
                }
                else
                {
                    item = Main.mouseItem.Clone();
                    Main.mouseItem.SetDefaults(0);
                    real = true;
                }
                if (item.type == 0)
                {
                    real = true;
                }
                OnItemChanged?.Invoke();
            }
            backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake;
        }
Example #6
0
    public void AddItemIntoInventory(Loot loot)
    {
        Item item = loot.GetItem();

        loot.PickUp();
        //currentCollidedItem = null;
        OnItemAdd?.Invoke(item);
    }
Example #7
0
 public bool Add(Item item)
 {
     if (!item.isDefaultItem)
     {
         if (Items.Count >= space)
         {
             Debug.Log("Not enough room.");
             return(false);
         }
         Items.Add(item);
         if (Callback != null)
         {
             Callback.Invoke();
         }
     }
     return(true);
 }
 public bool Add(Item item)
 {
     if (!item.isDefaultItem)
     {
         if (items.Count >= space)
         {
             print("Not enough room");
             return(false);
         }
         items.Add(item);
         if (onItemChangedCallback != null)
         {
             onItemChangedCallback.Invoke();
         }
     }
     return(true);
 }
Example #9
0
 public bool addToInv(InventoryItem item)
 {
     if (getSize() < maxSize)
     {
         invItems.Add(item);
         if (onItemChangedCallback != null)
         {
             onItemChangedCallback.Invoke();
         }
         return(true);
     }
     else
     {
         Debug.Log("no room for Item!");
         return(false);
     }
 }
Example #10
0
 public bool Add(InvItem invItem, int replaceIndex = -1)
 {
     if (invItem.item.stackable)
     {
         InvItem _item = FindItem(invItem.item);
         if (_item == null)
         {
             if (IsFull())
             {
                 return(false);
             }
             if (replaceIndex >= 0 && replaceIndex < items.Count)
             {
                 items[replaceIndex] = invItem;
             }
             else
             {
                 items.Add(invItem);
             }
         }
         else
         {
             _item.stackCount += invItem.stackCount;
         }
     }
     else
     {
         if (replaceIndex != -1 && replaceIndex < items.Count)
         {
             items[replaceIndex] = invItem;
         }
         else if (IsFull())
         {
             return(false);
         }
         else
         {
             items.Add(invItem);
         }
     }
     if (onItemChangedCallback != null)
     {
         onItemChangedCallback.Invoke();
     }
     return(true);
 }
Example #11
0
 public bool Add(Item item)
 {
     if (!item.isDefaultItem)
     {
         if (items.Count >= space)
         {
             Debug.Log("Not enough Inventory space");
             return(false);
         }
         items.Add(item);
         if (onItemChangedCallback != null)
         {
             onItemChangedCallback.Invoke();
         }
     }
     return(true);
 }
Example #12
0
 public bool Add(Item item)
 {
     if (!item.isDefaultItem)
     {
         if (items.Count >= space)
         {
             Debug.Log("Not Enough Room");
             return(false);;
         }
         items.Add(item);
         if (OnItemChangedCallback != null)
         {
             OnItemChangedCallback.Invoke();
         }
     }
     return(true);
 }
    public bool Add(Item item)
    {
        if (items.Count >= space)
        {
            Debug.Log("Not enough room");
            return(false);
        }

        items.Add(item);

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }

        return(true);
    }
    // Add a new item. If there is enough room we
    // return true. Else we return false.
    public bool Add(Item item, int amount)
    {
        // Don't do anything if it's a default item
        if (!item.isDefaultItem)
        {
            if ((this.GetWeight() + item.weight) > PlayerMovement.Statistics.GetCarriableWeight())
            {
                Debug.Log("Not enough strengh: can only carry " + PlayerMovement.Statistics.GetCarriableWeight() + ".");
                return(false);
            }

            // Check if out of space
            if (items.Count >= space)
            {
                Debug.Log("Not enough room.");
                return(false);
            }

            if (items.ContainsKey(item))
            {
                items[item] += amount;
            }
            else
            {
                items.Add(item, amount);
                Debug.LogError(item.name + " has been added");
            }
            Debug.Log("New inventory weight: " + GetWeight() + " " +
                      "(can carry " + PlayerMovement.Statistics.GetCarriableWeight() + ").");

            // Trigger callback
            if (onItemChangedCallback != null)
            {
                Debug.Log("Invoking callback");

                onItemChangedCallback.Invoke();
            }
            else
            {
                Debug.Log("No callback.");
            }
        }

        return(true);
    }
Example #15
0
    public bool Add(Item item)
    {
        /*
         * Add a single item in the inventory (ex: if you loot a single sword)
         */
        if (!item.isDefaultItem)
        {
            ItemStack itemStack = itemsStack.Find(x => x.item == item);
            if (itemStack != null)
            {
                itemStack.AddStack();
            }
            else
            {
                if (itemsStack.Count >= space)
                {
                    Debug.Log("Not enough space in inventory");
                    return(false);
                }

                itemsStack.Add(new ItemStack(item));
            }

            onItemChangedCallback?.Invoke();

            return(true);
        }
        return(false);
    }
Example #16
0
    public bool AddItem(Item _item)
    {
        if (!_item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                return(false);
            }
            if (!items.Contains(_item))
            {
                items.Add(_item);
                AmountItens.Add(1);
            }
            else
            {
                int index = -1;

                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i] == _item)
                    {
                        if (AmountItens[i] < items[i].MaximunStacks)
                        {
                            AmountItens[i]++;
                            index = i;
                            break;
                        }
                    }
                }

                if (index == -1)
                {
                    items.Add(_item);
                    AmountItens.Add(1);
                }
            }


            if (onItemChangedCallBack != null)
            {
                onItemChangedCallBack.Invoke();
            }
        }
        return(true);
    }
Example #17
0
 public bool Add(ItemSO item)
 {
     if (items.Count < space)
     {
         items.Add(item);
         // CallBack Triggered
         if (onItemChangedCallback != null)
         {
             onItemChangedCallback.Invoke();
         }
         return(true);
     }
     else
     {
         //Inventory Full
         return(false);
     }
 }
Example #18
0
    // Add a new item if enough room
    public void Add(Item item)
    {
        if (item.showInInventory)
        {
            if (items.Count >= space)
            {
                Debug.Log("Not enough room.");
                return;
            }

            items.Add(item);

            if (onItemChangedCallback != null)
            {
                onItemChangedCallback.Invoke();
            }
        }
    }
Example #19
0
    //add item to inventory
    public bool Add(Item item)
    {
        if (!item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                // no more room
                return(false);
            }
            items.Add(item);

            if (onItemChangedCallBack != null)
            {
                onItemChangedCallBack.Invoke();
            }
        }
        return(true);
    }
Example #20
0
    public bool add(Item item)
    {
        if (!item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                Debug.Log("pas assez d'espace");
                return(false);
            }
            items.Add(item);
            if (onItemChangedCallBack != null)
            {
                onItemChangedCallBack.Invoke();
            }
        }

        return(true);
    }
Example #21
0
    // Add a new item if enough room
    public void Add(Item item, string act)
    {
        if (range)
        {
            if (items.Count >= space)
            {
                Debug.Log("Not enough room.");
                return;
            }

            items.Add(act, item);

            if (onItemChangedCallback != null)
            {
                onItemChangedCallback.Invoke();
            }
        }
    }
Example #22
0
    // Add a new item. If there is enough room we
    // return true. Else we return false.
    public bool Add(HI_Prop item)
    {
        // Check if out of space
        if (items.Count >= space)
        {
            Debug.Log("Inventory Full");
            return(false);
        }

        items.Add(item);    // Add item to list

        // Trigger callback
        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
        return(true);
    }
Example #23
0
    public bool Add(Item item)
    {
        for (int i = 0; i < space; i++)
        {
            if (items[i] == null)
            {
                items[i] = item;
                if (onItemChangedCallback != null)
                {
                    onItemChangedCallback.Invoke();
                }
                return(true);
            }
        }

        Debug.Log("Not enough room!");
        return(false);
    }
    public bool AddItem(ItemInfo item)
    {
        if (listItems.Count >= nRelicSpace)
        {
            Debug.Log("Not enough room.");
            return(false);
        }

        ItemChange(item);

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }


        return(true);
    }
Example #25
0
    public bool Add(Item item)
    {
        if (!item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                Debug.Log("Your inventory is full");
                return(false);
            }
            items.Add(item);

            if (OnItemChangedCallback != null)
            {
                OnItemChangedCallback.Invoke();
            }
        }
        return(true);
    }
Example #26
0
    public bool Add(Vegetable vegetable)
    {
        if (veggies.Count < slots)
        {
            veggies.Add(vegetable);

            if (onItemChangedCallback != null)
            {
                onItemChangedCallback.Invoke();
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #27
0
    public void Add(Product item)
    {
        products.Add(item);

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }
Example #28
0
    public bool Add(Item item)
    {
        if (!item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                Debug.Log("I can't carry anymore!");
                return(false);
            }
            items.Add(item);

            if (onItemChangedCallback != null)
            {
                onItemChangedCallback.Invoke();
            }
        }
        return(true);
    }
    public bool Add(Item item)
    {
        if (!item.isDeafaultItem)
        {
            if (items.Count >= space)
            {
                Debug.Log("nie ma miejsca");
                return(false);
            }
            items.Add(item);

            if (onItemCHangedCallback != null)
            {
                onItemCHangedCallback.Invoke();
            }
        }
        return(true);
    }
Example #30
0
    // Remove an item
    public void Remove(Item item)
    {
        items.Remove(item);

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }