Implement SmartFridge functionality (#38648)

* Add SmartFridge

* my nit so pick

* my access so expanded and my whitelist so both

* list -> hashset
This commit is contained in:
pathetic meowmeow
2025-07-20 23:21:28 -04:00
committed by GitHub
parent 99b431cafd
commit d2ddbcbcda
17 changed files with 719 additions and 71 deletions

View File

@@ -0,0 +1,43 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.SmartFridge;
using Robust.Client.UserInterface;
using Robust.Shared.Input;
namespace Content.Client.SmartFridge;
public sealed class SmartFridgeBoundUserInterface : BoundUserInterface
{
private SmartFridgeMenu? _menu;
public SmartFridgeBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = this.CreateWindow<SmartFridgeMenu>();
_menu.OnItemSelected += OnItemSelected;
Refresh();
}
public void Refresh()
{
if (_menu is not {} menu || !EntMan.TryGetComponent(Owner, out SmartFridgeComponent? fridge))
return;
menu.SetFlavorText(Loc.GetString(fridge.FlavorText));
menu.Populate((Owner, fridge));
}
private void OnItemSelected(GUIBoundKeyEventArgs args, ListData data)
{
if (args.Function != EngineKeyFunctions.UIClick)
return;
if (data is not SmartFridgeListData entry)
return;
SendPredictedMessage(new SmartFridgeDispenseItemMessage(entry.Entry));
}
}