Skip to main content

IAPViewModel

A class in Root.Township, Features.Main_Menu.Scripts.TalemShop.

Client talem shop panel for Quest: shows the talem balance and buys talem packs through InterfaceResolver.IShopController. Hidden on Windows and Pico, and when logged out.

Constructors​

MemberWhat it is
IAPViewModel()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

6 private and internal fields
MemberWhat it is
private TextRenderer currentTalemsTextText showing the talem balance.
private TextRenderer errorOutputText showing purchase errors.
private bool isProcessingTrue while a purchase is in progress.
private GameObject loadingMarkerObject shown while a purchase is in progress.
private static readonly Logger loggerNLog logger for this class.
private UnityEvent onPurchaseSucceededEvent fired after a purchase is made and consumed.

Methods​

MemberWhat it is
async void PurchaseTalems(string sku)Buys the talem pack with the given SKU, showing the loading marker; ignored while a purchase is running.
protected override async void LoggedIn()Hides itself on Windows; otherwise sets up the balance and, on a Quest build, shows only if the Oculus entitlement check passes.
protected override void LoggedOut()Hides the panel.
protected override void OnDestroy()Unhooks the balance change event.
protected override void Start()Hides the error text, and hides the whole panel on Windows or Pico.
6 private and internal methods
MemberWhat it is
private void HandleError(PurchaseError error)Shows a purchase error's message.
private async Task MakePurchase(string sku)Buys the SKU, consumes it if that worked, shows any error, then asks for a fresh balance.
private void OutputError(string error, bool isLoggingInGame = true)Logs the error and, by default, shows it in red on the panel.
private void PurchaseMade(bool wasSuccessful)Fires onPurchaseSucceeded if the purchase was consumed, otherwise shows an error.
private void Setup()Shows the current balance and keeps it updated from CurrentTalemBalance.
private void UpdateBalance(int newBalance)Writes the balance into currentTalemsText.