예제 #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]);
        }
예제 #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);
 }
예제 #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));
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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));
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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));
 }
예제 #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);
 }
예제 #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);
 }