TopDown Engine
v4.2
|
A class to use to get more controlled randomness, taking values out of the bag randomly, and never getting them again. More...
Public Member Functions | |
MMShufflebag (int initialCapacity) | |
Initializes the shufflebag More... | |
virtual void | Add (T item, int quantity) |
Adds the specified quantity of the item to the bag More... | |
T | Pick () |
Returns a random item from the bag More... | |
Protected Attributes | |
List< T > | _contents |
T | _currentItem |
int | _currentIndex = -1 |
Properties | |
virtual int | Capacity [get] |
virtual int | Size [get] |
A class to use to get more controlled randomness, taking values out of the bag randomly, and never getting them again.
Usage :
var shuffleBag = new ShuffleBag(40); for (int i = 0; i<40; i++) { newValue = something; shuffleBag.Add(newValue, amount); }
then : float something = shuffleBag.Pick();
MoreMountains.Tools.MMShufflebag< T >.MMShufflebag | ( | int | initialCapacity | ) |
Initializes the shufflebag
initialCapacity |
|
virtual |
Adds the specified quantity of the item to the bag
item | |
quantity |
T MoreMountains.Tools.MMShufflebag< T >.Pick | ( | ) |
Returns a random item from the bag
|
protected |
|
protected |
|
protected |
|
get |
|
get |