private void OnComponentHandleState(EntityUid uid, IdCardComponent component, ref ComponentHandleState args)
 {
     if (args.Current is IdCardComponentState state)
     {
         component.FullName = state.FullName;
         component.JobTitle = state.JobTitle;
     }
 }
Пример #2
0
    private string GetNameAndJob(IdCardComponent id)
    {
        var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";

        var val = string.IsNullOrWhiteSpace(id.FullName)
            ? Loc.GetString("access-id-card-component-owner-name-job-title-text",
                            ("originalOwnerName", id.OriginalOwnerName),
                            ("jobSuffix", jobSuffix))
            : Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
                            ("fullName", id.FullName),
                            ("jobSuffix", jobSuffix));

        return(val);
    }
Пример #3
0
        private void HandleIDEjection(IEntity pdaUser)
        {
            if (IdSlotEmpty)
            {
                return;
            }

            var cardEntity = ContainedID.Owner;

            _idSlot.Remove(cardEntity);

            var hands             = pdaUser.GetComponent <HandsComponent>();
            var cardItemComponent = cardEntity.GetComponent <ItemComponent>();

            hands.PutInHandOrDrop(cardItemComponent);
            ContainedID = null;
            UpdatePDAUserInterface();
        }
Пример #4
0
        private bool TryInsertIdCard(InteractUsingEventArgs eventArgs, IdCardComponent idCardComponent)
        {
            var item = eventArgs.Using;

            if (_idSlot.Contains(item))
            {
                return(false);
            }

            if (!eventArgs.User.TryGetComponent(out IHandsComponent? hands))
            {
                Owner.PopupMessage(eventArgs.User, Loc.GetString("comp-pda-ui-try-insert-id-card-no-hands"));
                return(true);
            }

            IEntity?swap = null;

            if (!IdSlotEmpty)
            {
                // Swap
                swap = _idSlot.ContainedEntities[0];
            }

            if (!hands.Drop(item))
            {
                return(true);
            }

            if (swap != null)
            {
                hands.PutInHand(swap.GetComponent <ItemComponent>());
            }

            InsertIdCard(idCardComponent);

            UpdatePDAUserInterface();
            return(true);
        }
Пример #5
0
        private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowavedEvent args)
        {
            if (TryComp <AccessComponent>(uid, out var access))
            {
                float randomPick = _random.NextFloat();
                // if really unlucky, burn card
                if (randomPick <= 0.15f)
                {
                    TryComp <TransformComponent>(uid, out TransformComponent? transformComponent);
                    if (transformComponent != null)
                    {
                        _popupSystem.PopupCoordinates(Loc.GetString("id-card-component-microwave-burnt", ("id", uid)),
                                                      transformComponent.Coordinates, Filter.Pvs(uid));
                        EntityManager.SpawnEntity("FoodBadRecipe",
                                                  transformComponent.Coordinates);
                    }
                    EntityManager.QueueDeleteEntity(uid);
                    return;
                }
                // If they're unlucky, brick their ID
                if (randomPick <= 0.25f)
                {
                    _popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-bricked", ("id", uid)),
                                             uid, Filter.Pvs(uid));
                    access.Tags.Clear();
                }
                else
                {
                    _popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-safe", ("id", uid)),
                                             uid, Filter.Pvs(uid));
                }

                // Give them a wonderful new access to compensate for everything
                var random = _random.Pick(_prototypeManager.EnumeratePrototypes <AccessLevelPrototype>().ToArray());
                access.Tags.Add(random.ID);
            }
        }
Пример #6
0
 public void InsertIdCard(IdCardComponent card)
 {
     _idSlot.Insert(card.Owner);
     ContainedID = card;
     SoundSystem.Play(Filter.Pvs(Owner), _insertIdSound.GetSound(), Owner);
 }
 private void InsertIdCard(IdCardComponent card)
 {
     _idSlot.Insert(card.Owner);
     ContainedID = card;
     EntitySystem.Get <AudioSystem>().PlayFromEntity("/Audio/Guns/MagIn/batrifle_magin.ogg", Owner);
 }
Пример #8
0
 private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args)
 {
     id.OriginalOwnerName ??= EntityManager.GetComponent <MetaDataComponent>(id.Owner).EntityName;
     UpdateEntityName(uid, id);
 }
Пример #9
0
 private void InsertIdCard(IdCardComponent card)
 {
     _idSlot.Insert(card.Owner);
     ContainedID = card;
 }
Пример #10
0
 public void InsertIdCard(IdCardComponent card)
 {
     _idSlot.Insert(card.Owner);
     ContainedID = card;
     SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg", Owner);
 }
 private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args)
 {
     id.OriginalOwnerName ??= id.Owner.Name;
     UpdateEntityName(uid, id);
 }
 private void OnComponentGetState(EntityUid uid, IdCardComponent component, ref ComponentGetState args)
 {
     args.State = new IdCardComponentState(component.FullName, component.JobTitle);
 }