Skip to main content

CosmeticOwnershipManager

A class in Root.Township, Alta.Customization.

Which cosmetics a player has bought, owns and may pick from, by category. Get one with the async LoadFor.

Constructors​

1 private and internal constructor
MemberWhat it is
private CosmeticOwnershipManager(PlayerCharacterCustomizationManager manager, PurchasedList purchasedList)Creates a CosmeticOwnershipManager from manager and purchasedList.

Fields​

6 private and internal fields
MemberWhat it is
private readonly Dictionary<PlayerCosmeticCategory, HashSet<uint>> availableBacking field for Available.
private static readonly Logger loggerNLog logger for this class.
private readonly PlayerCharacterCustomizationManager managerThe player's customization manager.
private readonly Dictionary<PlayerCosmeticCategory, HashSet<uint>> ownedBacking field for Owned.
private readonly List<uint> purchasedBacking field for Purchased.
private TaskCompletionSource<bool> randomizeTask for the randomize in progress, so a second call waits for it instead.

Properties​

MemberWhat it is
IReadOnlyDictionary<PlayerCosmeticCategory, HashSet<uint>> Available { get; }Cosmetic IDs the player can choose from per category: owned ones plus ones made available without buying.
IReadOnlyDictionary<PlayerCosmeticCategory, HashSet<uint>> Owned { get; }Cosmetic IDs the player owns per category, including items from the current store rotation.
IReadOnlyCollection<uint> Purchased { get; }Every purchased cosmetic ID (only purchasables that are cosmetics).

Methods​

MemberWhat it is
ICollection<uint> GetCategoryOptions(PlayerCosmeticCategory category)Returns the available cosmetic IDs for one category.
List<uint> GetPurchases()Returns the list of purchased cosmetic IDs.
static async Task<CosmeticOwnershipManager> LoadFor(Player player)Loads a player's or user ID's purchases and builds a manager, adding the current store rotation for the local player. The user ID overload returns null on failure.
static async Task<CosmeticOwnershipManager> LoadFor(int userId, bool isLocalPlayer, PlayerSubscriberStatus status, PlayerCharacterCustomizationManager manager)Loads a player's or user ID's purchases and builds a manager, adding the current store rotation for the local player. The user ID overload returns null on failure.
async Task Randomize(bool canUseNonOwned)Replaces the character's cosmetics with a random pick per category, from owned items or all available ones. Concurrent calls wait for the running one.
async Task Randomize(PlayerCosmeticWrapper cosmeticWrapper, bool canUseNonOwned)Replaces the character's cosmetics with a random pick per category, from owned items or all available ones. Concurrent calls wait for the running one.
async Task RefreshStore()Removes the old store rotation's items, fetches the current rotation and adds its items (expanding sets) as owned.
2 private and internal methods
MemberWhat it is
private void AddItem(uint purchasable)Adds a cosmetic to purchased and owned if it is a cosmetic definition.
private bool WasDestroyed()True if any customization handler has been destroyed, so randomizing stops.

Used in​

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