Predict general interactions. (#6856)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user