Skip to content

GodotWeightedPoolExtensions

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 Godot’s global random number generator, which GD.Seed affects.

public static class GodotWeightedPoolExtensions

Inheritance Object → GodotWeightedPoolExtensions

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