Skip to main content

Rarity

A class in Root.Township, Alta.Loot.

A loot rarity asset with a weighting. All rarities load from Resources/Items/Rarities, and loot tables pick one at random.

Constructors​

MemberWhat it is
Rarity()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

3 private and internal fields
MemberWhat it is
private static Rarity[] allRaritiesEvery rarity in Resources/Items/Rarities, loaded on the first GetRandom call.
private OriginSingleValue[] originWeightingsWeight of each origin for loot of this rarity. Exposed as OriginWeightings.
private float weightingHow likely this rarity is picked relative to others. Exposed as Weighting.

Properties​

MemberWhat it is
OriginSingleValue[] OriginWeightings { get; }Weightings used to pick an Origin for loot of this rarity.
float Weighting { get; }Base weighting (default 1).

Methods​

MemberWhat it is
static Rarity GetRandom(float weightingPower, List<Rarity> ignore)Weighted pick from all rarities not in ignore. The running total is raised to weightingPower before comparing, which favours rarities earlier in the list as it grows.

Used in​

Members of other types that take, return or hold a Rarity: