Raise hand (un)equipped events on container insert/remove (#15664)

This commit is contained in:
Menshin
2023-04-23 21:38:52 +02:00
committed by GitHub
parent 5272198729
commit c1ef48cee9
7 changed files with 56 additions and 33 deletions

View File

@@ -7,6 +7,25 @@ namespace Content.Shared.Hands.EntitySystems;
public abstract partial class SharedHandsSystem : EntitySystem
{
private void InitializeDrop()
{
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
}
protected virtual void HandleEntityRemoved(EntityUid uid, HandsComponent hands, EntRemovedFromContainerMessage args)
{
if (!TryGetHand(uid, args.Container.ID, out var hand))
{
return;
}
var gotUnequipped = new GotUnequippedHandEvent(uid, args.Entity, hand);
RaiseLocalEvent(args.Entity, gotUnequipped, false);
var didUnequip = new DidUnequipHandEvent(uid, args.Entity, hand);
RaiseLocalEvent(uid, didUnequip, false);
}
/// <summary>
/// Checks if the contents of a hand is able to be removed from its container.
/// </summary>
@@ -154,12 +173,6 @@ public abstract partial class SharedHandsSystem : EntitySystem
if (doDropInteraction)
_interactionSystem.DroppedInteraction(uid, entity);
var gotUnequipped = new GotUnequippedHandEvent(uid, entity, hand);
RaiseLocalEvent(entity, gotUnequipped, false);
var didUnequip = new DidUnequipHandEvent(uid, entity, hand);
RaiseLocalEvent(uid, didUnequip, true);
if (hand == handsComp.ActiveHand)
RaiseLocalEvent(entity, new HandDeselectedEvent(uid), false);
}