示例#1
0
        private void OnToggleMask(EntityUid uid, MaskComponent mask, ToggleMaskEvent args)
        {
            if (mask.ToggleAction == null)
            {
                return;
            }

            if (!_inventorySystem.TryGetSlotEntity(args.Performer, "mask", out var existing) || !mask.Owner.Equals(existing))
            {
                return;
            }

            mask.IsToggled ^= true;
            _actionSystem.SetToggled(mask.ToggleAction, mask.IsToggled);

            // Pulling mask down can change identity, so we want to update that
            _identity.QueueIdentityUpdate(args.Performer);

            if (mask.IsToggled)
            {
                _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-down-popup-message", ("mask", mask.Owner)), args.Performer, Filter.Entities(args.Performer));
            }
            else
            {
                _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-up-popup-message", ("mask", mask.Owner)), args.Performer, Filter.Entities(args.Performer));
            }

            ToggleMaskComponents(uid, mask, args.Performer);
        }
示例#2
0
 private void OnGetActions(EntityUid uid, MaskComponent component, GetItemActionsEvent args)
 {
     if (component.ToggleAction != null && !args.InHands)
     {
         args.Actions.Add(component.ToggleAction);
     }
 }
示例#3
0
        // set to untoggled when unequipped, so it isn't left in a 'pulled down' state
        private void OnGotUnequipped(EntityUid uid, MaskComponent mask, GotUnequippedEvent args)
        {
            if (mask.ToggleAction == null)
            {
                return;
            }

            mask.IsToggled = false;
            _actionSystem.SetToggled(mask.ToggleAction, mask.IsToggled);

            ToggleMaskComponents(uid, mask, args.Equipee, true);
        }
示例#4
0
        private void ToggleMaskComponents(EntityUid uid, MaskComponent mask, EntityUid wearer, bool isEquip = false)
        {
            //toggle visuals
            if (TryComp <ClothingComponent>(mask.Owner, out var clothing))
            {
                //TODO: sprites for 'pulled down' state. defaults to invisible due to no sprite with this prefix
                _clothing.SetEquippedPrefix(uid, mask.IsToggled ? "toggled" : null, clothing);
            }

            // toggle ingestion blocking
            if (TryComp <IngestionBlockerComponent>(uid, out var blocker))
            {
                blocker.Enabled = !mask.IsToggled;
            }

            // toggle disease protection
            if (TryComp <DiseaseProtectionComponent>(uid, out var diseaseProtection))
            {
                diseaseProtection.IsActive = !mask.IsToggled;
            }

            // toggle identity
            if (TryComp <IdentityBlockerComponent>(uid, out var identity))
            {
                identity.Enabled = !mask.IsToggled;
            }

            // toggle breath tool connection (skip during equip since that is handled in LungSystem)
            if (isEquip || !TryComp <BreathToolComponent>(uid, out var breathTool))
            {
                return;
            }

            if (mask.IsToggled)
            {
                _atmos.DisconnectInternals(breathTool);
            }
            else
            {
                breathTool.IsFunctional = true;

                if (TryComp(wearer, out InternalsComponent? internals))
                {
                    breathTool.ConnectedInternalsEntity = wearer;
                    _internals.ConnectBreathTool(internals, uid);
                }
            }
        }
示例#5
0
        private static Mask CreateMask(GameObject gameObject, IAssetLoader assetLoader, MaskComponent maskComponent)
        {
            var image = gameObject.AddComponent <Image>();

            image.raycastTarget = false;

            if (maskComponent.Sprite != null)
            {
                UpdateImageSprite(gameObject, image, maskComponent.Sprite, assetLoader);
            }

            var mask = gameObject.AddComponent <Mask>();

            mask.showMaskGraphic = false;

            return(mask);
        }