@inject IJSRuntime jsRuntime; @inject IEconomyService economyService @implements IDisposable @BuildOrderService.GetLastRequestInterval() | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval())
@economy.Alloy @economy.Ether
@economy.Pyre @supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : ""))
@code { [Inject] IBuildOrderService BuildOrderService { get; set; } = default!; [Inject] IEconomyService EconomyService { get; set; } = default!; EconomyModel economy = new(); int supplyGranted; int supplyTaken; int extraBuildings; protected override void OnInitialized() { BuildOrderService.Subscribe(OnBuildOrderChanged); } protected override bool ShouldRender() { #if DEBUG jsRuntime.InvokeVoidAsync("console.time", "BankComponent"); #endif return true; } protected override void OnAfterRender(bool firstRender) { #if DEBUG jsRuntime.InvokeVoidAsync("console.timeEnd", "BankComponent"); #endif } void IDisposable.Dispose() { BuildOrderService.Unsubscribe(OnBuildOrderChanged); } void OnBuildOrderChanged() { Console.WriteLine("OnBuildOrderChanged()"); economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval()); var ordersOverTime = BuildOrderService.GetOrders(); supplyTaken = (from ordersAtInterval in ordersOverTime from order in ordersAtInterval.Value where order.Supply() != null where order.Supply().Takes > 0 select order.Supply().Takes).Sum(); supplyGranted = (from ordersAtInterval in ordersOverTime from order in ordersAtInterval.Value where order.Supply() != null where order.Supply().Grants > 0 select order.Supply().Grants).Sum(); extraBuildings = 0; if (supplyGranted > 160) { extraBuildings = (supplyGranted - 160) / 16; supplyGranted = 160; } StateHasChanged(); } }