PurchasedList
A class in Root.Township, Alta.Customization.
Which cosmetic hashes the local player owns or can pick, built from default cosmetics, the shop API's owned items and developer items. The owned and available sets are static, so every instance shares them. Does nothing on a dedicated server.
- Listed in Customization and screenshots
Constructors
| Member | What it is |
|---|---|
PurchasedList(int playerIdentifier, PlayerSubscriberStatus status) | Creates a PurchasedList from player. |
PurchasedList(Player player) | Creates a PurchasedList from player. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private static HashSet<uint> available | Static set of item hashes the player can use, owned or not. |
private static Logger logger | NLog logger for this class. |
private static HashSet<uint> owned | Static set of item hashes the player owns. Shared by every PurchasedList, not per player. |
private static IEnumerable<OwnedShopItem> ownedItems | Cached owned shop items from the API. |
private static PurchasedList personal | The local player's list, reused between calls. |
private int playerId | The player's user ID. |
private PlayerSubscriberStatus status | The player's subscriber status, used to grant developer items. |
Properties
| Member | What it is |
|---|---|
static HashSet<uint> CurrentOnStore { get; } | Hashes of items in the current shop rotation, with sets expanded to their contents. |
static Dictionary<uint, uint> CurrentRotationToSets { get; } | Maps each item hash in the shop rotation to the store item (set or single) it came from. |
static HashSet<uint> OwnedByAll { get; private set; } | Default cosmetics everyone owns, from CustomizationSettings. Null until the first refresh. |
Events
| Member | What it is |
|---|---|
static event Action OwnedUpdated | Raised after developer items are added, for players with Developer status. |
Methods
| Member | What it is |
|---|---|
async Task AddCurrentRotation() | Fetches the current shop rotation and marks every item in it as available. |
static void BuyItem(uint hash) | Marks an item (and every item in its set) as owned and clears the cached owned list so the next refresh asks the API again. |
static async Task<PurchasedList> GetForPlayer(Player player) | Returns a refreshed list for a player. The local player's list is cached and reused. |
static async Task<PurchasedList> GetForPlayer(int playerIdentifier, bool isLocalPlayer, PlayerSubscriberStatus status) | Returns a refreshed list for a player. The local player's list is cached and reused. |
static bool IsAvailable(uint item) | True if the item is owned or available to pick. |
static bool IsOwned(uint item) | True if the item is in the static owned set. |
IEnumerable<uint> LoadAllAvailable(Func<uint, bool> filter) (iterator) | Every available hash that passes the filter. |
IEnumerable<uint> LoadAllOwned(Func<uint, bool> filter) (iterator) | Every owned hash that passes the filter. |
async Task Refresh() | Client or local test only: rebuilds the owned and available sets, fetching owned items from the shop API if not cached. |
static async Task UpdateCurrentRotation() | Fetches the current shop configuration and rebuilds CurrentOnStore. Clears it on error. |
static Task<bool> ValidatePlayersOwnedItems(Player player, IEnumerable<uint> items) | Meant to check a player owns the given items. Always returns true in this build. |
8 private and internal methods
| Member | What it is |
|---|---|
private static void AddItems(ShopItemConfiguration[] items) | Adds store items to the current rotation, expanding sets into their items. |
private static void ClearAvailableHashes() | Resets the available set to the items everyone owns. |
private static void ClearPurchasedHashes() | Resets the owned set to the items everyone owns. |
private static void Initialize() | On first use, fills OwnedByAll from the default cosmetics. |
private static void InvalidateCache() | Drops the cached owned items so the next refresh fetches them again. |
private static async Task RefreshOwnedItemsCache() | Fetches the account's owned shop items from the API. |
private void UpdateDeveloperItems() | For developers, adds the developer-only items to owned and available. |
private static void UpdateOwnedItems() | Adds the cached owned shop items to owned and available. |
Used in
Members of other types that take, return or hold a PurchasedList: