Predict general interactions. (#6856)

This commit is contained in:
Leon Friedrich
2022-03-09 20:12:17 +13:00
committed by GitHub
parent 60e7ef6073
commit 0f435f31c8
10 changed files with 283 additions and 256 deletions

View File

@@ -1,3 +1,5 @@
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
@@ -17,11 +19,26 @@ namespace Content.Shared.Item
SubscribeLocalEvent<SharedSpriteComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<SharedSpriteComponent, GotUnequippedEvent>(OnUnequipped);
SubscribeLocalEvent<SharedItemComponent, InteractHandEvent>(OnHandInteract);
SubscribeLocalEvent<SharedItemComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<SharedItemComponent, ComponentHandleState>(OnHandleState);
}
private void OnHandInteract(EntityUid uid, SharedItemComponent component, InteractHandEvent args)
{
if (args.Handled)
return;
if (!TryComp(args.User, out SharedHandsComponent? hands))
return;
if (hands.ActiveHand == null)
return;
args.Handled = hands.TryPickupEntity(hands.ActiveHand, uid, false, animateUser: false);
}
private void OnHandleState(EntityUid uid, SharedItemComponent component, ref ComponentHandleState args)
{
if (args.Current is not ItemComponentState state)