UnityWeightedPoolExtensions
Namespace: Shadop.Archmage.Sdk
Extension methods for WeightedPool<T>.
public static class UnityWeightedPoolExtensionsInheritance Object → UnityWeightedPoolExtensions
Methods
Section titled “Methods”Sample<T>(WeightedPool<T>)
Section titled “Sample<T>(WeightedPool<T>)”Returns a randomly selected item, with each item’s probability proportional to its weight. Uses Unity’s global UnityEngine.Random.
Throws if the pool is empty or the total weight is zero.
public static T Sample<T>(this WeightedPool<T> wp)Returns
Section titled “Returns”T
The randomly selected item.
SampleIndex<T>(WeightedPool<T>)
Section titled “SampleIndex<T>(WeightedPool<T>)”Returns the index of a randomly selected item, with each item’s probability proportional to its weight. Uses Unity’s global UnityEngine.Random.
Throws if the pool is empty or the total weight is zero.
public static int SampleIndex<T>(this WeightedPool<T> wp)Returns
Section titled “Returns”Int32
The zero-based index of the randomly selected item.