public static Vector2 NextVector2(this RNG rng) { return(new Vector2(rng.NextFloat1(), rng.NextFloat1())); }
/// <summary>Randomly select one item.</summary> /// <param name="rng">The RNG.</param> /// <returns>Index of the selected item.</returns> public int Select(RNG rng) { int sample = GetSample(rng); return(Select(sample)); }
/// <summary>Randomly select one item.</summary> /// <param name="rng">The RNG.</param> /// <returns>Selected item.</returns> public T SelectItem(RNG rng) { int index = Select(rng); return(Items[index]); }
protected int GetSample(RNG rng) { // must be 1-based sample return(rng.NextIntRange(TotalWeights) + 1); }