Economy #

Read more about the Economy system in Hiro here.

Initializing the economy system #

The economy system relies on the Nakama System and an ILogger, both must be passed in as dependencies via the constructor. You must also specify which EconomyStoreType you wish to work with.

1
2
var economySystem = new EconomySystem(logger, nakamaSystem, EconomyStoreType.AppleAppstore);
systems.Add(economySystem);

Subscribing to changes in the economy system #

You can listen for changes in the economy system so that you can respond appropriately, such as updating the UI, by implementing the IObserver pattern, or use the SystemObserver<T> type which handles it for you.

1
2
3
4
5
var disposer = SystemObserver<EconomySystem>.Create(economySystem, system => {
    Instance.Logger.Info($"System updated.");

    // Update UI elements etc as necessary here...
});

Refreshing the economy system #

To ensure the economy system has the latest information from Nakama you can refresh it.

1
await economySystem.RefreshAsync();