Пример #1
0
 private void HandleContainerModified(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args)
 {
     if (handComp.Hands.TryGetValue(args.Container.ID, out var hand))
     {
         UpdateHandVisuals(uid, args.Entity, hand);
     }
 }
Пример #2
0
 protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args)
 {
     if (handComp.TryGetHand(args.Container.ID, out var hand))
     {
         UpdateHandVisuals(uid, args.Entity, hand);
     }
 }
        private void HandleContainerInserted(EntityUid uid, SharedHandsComponent component, EntInsertedIntoContainerMessage args)
        {
            // un-rotate entities. needed for things like directional flashlights
            Transform(args.Entity).LocalRotation = 0;

            HandleContainerModified(uid, component, args);
        }
Пример #4
0
 protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args)
 {
     if (uid == _playerManager.LocalPlayer?.ControlledEntity)
     {
         GuiStateUpdated?.Invoke();
     }
 }
Пример #5
0
 private void HandleEntityRemoved(EntityUid uid, SharedHandsComponent component, EntRemovedFromContainerMessage args)
 {
     if (!Deleted(args.Entity) && TryComp(args.Entity, out HandVirtualItemComponent? @virtual))
     {
         _virtualSystem.Delete(@virtual, uid);
     }
 }
Пример #6
0
        private void DropHandItems(SharedHandsComponent handsComponent, bool doMobChecks = true)
        {
            var msg      = new DropHandItemsAttemptEvent();
            var entity   = handsComponent.Owner;
            var uid      = entity.Uid;
            var eventBus = EntityManager.EventBus;

            eventBus.RaiseLocalEvent(uid, msg);

            if (msg.Cancelled)
            {
                return;
            }

            if (entity.TryGetContainerMan(out var containerManager))
            {
                var parentMsg = new ContainedEntityDropHandItemsAttemptEvent(uid);
                eventBus.RaiseLocalEvent(containerManager.Owner.Uid, parentMsg);

                if (parentMsg.Cancelled)
                {
                    return;
                }
            }

            DropAllItemsInHands(entity, doMobChecks);
        }
Пример #7
0
 protected virtual void HandleContainerModified(
     EntityUid uid,
     SharedHandsComponent component,
     ContainerModifiedMessage args)
 {
     component.Dirty();
 }
Пример #8
0
 private void OnPrefixChanged(EntityUid uid, SharedHandsComponent component, ItemPrefixChangeEvent args)
 {
     // update hands visuals if this item is in a hand (rather then inventory or other container).
     if (component.HasHand(args.ContainerId))
     {
         UpdateHandVisuals(uid, component);
     }
 }
Пример #9
0
        protected override void HandleContainerRemoved(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args)
        {
            if (!Deleted(args.Entity) && TryComp(args.Entity, out HandVirtualItemComponent? @virtual))
            {
                _virtualSystem.Delete(@virtual, uid);
            }

            base.HandleContainerRemoved(uid, component, args);
        }
    //TODO: Actually shows all items/clothing/etc.
    private void HandleExamined(EntityUid uid, SharedHandsComponent handsComp, ExaminedEvent args)
    {
        foreach (var inhand in EnumerateHeld(uid, handsComp))
        {
            if (HasComp <HandVirtualItemComponent>(inhand))
            {
                continue;
            }

            args.PushText(Loc.GetString("comp-hands-examine", ("user", handsComp.Owner), ("item", inhand)));
        }
    }
Пример #11
0
 protected abstract void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args);
Пример #12
0
 protected virtual void HandleContainerRemoved(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args)
 {
     HandleContainerModified(uid, component, args);
 }
Пример #13
0
 private void HandleContainerModified(EntityUid uid, SharedHandsComponent hands, ContainerModifiedMessage args)
 {
     UpdateHandVisuals(uid, hands);
 }
 protected virtual void HandleContainerModified(EntityUid uid, SharedHandsComponent hands, ContainerModifiedMessage args)
 {
     // client updates hand visuals here.
 }
Пример #15
0
 public HandsComponentState(SharedHandsComponent handComp)
 {
     Hands      = new(handComp.Hands.Values);
     HandNames  = handComp.SortedHands;
     ActiveHand = handComp.ActiveHand?.Name;
 }
Пример #16
0
 /// <summary>
 ///     Get a list of hands that are currently holding nothing. This is a LinQ method, not a property, so cache
 ///     it instead of accessing this multiple times.
 /// </summary>
 public static IEnumerable <string> GetFreeHandNames(this SharedHandsComponent component) => GetFreeHands(component).Select(hand => hand.Name);
Пример #17
0
 /// <summary>
 ///     Get a list of hands that are currently holding nothing. This is a LinQ method, not a property, so cache
 ///     it instead of accessing this multiple times.
 /// </summary>
 public static IEnumerable <Hand> GetFreeHands(this SharedHandsComponent component) => component.Hands.Values.Where(hand => !hand.IsEmpty);
Пример #18
0
 /// <summary>
 ///     Get the number of hands that are not currently holding anything. This is a LinQ method, not a property, so
 ///     cache it instead of accessing this multiple times.
 /// </summary>
 public static int CountFreeHands(this SharedHandsComponent component) => component.Hands.Values.Count(hand => hand.IsEmpty);
Пример #19
0
 /// <summary>
 ///     Returns true if any hand is free. This is a LinQ method, not a property, so
 ///     cache it instead of accessing this multiple times.
 /// </summary>
 public static bool IsAnyHandFree(this SharedHandsComponent component) => component.Hands.Values.Any(hand => hand.IsEmpty);
Пример #20
0
 protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args)
 {
     component.HandsModified();
 }