Click or drag to resize

BagT Class

A generic class that holds how much of a particular item you carry. Can be used to create things like Inventories or Wallets.
Inheritance Hierarchy
SystemObject
  System.Collections.GenericDictionaryT, Int32
    Kit.ContainersBagT

Namespace:  Kit.Containers
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0
Syntax
C#
public class Bag<T> : Dictionary<T, int>
Request Example View Source

Type Parameters

T
Base type of items.

The BagT type exposes the following members.

Constructors
  NameDescription
Public methodBagT
Initializes a new instance of the BagT class
Top
Properties
  NameDescription
Public propertyItem
Returns the current amount of an item.
Top
Methods
  NameDescription
Public methodAdd(IDictionaryT, Int32)
Adds the amount of items from another dictionary.
Public methodAdd(KeyValuePairT, Int32)
Adds the amount of items.
Public methodAdd(BunchT)
Adds the amount of items.
Public methodAdd(T, Int32)
Adds the amount of items.
Public methodAsBunches
Convert the dictionary to a enumerable of Bunches.
Public methodContains(IDictionaryT, Int32)
Returns whether it contains the specified amounts of items.
Public methodContains(KeyValuePairT, Int32)
Returns whether it contains the specified amount of an item.
Public methodContains(BunchT)
Returns whether it contains the specified amount of an item.
Public methodContains(T, Int32)
Returns whether it contains the specified amount of an item.
Public methodRemove(IDictionaryT, Int32)
Removes the amount of items from another dictionary.
Public methodRemove(KeyValuePairT, Int32)
Removes the amount of items.
Public methodRemove(BunchT)
Removes the amount of items.
Public methodRemove(T, Int32)
Removes the amount of items.
Public methodRemoveAll(IEnumerableT)
Sets the amount of specified items to 0.
Public methodRemoveAll(T)
Sets the amount of specified items to 0.
Public methodToBunches
Convert the dictionary to a List of Bunches.
Top
Events
  NameDescription
Public eventAdded
Event called whenever a new item is added.
Public eventChanged
Event called whenever an item's amount is changed.
Public eventRemoved
Event called whenever an item is removed.
Top
Operators
  NameDescription
Public operatorStatic memberAddition(BagT, BunchT)
Add an item to the bag.
Public operatorStatic memberAddition(BagT, IDictionaryT, Int32)
Add items to the bag.
Public operatorStatic memberAddition(BagT, KeyValuePairT, Int32)
Add an item to the bag.
Public operatorStatic memberAddition(BagT, T)
Add an item to the bag.
Public operatorStatic memberSubtraction(BagT, BunchT)
Remove an item from the bag.
Public operatorStatic memberSubtraction(BagT, IDictionaryT, Int32)
Remove items from the bag.
Public operatorStatic memberSubtraction(BagT, KeyValuePairT, Int32)
Remove an item from the bag.
Public operatorStatic memberSubtraction(BagT, T)
Remove an item from the bag.
Top
Fields
  NameDescription
Public fieldMax
A function that should return the maximum amount of items of a particular type can be there. The amounts will be capped to this function's values if specified. Ignored if .
Top
Remarks
To create nested inventories, create a Bag<Bag<T>>. To create inventories that can have nested and non-nested items, create a Bag<object>.
Examples
Bag<Currency> wallet = new Bag<Currency>();
Bunch<Currency> cost = new Bunch<Currency>(Currency.Diamonds, 10);
wallet[Currency.Diamonds] = 50;
wallet[Currency.Coins] = 25;
wallet -= cost;
See Also