Esempio n. 1
0
        /// <summary>
        ///     Remove any single item type from the inventory
        /// </summary>
        /// <param name="amount">Amount to remove (for stacks)</param>
        /// <returns>The ItemBase removed from inventory</returns>
        public ItemBase RemoveAnySingle(int amount = 1)
        {
            List <ItemBase> output = new List <ItemBase>();

            ItemBaseUtil.MoveItems(ref this.Inventory, ref output, amount, amount, true);
            if (output.Count == 0)
            {
                return(null);
            }
            return(output[0]);
        }
Esempio n. 2
0
 /// <summary>
 ///     Add items from a source inventory or item list
 /// </summary>
 /// <param name="items">The source inventory or list of items</param>
 /// <param name="amount">The number of items to transfer</param>
 public void AddItem(ref List <ItemBase> items, int amount = 1)
 {
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, amount, this.StorageCapacity, false);
 }
Esempio n. 3
0
 /// <summary>
 ///     Add a single item type to the inventory
 /// </summary>
 /// <param name="item">The item to add</param>
 /// <param name="amount">Amount of items added if given a stack</param>
 /// <returns>Returns the remainder that doesn't fit or null if successful</returns>
 public ItemBase AddItem(ItemBase item, int amount = 1)
 {
     return(ItemBaseUtil.AddListItem(item, ref this.Inventory, true, this.StorageCapacity));
 }
Esempio n. 4
0
 /// <summary>
 ///     Remove items from inventory if items are not on the blacklist
 /// </summary>
 /// <param name="items">The target inventory or list to store the items</param>
 /// <param name="blacklist">Item forbidden from transfer</param>
 /// <param name="storagecapacity">Storage capacity of target inventory</param>
 /// <param name="amount">Amount of items to move in this transfer</param>
 public void RemoveBlackList(ref List <ItemBase> items, ItemBase blacklist, int storagecapacity = int.MaxValue, int amount = 1)
 {
     ItemBase[] BlackList = new[] { blacklist };
     ItemBaseUtil.MoveItems(ref this.Inventory, ref items, amount, storagecapacity, false, BlackList, false);
 }
Esempio n. 5
0
 /// <summary>
 ///     Remove items from inventory if items are not on the blacklist
 /// </summary>
 /// <param name="items">The target inventory or list to store the items</param>
 /// <param name="blacklist">The list of items forbidden from transfer</param>
 /// <param name="storagecapacity">Storage capacity of target inventory</param>
 /// <param name="amount">Amount of items to move in this transfer</param>
 public void RemoveBlackList(ref List <ItemBase> items, IEnumerable <ItemBase> blacklist, int storagecapacity = int.MaxValue, int amount = 1)
 {
     ItemBaseUtil.MoveItems(ref this.Inventory, ref items, amount, storagecapacity, false, blacklist, false);
 }
Esempio n. 6
0
 /// <summary>
 ///     Remove items from inventory if items are on the whitelist
 /// </summary>
 /// <param name="items">The target inventory or list to store the items</param>
 /// <param name="whitelist">Item allowed to transfer</param>
 /// <param name="storagecapacity">Storage capacity of target inventory</param>
 /// <param name="amount">Amount of items to move in this transfer</param>
 public void RemoveWhiteList(ref List <ItemBase> items, ItemBase whitelist, int storagecapacity = int.MaxValue, int amount = 1)
 {
     ItemBase[] WhiteList = new [] { whitelist };
     ItemBaseUtil.MoveItems(ref this.Inventory, ref items, amount, storagecapacity, false, WhiteList, true);
 }
Esempio n. 7
0
 /// <summary>
 ///     Transfers items to machine inventory if they are not on the provided blacklist
 /// </summary>
 /// <param name="items">Source inventory or list of items</param>
 /// <param name="blacklist">Item forbidden from transfer</param>
 /// <param name="amount">Number of items to add</param>
 public void AddBlackList(ref List <ItemBase> items, ItemBase blacklist, int amount = 1)
 {
     ItemBase[] BlackList = new[] { blacklist };
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, amount, this.StorageCapacity, false, BlackList, false);
 }
Esempio n. 8
0
 /// <summary>
 ///     Empty the inventory of items
 /// </summary>
 /// <param name="items">Target inventory or list</param>
 /// <param name="amount">Maximum number of items to take</param>
 public void Empty(ref List <ItemBase> items, int amount)
 {
     ItemBaseUtil.MoveItems(ref this.Inventory, ref items, amount);
 }
Esempio n. 9
0
 /// <summary>
 ///     Return item from inventory by example (obeys stack size)
 /// </summary>
 /// <param name="item">Example item to find in inventory</param>
 /// <returns>Returns the item or null if unavailable or insufficient stack size</returns>
 public ItemBase RemoveItem(ItemBase item)
 {
     return(ItemBaseUtil.RemoveListItem(item, ref this.Inventory, false));
 }
Esempio n. 10
0
 /// <summary>
 ///     Fills the inventory to capacity with source items
 /// </summary>
 /// <param name="items">Source items to fill the inventory</param>
 /// <param name="blacklist">Item forbidden from transfer</param>
 public void FillBlackList(ref List <ItemBase> items, IEnumerable <ItemBase> blacklist)
 {
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, this.SpareCapacity(), this.StorageCapacity, false, blacklist, false);
 }
Esempio n. 11
0
 /// <summary>
 ///     Fills the inventory to capacity with source items
 /// </summary>
 /// <param name="items">Source items to fill the inventory</param>
 /// <param name="blacklist">Item forbidden from transfer</param>
 public void FillBlackList(ref List <ItemBase> items, ItemBase blacklist)
 {
     ItemBase[] BlackList = new[] { blacklist };
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, this.SpareCapacity(), this.StorageCapacity, false, BlackList, false);
 }
Esempio n. 12
0
 /// <summary>
 ///     Fills the inventory to capacity with source items
 /// </summary>
 /// <param name="items">Source items to fill the inventory</param>
 /// <param name="whitelist">Item type allowed in the transfer</param>
 public void FillWhiteList(ref List <ItemBase> items, ItemBase whitelist)
 {
     ItemBase[] WhiteList = new[] { whitelist };
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, this.SpareCapacity(), this.StorageCapacity, false, WhiteList, true);
 }
Esempio n. 13
0
 /// <summary>
 ///     Fills the inventory to capacity with source items
 /// </summary>
 /// <param name="items">Source items to fill the inventory</param>
 /// <param name="whitelist">Item type allowed in the transfer</param>
 public void FillWhiteList(ref List <ItemBase> items, IEnumerable <ItemBase> whitelist)
 {
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, this.SpareCapacity(), this.StorageCapacity, false, whitelist, true);
 }
Esempio n. 14
0
 /// <summary>
 ///     Fills the inventory to capacity with source items
 /// </summary>
 /// <param name="items">Source items to fill the inventory</param>
 public void Fill(ref List <ItemBase> items)
 {
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, this.SpareCapacity(), this.StorageCapacity);
 }
Esempio n. 15
0
 /// <summary>
 ///     Transfers items to machine inventory if they are on the provided whitelist
 /// </summary>
 /// <param name="items">Source inventory or list of items</param>
 /// <param name="whitelist">List of items types allowed in the transfer</param>
 /// <param name="amount">Number of items to add</param>
 public void AddWhiteList(ref List <ItemBase> items, IEnumerable <ItemBase> whitelist, int amount = 1)
 {
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, amount, this.StorageCapacity, false, whitelist, true);
 }
Esempio n. 16
0
 /// <summary>
 ///     Return item from inventory by example including partial item stack
 /// </summary>
 /// <param name="item">Example item to find in inventory</param>
 /// <returns>Returns the item or partial stack (null if item not found)</returns>
 public ItemBase RemovePartialStack(ItemBase item)
 {
     return(ItemBaseUtil.RemoveListItem(item, ref this.Inventory, true));
 }
Esempio n. 17
0
 /// <summary>
 ///     Transfers items to machine inventory if they are on the provided whitelist
 /// </summary>
 /// <param name="items">Source inventory or list of items</param>
 /// <param name="whitelist">Item type allowed in the transfer</param>
 /// <param name="amount">Number of items to add</param>
 public void AddWhiteList(ref List <ItemBase> items, ItemBase whitelist, int amount = 1)
 {
     ItemBase[] WhiteList = new[] { whitelist };
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, amount, this.StorageCapacity, false, WhiteList, true);
 }
Esempio n. 18
0
 /// <summary>
 ///     Transfers items to machine inventory if they are not on the provided blacklist
 /// </summary>
 /// <param name="items">Source inventory or list of items</param>
 /// <param name="blacklist">List of items forbidden from transfer</param>
 /// <param name="amount">Number of items to add</param>
 public void AddBlackList(ref List <ItemBase> items, IEnumerable <ItemBase> blacklist, int amount = 1)
 {
     ItemBaseUtil.MoveItems(ref items, ref this.Inventory, amount, this.StorageCapacity, false, blacklist, false);
 }