Files
RobustToolbox/Robust.Client/GameObjects/EntitySystems/UserInterfaceSystem.cs
metalgearsloth 176ca6c578 Add window helper for BUIs (#5183)
* Add window helper for BUIs

Automatically does OnClose and just makes content slightly nicer.

* more

* Add prototype reload helper

* Add Box2i Center

* weh
2024-07-20 14:50:15 +10:00

39 lines
937 B
C#

using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
namespace Robust.Client.GameObjects;
public sealed class UserInterfaceSystem : SharedUserInterfaceSystem
{
public override void Initialize()
{
base.Initialize();
ProtoManager.PrototypesReloaded += OnProtoReload;
}
public override void Shutdown()
{
base.Shutdown();
ProtoManager.PrototypesReloaded -= OnProtoReload;
}
private void OnProtoReload(PrototypesReloadedEventArgs obj)
{
var player = Player.LocalEntity;
if (!UserQuery.TryComp(player, out var userComp))
return;
foreach (var uid in userComp.OpenInterfaces.Keys)
{
if (!UIQuery.TryComp(uid, out var uiComp))
continue;
foreach (var bui in uiComp.ClientOpenInterfaces.Values)
{
bui.OnProtoReload(obj);
}
}
}
}