Convert StorageSystem comp messages into network events (#7351)

This commit is contained in:
mirrorcult
2022-03-30 16:23:20 -07:00
committed by GitHub
parent 5a35cecc50
commit 452d67c0b8
5 changed files with 176 additions and 167 deletions

View File

@@ -0,0 +1,49 @@
using Content.Shared.Storage;
namespace Content.Client.Storage;
// TODO kill this is all horrid.
public sealed class StorageSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<StorageHeldItemsEvent>(OnStorageHeldItems);
SubscribeNetworkEvent<OpenStorageUIEvent>(OnOpenStorageUI);
SubscribeNetworkEvent<CloseStorageUIEvent>(OnCloseStorageUI);
SubscribeNetworkEvent<AnimateInsertingEntitiesEvent>(OnAnimateInsertingEntities);
}
private void OnStorageHeldItems(StorageHeldItemsEvent ev)
{
if (TryComp<ClientStorageComponent>(ev.Storage, out var storage))
{
storage.HandleStorageMessage(ev);
}
}
private void OnOpenStorageUI(OpenStorageUIEvent ev)
{
if (TryComp<ClientStorageComponent>(ev.Storage, out var storage))
{
storage.ToggleUI();
}
}
private void OnCloseStorageUI(CloseStorageUIEvent ev)
{
if (TryComp<ClientStorageComponent>(ev.Storage, out var storage))
{
storage.CloseUI();
}
}
private void OnAnimateInsertingEntities(AnimateInsertingEntitiesEvent ev)
{
if (TryComp<ClientStorageComponent>(ev.Storage, out var storage))
{
storage.HandleAnimatingInsertingEntities(ev);
}
}
}