ProbabilityItem<T>

ProbabilityItem<T> represents a single entry inside a ProbabilityList<T>. It stores the value itself plus the state and metadata that control how that item behaves during selection.

What this type is responsible for

A ProbabilityItem<T> can hold:

  • the value itself
  • base probability
  • enabled / locked state
  • weight
  • influence provider settings
  • depletion state and unit counts
  • provider-interface capabilities discovered from the value type

Core item data

Core properties

PROPERTYValue
T

The value stored by this item.

PROPERTYBaseProbability
float

The stored baseline probability, clamped between 0 and 1.

PROPERTYProbability
float

The effective probability currently used during selection. If the item is influenced, this value is derived from BaseProbability, spread settings, and current influence.

PROPERTYEnabled
bool

Determines whether the item is eligible for selection.

PROPERTYLocked
bool

Prevents certain list-level probability operations from changing this item's base probability.

PROPERTYWeight
int

Weight representation used by weight-based list helpers.


Influence support

Influence properties

PROPERTYInfluenceSpread
Vector2

The allowed low/high probability range when influence is applied.

PROPERTYInvertInfluence
bool

Reverses the effect of the incoming influence value.

PROPERTYInfluenceProvider
IProbabilityInfluenceProvider

External provider used to influence this item, unless the value itself already implements the influence-provider interface.

PROPERTYValueIsInfluenceProvider
bool

Returns true when the stored value itself implements IProbabilityInfluenceProvider.

PROPERTYIsInfluencedItem
bool

Returns true when the item is currently influenced by either an external provider or the value itself.

METHODGetInfluencedProbability
float GetInfluencedProbability(float influence)

Calculates the resulting probability for a specific influence value.

Important behavior

If the stored value implements IProbabilityInfluenceProvider, RNGNeeds prefers that provider over an externally assigned one. That makes it possible for a value object to supply its own influence directly.

For the conceptual guide and examples, see Probability Influence.


Depletion and selectability

Depletable item properties

PROPERTYIsDepletable
bool

When true, picks consume units from this item while the parent list is depletable.

PROPERTYUnits
int

Current number of units remaining.

PROPERTYMaxUnits
int

Maximum units available after refill.

PROPERTYIsDepleted
bool

Returns true when the item is depletable and has no units left.

PROPERTYIsSelectable
bool

Returns true when the item is currently eligible for selection, taking enabled state and depletion into account.

METHODRefill
void Refill()

Sets Units back to MaxUnits.

METHODSetDepletable
void SetDepletable(bool depletable = true, int units = 1, int maxUnits = 1)

Configures depletion state and unit counts together.


Provider capability discovery

Provider-interface helpers

METHODGetProviderTypes
ItemProviderType GetProviderTypes()

Inspects the value and reports which provider interfaces it implements.

INTERFACEIProbabilityInfluenceProvider

Lets a value or external object supply a live influence value that changes the item's effective probability.

INTERFACEIProbabilityItemInfoProvider

Lets a value provide extra item info for the editor UI.

INTERFACEIProbabilityItemColorProvider

Lets a value provide custom coloring for the editor UI.


Typical setup

var item = new ProbabilityItem<string>("Rare Gem", 0.2f);
item.Enabled = true;
item.Locked = false;
item.SetDepletable(true, units: 3, maxUnits: 3);