mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using JetBrains.Annotations;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Robust.Client.GameObjects
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class UserInterfaceSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeNetworkEvent<BoundUIWrapMessage>(MessageReceived);
|
|
SubscribeLocalEvent<ClientUserInterfaceComponent, ComponentShutdown>(OnUserInterfaceShutdown);
|
|
}
|
|
|
|
private void OnUserInterfaceShutdown(EntityUid uid, ClientUserInterfaceComponent component, ComponentShutdown args)
|
|
{
|
|
foreach (var bui in component.Interfaces)
|
|
{
|
|
bui.Dispose();
|
|
}
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
|
|
UnsubscribeNetworkEvent<BoundUIWrapMessage>();
|
|
UnsubscribeLocalEvent<ClientUserInterfaceComponent, ComponentShutdown>();
|
|
}
|
|
|
|
private void MessageReceived(BoundUIWrapMessage ev)
|
|
{
|
|
var cmp = ComponentManager.GetComponent<ClientUserInterfaceComponent>(ev.Entity);
|
|
|
|
cmp.MessageReceived(ev);
|
|
}
|
|
|
|
internal void Send(BoundUIWrapMessage msg)
|
|
{
|
|
RaiseNetworkEvent(msg);
|
|
}
|
|
}
|
|
}
|