Files
OldThink/Content.Client/Inventory/ClientInventorySystem.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2021-06-09 22:19:39 +02:00
using Content.Client.HUD;
2019-07-20 13:11:42 +02:00
using Content.Shared.Input;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Input.Binding;
2019-07-20 13:11:42 +02:00
using Robust.Shared.IoC;
2021-06-09 22:19:39 +02:00
namespace Content.Client.Inventory
2019-07-20 13:11:42 +02:00
{
[UsedImplicitly]
2019-07-20 13:11:42 +02:00
public sealed class ClientInventorySystem : EntitySystem
{
[Dependency] private readonly IGameHud _gameHud = default!;
2019-07-20 13:11:42 +02:00
public override void Initialize()
{
base.Initialize();
CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenInventoryMenu,
InputCmdHandler.FromDelegate(_ => HandleOpenInventoryMenu()))
.Register<ClientInventorySystem>();
SubscribeLocalEvent<ClientInventoryComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
SubscribeLocalEvent<ClientInventoryComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
}
public override void Shutdown()
{
CommandBinds.Unregister<ClientInventorySystem>();
base.Shutdown();
2019-07-20 13:11:42 +02:00
}
private void HandleOpenInventoryMenu()
{
_gameHud.InventoryButtonDown = !_gameHud.InventoryButtonDown;
2019-07-20 13:11:42 +02:00
}
}
}