Beispiel #1
0
    /// <summary>
    ///     Removes the contents of a hand from its container. Assumes that the removal is allowed. In general, you should not be calling this directly.
    /// </summary>
    public virtual void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, SharedHandsComponent?handsComp = null)
    {
        if (!Resolve(uid, ref handsComp))
        {
            return;
        }

        if (hand.Container?.ContainedEntity == null)
        {
            return;
        }

        var entity = hand.Container.ContainedEntity.Value;

        if (!hand.Container !.Remove(entity, EntityManager))
        {
            Logger.Error($"{nameof(SharedHandsComponent)} on {uid} could not remove {entity} from {hand.Container}.");
            return;
        }

        Dirty(handsComp);

        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);

        if (hand == handsComp.ActiveHand)
        {
            RaiseLocalEvent(entity, new HandDeselectedEvent(uid), false);
        }
    }
Beispiel #2
0
 private void OnUnequip(EntityUid uid, BlockingComponent component, GotUnequippedHandEvent args)
 {
     BlockingShutdownHelper(uid, component, args.User);
 }