You can listen for changes in the energy 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
vardisposer=SystemObserver<EnergiesSystem>.Create(energiesSystem,system=>{Instance.Logger.Info($"System updated.");// Update UI elements etc as necessary here...});
You can spend energy as a user, either as a single energy at a time or as multiple at once.
1
2
3
4
5
6
7
8
9
// Spend a single energyawaitenergiesSystem.SpendEnergyAsync("lives",1);// Spend multiple energiesawaitenergiesSystem.SpendEnergyAsync(newDictionary<string,int>{{"lives",1},{"hearts",5}});