Predict vending machine BUI (#32376)

This commit is contained in:
metalgearsloth
2024-09-23 12:10:22 +10:00
committed by GitHub
parent 5e162e776d
commit dd7884ed40
7 changed files with 30 additions and 72 deletions

View File

@@ -23,29 +23,17 @@ namespace Content.Client.VendingMachines
{
base.Open();
var vendingMachineSys = EntMan.System<VendingMachineSystem>();
_cachedInventory = vendingMachineSys.GetAllInventory(Owner);
_menu = this.CreateWindow<VendingMachineMenu>();
_menu.OpenCenteredLeft();
_menu.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
_menu.OnItemSelected += OnItemSelected;
_menu.Populate(_cachedInventory);
_menu.OpenCenteredLeft();
Refresh();
}
protected override void UpdateState(BoundUserInterfaceState state)
public void Refresh()
{
base.UpdateState(state);
if (state is not VendingMachineInterfaceState newState)
return;
_cachedInventory = newState.Inventory;
var system = EntMan.System<VendingMachineSystem>();
_cachedInventory = system.GetAllInventory(Owner);
_menu?.Populate(_cachedInventory);
}