예제 #1
0
    /// <summary>
    /// Handles outputting to things with the inventory interface.
    /// </summary>
    /// <param name="OUT_INV"></param>
    public void OutputToInventory(IInventory OUT_INV)
    {
        //If the inventory is completely full, then just return.
        if (OUT_INV.IsFull())
        {
            return;
        }
        else
        {
            //Get the item list with all its counts.
            List <ItemAmount> ITEM_LIST = INV.GetItemAmountList();

            //For each unique item, attempt to add its count.
            foreach (ItemAmount ITEM_INFO in ITEM_LIST)
            {
                //If attempting to add the items would be successful,
                if (OUT_INV.AttemptAddItem(ITEM_INFO.Item, ITEM_INFO.Amount))
                {
                    GenericEntity      OUT_INFO     = OUT_INV.GetEntity();
                    List <GenericItem> UNIQUE_ITEMS = INV.GetUniqueItemsList();
                    if (UNIQUE_ITEMS.Contains(ITEM_INFO.Item))
                    {
                        UNIQUE_ITEMS.Add(ITEM_INFO.Item);
                    }

                    //Check if it is valid for us to place these items into the given entity.
                    if (GameManager.Instance.isItemPlacementValid(UNIQUE_ITEMS, OUT_INV.GetEntity().FLAGS))
                    {
                        OUT_INV.AddItem(ITEM_INFO.Item, ITEM_INFO.Amount);
                        INV.ExtractItem(ITEM_INFO.Item, ITEM_INFO.Amount);
                    }
                }
            }
        }
    }