Skip to content

UnityWeightedPoolExtensions

Namespace: Shadop.Archmage.Sdk

Provides parameterless Sample and SampleIndex extension methods that draw an item from a WeightedPool at random with probability proportional to its weight, using Unity’s global UnityEngine.Random.

public static class UnityWeightedPoolExtensions

Inheritance Object → UnityWeightedPoolExtensions

Returns a randomly selected item, weighted by the pool’s weights. Throws if the pool is empty or the total weight is zero.

public static T Sample<T>(WeightedPool<T> wp)

wp WeightedPool

T

Returns the index of a randomly selected item, weighted by the pool’s weights. Throws if the pool is empty or the total weight is zero.

public static int SampleIndex<T>(WeightedPool<T> wp)

wp WeightedPool

Int32