private void AddEjectVerbs(EntityUid uid, SharedItemSlotsComponent component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            foreach (var(slotName, slot) in component.Slots)
            {
                if (slot.ContainerSlot.ContainedEntity == null)
                {
                    continue;
                }

                Verb verb = new();
                verb.Text     = slot.Name;
                verb.Category = VerbCategory.Eject;
                verb.Act      = () => TryEjectContent(uid, slotName, args.User, component);

                args.Verbs.Add(verb);
            }
        }
        private void AddEjectVerbs(EntityUid uid, IdCardConsoleComponent component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            // Can we eject a privileged ID?
            if (!component.PrivilegedIDEmpty)
            {
                Verb verb = new();
                verb.Act      = () => component.PutIdInHand(component.PrivilegedIdContainer, args.Hands);
                verb.Category = VerbCategory.Eject;
                verb.Text     = Loc.GetString("id-card-console-privileged-id");
                args.Verbs.Add(verb);
            }

            // Can we eject a target ID?
            if (!component.TargetIDEmpty)
            {
                Verb verb = new();
                verb.Act      = () => component.PutIdInHand(component.TargetIdContainer, args.Hands);
                verb.Category = VerbCategory.Eject;
                verb.Text     = Loc.GetString("id-card-console-target-id");
                args.Verbs.Add(verb);
            }
        }
Esempio n. 3
0
        private void AddEjectVerbs(EntityUid uid, ItemSlotsComponent itemSlots, GetVerbsEvent <AlternativeVerb> args)
        {
            if (args.Hands == null || !args.CanAccess || !args.CanInteract)
            {
                return;
            }

            foreach (var slot in itemSlots.Slots.Values)
            {
                if (slot.EjectOnInteract)
                {
                    // For this item slot, ejecting/inserting is a primary interaction. Instead of an eject category
                    // alt-click verb, there will be a "Take item" primary interaction verb.
                    continue;
                }

                if (!CanEject(slot))
                {
                    continue;
                }

                if (!_actionBlockerSystem.CanPickup(args.User, slot.Item !.Value))
                {
                    continue;
                }

                var verbSubject = slot.Name != string.Empty
                    ? Loc.GetString(slot.Name)
                    : EntityManager.GetComponent <MetaDataComponent>(slot.Item.Value).EntityName ?? string.Empty;

                AlternativeVerb verb = new();
                verb.IconEntity = slot.Item;
                verb.Act        = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true);

                if (slot.EjectVerbText == null)
                {
                    verb.Text     = verbSubject;
                    verb.Category = VerbCategory.Eject;
                }
                else
                {
                    verb.Text = Loc.GetString(slot.EjectVerbText);
                }

                args.Verbs.Add(verb);
            }
        }
        // TODO VERBS EJECTABLES Standardize eject/insert verbs into a single system?
        // Really, why isn't this just PowerCellSlotComponent?
        private void AddEjectCellVerb(EntityUid uid, ServerBatteryBarrelComponent component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !component.PowerCellRemovable ||
                component.PowerCell == null ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            Verb verb = new();

            verb.Text     = component.PowerCell.Owner.Name;
            verb.Category = VerbCategory.Eject;
            verb.Act      = () => component.TryEjectCell(args.User);
            args.Verbs.Add(verb);
        }
Esempio n. 5
0
        public bool CanPickup(IEntity user)
        {
            var coords = Owner.Transform.GridPosition;

            if (!ActionBlockerSystem.CanPickup(user))
            {
                return(false);
            }
            return(_entitySystemManager.GetEntitySystem <InteractionSystem>()
                   .InRangeUnobstructed(coords, user.Transform.GridPosition, ignoredEnt: Owner));
        }
        /// <summary>
        ///     Try to eject an item from a slot.
        /// </summary>
        /// <returns>False if item slot is locked or has no item inserted</returns>
        public bool TryEject(EntityUid uid, ItemSlot slot, EntityUid?user, [NotNullWhen(true)] out EntityUid?item, bool excludeUserAudio = false)
        {
            item = null;

            // This handles logic with the slot itself
            if (!CanEject(slot))
            {
                return(false);
            }

            item = slot.Item;

            // This handles user logic
            if (user != null && item != null && !_actionBlockerSystem.CanPickup(user.Value, item.Value))
            {
                return(false);
            }

            Eject(uid, slot, item !.Value, user, excludeUserAudio);
            return(true);
        }
Esempio n. 7
0
        public bool CanPickup(IEntity user)
        {
            if (!ActionBlockerSystem.CanPickup(user))
            {
                return(false);
            }

            if (user.Transform.MapID != Owner.Transform.MapID)
            {
                return(false);
            }

            var userPos = user.Transform.MapPosition;
            var itemPos = Owner.Transform.WorldPosition;

            return(InteractionChecks.InRangeUnobstructed(user, itemPos, ignoredEnt: Owner, insideBlockerValid: true));
        }
        // TODO VERBS EJECTABLES Standardize eject/insert verbs into a single system?
        private void AddEjectVerb(EntityUid uid, BaseCharger component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !component.HasCell ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            Verb verb = new();

            verb.Text     = component.Container.ContainedEntity !.Name;
            verb.Category = VerbCategory.Eject;
            verb.Act      = () => component.RemoveItem(args.User);
            args.Verbs.Add(verb);
        }
        // TODO VERBS EJECTABLES Standardize eject/insert verbs into a single system?
        private void AddEjectVerb(EntityUid uid, PowerCellSlotComponent component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !component.ShowVerb ||
                !component.HasCell ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            Verb verb = new();

            verb.Text     = component.Cell !.Name;
            verb.Category = VerbCategory.Eject;
            verb.Act      = () => component.EjectCell(args.User);
            args.Verbs.Add(verb);
        }
Esempio n. 10
0
        public bool CanPickup(IEntity user)
        {
            if (!ActionBlockerSystem.CanPickup(user))
            {
                return(false);
            }

            if (user.Transform.MapID != Owner.Transform.MapID)
            {
                return(false);
            }

            if (Owner.TryGetComponent(out IPhysicsComponent physics) &&
                physics.Anchored)
            {
                return(false);
            }

            return(user.InRangeUnobstructed(Owner, ignoreInsideBlocker: true, popup: true));
        }
        public bool CanPickup(IEntity user)
        {
            if (!ActionBlockerSystem.CanPickup(user))
            {
                return(false);
            }

            if (user.Transform.MapID != Owner.Transform.MapID)
            {
                return(false);
            }

            if (Owner.TryGetComponent(out ICollidableComponent physics) &&
                physics.Anchored)
            {
                return(false);
            }

            var itemPos = Owner.Transform.MapPosition;

            return(InteractionChecks.InRangeUnobstructed(user, itemPos, ignoredEnt: Owner, ignoreInsideBlocker: true));
        }
        // TODO VERBS EJECTABLES Standardize eject/insert verbs into a single system? Maybe using something like the
        // system mentioned in #4538? The code here is basically identical to the stuff in ChemDispenserSystem
        private void AddEjectVerb(EntityUid uid, ChemMasterComponent component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !component.HasBeaker ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            Verb verb = new();

            verb.Act = () =>
            {
                component.TryEject(args.User);
                component.UpdateUserInterface();
            };
            verb.Category = VerbCategory.Eject;
            verb.Text     = component.BeakerContainer.ContainedEntity !.Name;
            args.Verbs.Add(verb);
        }
Esempio n. 13
0
        private void AddEjectMagazineVerb(EntityUid uid, ServerMagazineBarrelComponent component, GetAlternativeVerbsEvent args)
        {
            if (args.Hands == null ||
                !args.CanAccess ||
                !args.CanInteract ||
                !component.HasMagazine ||
                !_actionBlockerSystem.CanPickup(args.User))
            {
                return;
            }

            if (component.MagNeedsOpenBolt && !component.BoltOpen)
            {
                return;
            }

            Verb verb = new();

            verb.Text     = EntityManager.GetComponent <MetaDataComponent>(component.MagazineContainer.ContainedEntity !.Value).EntityName;
            verb.Category = VerbCategory.Eject;
            verb.Act      = () => component.RemoveMagazine(args.User);
            args.Verbs.Add(verb);
        }