private void OnHandEquipped(EntityUid uid, ActionsComponent component, DidEquipHandEvent args) { var ev = new GetItemActionsEvent(); RaiseLocalEvent(args.Equipped, ev, false); if (ev.Actions.Count == 0) { return; } AddActions(args.User, ev.Actions, args.Equipped, component); }
/// <summary> /// Puts an entity into the player's hand, assumes that the insertion is allowed. In general, you should not be calling this function directly. /// </summary> public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, SharedHandsComponent?hands = null) { if (!Resolve(uid, ref hands)) { return; } var handContainer = hand.Container; if (handContainer == null || handContainer.ContainedEntity != null) { return; } if (!handContainer.Insert(entity, EntityManager)) { Logger.Error($"{nameof(SharedHandsComponent)} on {uid} could not insert {entity} into {handContainer}."); return; } _adminLogger.Add(LogType.Pickup, LogImpact.Low, $"{ToPrettyString(uid):user} picked up {ToPrettyString(entity):entity}"); Dirty(hands); var didEquip = new DidEquipHandEvent(uid, entity, hand); RaiseLocalEvent(uid, didEquip, false); var gotEquipped = new GotEquippedHandEvent(uid, entity, hand); RaiseLocalEvent(entity, gotEquipped, true); // TODO this should REALLY be a cancellable thing, not a handled event. // If one of the interactions resulted in the item being dropped, return early. if (gotEquipped.Handled) { return; } if (hand == hands.ActiveHand) { RaiseLocalEvent(entity, new HandSelectedEvent(uid), false); } }