Skip to main content

PlayerCosmeticCategory

A class in Root.Township, Alta.Customization.

A category of player cosmetics (a slot such as a hat or shirt), loaded from Resources/Cosmetic Categories. Picks random items for random outfits.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private static PlayerCosmeticCategory[] allCategoriesBacking field for AllCategories. Reloaded every time in the editor.
private const string CategoriesFolderResources folder the categories load from: "Cosmetic Categories".
private float flatNullChanceChance that a random pick returns nothing for this category.
private float nullElementWeightWeight of "nothing" against the item count in random picks.

Properties​

MemberWhat it is
static PlayerCosmeticCategory[] AllCategories { get; }Every active category, sorted by priority. Loaded once, or every time in the editor.

Methods​

MemberWhat it is
override uint GetRandom(ICollection<uint> items, bool canUseNonOwnedItems)Picks a random item, or none by the category's null chances. The ID version only picks owned items, or available ones if allowed.
override ICustomizationDefinition GetRandom(ICollection<ICustomizationDefinition> items)Picks a random item, or none by the category's null chances. The ID version only picks owned items, or available ones if allowed.
1 private and internal method
MemberWhat it is
private static void LoadAllCategories()Loads every active category from Resources, sorted by priority, into allCategories.

Used in​

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