예제 #1
0
        private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // Break any pulls
            if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled && TryComp(pulled, out SharedPullableComponent? pullable))
            {
                _pullingSystem.TryStopPull(pullable);
            }

            if (_handsSystem.TryDrop(uid, component.ActiveHand !, null, checkActionBlocker: false))
            {
                return;
            }

            var targetName = Name(args.Target);

            var msgOther = Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name(args.Source)), ("disarmed", targetName));
            var msgUser  = Loc.GetString("hands-component-disarm-success-message", ("disarmed", targetName));

            var filter = Filter.Pvs(args.Source).RemoveWhereAttachedEntity(e => e == args.Source);

            _popupSystem.PopupEntity(msgOther, args.Source, filter);
            _popupSystem.PopupEntity(msgUser, args.Source, Filter.Entities(args.Source));

            args.Handled = true; // no shove/stun.
        }
예제 #2
0
        public SuicideKind Suicide(EntityUid uid, EntityUid victimUid, ToiletComponent?component = null,
                                   MetaDataComponent?meta = null, MetaDataComponent?victimMeta = null)
        {
            // check that victim even have head
            if (EntityManager.TryGetComponent <SharedBodyComponent>(victimUid, out var body) &&
                body.HasPartOfType(BodyPartType.Head))
            {
                var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others",
                                                  ("victim", victimUid), ("owner", uid));
                _popupSystem.PopupEntity(othersMessage, uid, Filter.Pvs(victimUid).RemoveWhereAttachedEntity(puid => puid == victimUid));

                var selfMessage = Loc.GetString("toilet-component-suicide-head-message",
                                                ("owner", uid));
                _popupSystem.PopupEntity(selfMessage, uid, Filter.Entities(victimUid));

                return(SuicideKind.Asphyxiation);
            }
            else
            {
                var othersMessage = Loc.GetString("toilet-component-suicide-message-others",
                                                  ("victim", victimUid), ("owner", uid));
                _popupSystem.PopupEntity(othersMessage, uid, Filter.Pvs(uid).RemoveWhereAttachedEntity(puid => puid == victimUid));

                var selfMessage = Loc.GetString("toilet-component-suicide-message",
                                                ("owner", uid));
                _popupSystem.PopupEntity(selfMessage, uid, Filter.Entities(victimUid));

                return(SuicideKind.Blunt);
            }
        }
예제 #3
0
        private void OnSuicide(EntityUid uid, ToiletComponent component, SuicideEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // Check that victim has a head
            if (EntityManager.TryGetComponent <SharedBodyComponent>(args.Victim, out var body) &&
                body.HasPartOfType(BodyPartType.Head))
            {
                var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others",
                                                  ("victim", args.Victim), ("owner", uid));
                _popupSystem.PopupEntity(othersMessage, uid, Filter.Pvs(args.Victim).RemoveWhereAttachedEntity(puid => puid == args.Victim));

                var selfMessage = Loc.GetString("toilet-component-suicide-head-message",
                                                ("owner", uid));
                _popupSystem.PopupEntity(selfMessage, uid, Filter.Entities(args.Victim));

                args.SetHandled(SuicideKind.Asphyxiation);
            }
            else
            {
                var othersMessage = Loc.GetString("toilet-component-suicide-message-others",
                                                  ("victim", args.Victim), ("owner", uid));
                _popupSystem.PopupEntity(othersMessage, uid, Filter.Pvs(uid).RemoveWhereAttachedEntity(puid => puid == args.Victim));

                var selfMessage = Loc.GetString("toilet-component-suicide-message",
                                                ("owner", uid));
                _popupSystem.PopupEntity(selfMessage, uid, Filter.Entities(args.Victim));

                args.SetHandled(SuicideKind.Blunt);
            }
        }
예제 #4
0
        private void ToggleShuttleMode(EntityUid user, ShuttleConsoleComponent consoleComponent, ShuttleComponent shuttleComponent, TransformComponent?consoleXform = null)
        {
            // Re-validate
            if (EntityManager.TryGetComponent(consoleComponent.Owner, out ApcPowerReceiverComponent? receiver) && !receiver.Powered)
            {
                return;
            }

            if (!Resolve(consoleComponent.Owner, ref consoleXform))
            {
                return;
            }

            if (!consoleXform.Anchored || consoleXform.GridID != EntityManager.GetComponent <TransformComponent>(shuttleComponent.Owner).GridID)
            {
                return;
            }

            switch (shuttleComponent.Mode)
            {
            case ShuttleMode.Cruise:
                shuttleComponent.Mode = ShuttleMode.Docking;
                _popup.PopupEntity(Loc.GetString("shuttle-mode-docking"), consoleComponent.Owner, Filter.Entities(user));
                break;

            case ShuttleMode.Docking:
                shuttleComponent.Mode = ShuttleMode.Cruise;
                _popup.PopupEntity(Loc.GetString("shuttle-mode-cruise"), consoleComponent.Owner, Filter.Entities(user));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void OnInteractUsing(EntityUid uid, MicrowaveComponent component, InteractUsingEvent args)
        {
            if (args.Handled)
            {
                return;
            }
            if (!component.Powered)
            {
                _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-no-power"), uid, Filter.Entities(args.User));
                return;
            }

            if (component.Broken)
            {
                _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-broken"), uid, Filter.Entities(args.User));
                return;
            }

            if (!HasComp <SharedItemComponent>(args.Used))
            {
                _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-transfer-fail"), uid, Filter.Entities(args.User));
                return;
            }

            args.Handled = true;

            component.Storage.Insert(args.Used);
            component.DirtyUi();
        }
        private void OnInteract(EntityUid uid, ContainmentFieldGeneratorComponent component, InteractHandEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            if (TryComp(component.Owner, out TransformComponent? transformComp) && transformComp.Anchored)
            {
                if (!component.Enabled)
                {
                    TurnOn(component);
                }
                else if (component.Enabled && component.IsConnected)
                {
                    _popupSystem.PopupEntity(Loc.GetString("comp-containment-anchor-warning"), args.User, Filter.Entities(args.User));
                    return;
                }
                else
                {
                    TurnOff(component);
                }
            }

            args.Handled = true;
        }
예제 #7
0
        private void OnMindAdded(EntityUid uid, DroneComponent drone, MindAddedMessage args)
        {
            UpdateDroneAppearance(uid, DroneStatus.On);
            _popupSystem.PopupEntity(Loc.GetString("drone-activated"), uid, Filter.Pvs(uid));

            if (drone.AlreadyAwoken == false)
            {
                var spawnCoord = Transform(uid).Coordinates;

                if (drone.Tools.Count == 0)
                {
                    return;
                }

                if (TryComp <HandsComponent>(uid, out var hands) && hands.Count >= drone.Tools.Count)
                {
                    foreach (var entry in drone.Tools)
                    {
                        var item = EntityManager.SpawnEntity(entry.PrototypeId, spawnCoord);
                        AddComp <UnremoveableComponent>(item);
                        hands.PutInHand(item);
                        drone.ToolUids.Add(item);
                    }
                }

                drone.AlreadyAwoken = true;
            }
        }
예제 #8
0
    public bool TryLayEgg(EntityUid uid, EggLayerComponent?component)
    {
        if (!Resolve(uid, ref component))
        {
            return(false);
        }

        // Allow infinitely laying eggs if they can't get hungry
        if (TryComp <HungerComponent>(uid, out var hunger))
        {
            if (hunger.CurrentHunger < component.HungerUsage)
            {
                _popup.PopupEntity(Loc.GetString("action-popup-lay-egg-too-hungry"), uid, Filter.Entities(uid));
                return(false);
            }

            hunger.CurrentHunger -= component.HungerUsage;
        }

        foreach (var ent in EntitySpawnCollection.GetSpawns(component.EggSpawn, _random))
        {
            Spawn(ent, Transform(uid).Coordinates);
        }

        // Sound + popups
        SoundSystem.Play(component.EggLaySound.GetSound(), Filter.Pvs(uid), uid, component.EggLaySound.Params);
        _popup.PopupEntity(Loc.GetString("action-popup-lay-egg-user"), uid, Filter.Entities(uid));
        _popup.PopupEntity(Loc.GetString("action-popup-lay-egg-others", ("entity", uid)), uid, Filter.PvsExcept(uid));

        return(true);
    }
예제 #9
0
        private void OnInteractUsing(EntityUid uid, PaperComponent paperComp, InteractUsingEvent args)
        {
            if (_tagSystem.HasTag(args.Used, "Write"))
            {
                if (!TryComp <ActorComponent>(args.User, out var actor))
                {
                    return;
                }

                paperComp.Mode = PaperAction.Write;
                UpdateUserInterface(uid, paperComp);
                _uiSystem.GetUiOrNull(uid, PaperUiKey.Key)?.Open(actor.PlayerSession);
                return;
            }

            // If a stamp, attempt to stamp paper
            if (TryComp <StampComponent>(args.Used, out var stampComp) && TryStamp(uid, stampComp.StampedName, stampComp.StampState, paperComp))
            {
                // successfully stamped, play popup
                var stampPaperOtherMessage = Loc.GetString("paper-component-action-stamp-paper-other", ("user", args.User), ("target", args.Target), ("stamp", args.Used));
                _popupSystem.PopupEntity(stampPaperOtherMessage, args.User, Filter.Pvs(args.User, entityManager: EntityManager).RemoveWhereAttachedEntity(puid => puid == args.User));
                var stampPaperSelfMessage = Loc.GetString("paper-component-action-stamp-paper-self", ("target", args.Target), ("stamp", args.Used));
                _popupSystem.PopupEntity(stampPaperSelfMessage, args.User, Filter.Entities(args.User));
            }
        }
        private void OnEntityActionPerform(EntityUid uid, SharedCombatModeComponent component, DisarmActionEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            if (!_actionBlockerSystem.CanAttack(args.Performer))
            {
                return;
            }

            var attemptEvent = new DisarmAttemptEvent(args.Target, args.Performer);

            RaiseLocalEvent(args.Target, attemptEvent);
            if (attemptEvent.Cancelled)
            {
                return;
            }

            var diff  = Transform(args.Target).MapPosition.Position - Transform(args.Performer).MapPosition.Position;
            var angle = Angle.FromWorldVec(diff);

            var filterAll   = Filter.Pvs(args.Performer);
            var filterOther = filterAll.RemoveWhereAttachedEntity(e => e == args.Performer);

            args.Handled = true;

            if (_random.Prob(component.DisarmFailChance))
            {
                SoundSystem.Play(Filter.Pvs(args.Performer), component.DisarmFailSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f));

                var targetName = Name(args.Target);

                var msgOther = Loc.GetString(
                    "disarm-action-popup-message-other-clients",
                    ("performerName", Name(args.Performer)),
                    ("targetName", targetName));

                var msgUser = Loc.GetString("disarm-action-popup-message-cursor", ("targetName", targetName));

                _popupSystem.PopupEntity(msgOther, args.Performer, filterOther);
                _popupSystem.PopupEntity(msgUser, args.Performer, Filter.Entities(args.Performer));

                _meleeWeaponSystem.SendLunge(angle, args.Performer);
                return;
            }

            _meleeWeaponSystem.SendAnimation("disarm", angle, args.Performer, args.Performer, new[] { args.Target });
            SoundSystem.Play(filterAll, component.DisarmSuccessSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f));
            _logSystem.Add(LogType.DisarmedAction, $"{ToPrettyString(args.Performer):user} used disarm on {ToPrettyString(args.Target):target}");

            var eventArgs = new DisarmedEvent()
            {
                Target = args.Target, Source = args.Performer, PushProbability = component.DisarmPushChance
            };

            RaiseLocalEvent(args.Target, eventArgs);
        }
예제 #11
0
        private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInteractEvent args)
        {
            if (!args.CanReach)
            {
                return;
            }

            var currentTime = _gameTiming.CurTime;

            if (currentTime < component.CooldownEnd)
            {
                return;
            }
            if (args.Target == null || args.Target == args.User || !HasComp <MobStateComponent>(args.Target))
            {
                return;
            }

            component.LastAttackTime = currentTime;
            component.CooldownEnd    = component.LastAttackTime + TimeSpan.FromSeconds(component.CooldownTime);
            RaiseLocalEvent(uid, new RefreshItemCooldownEvent(component.LastAttackTime, component.CooldownEnd), false);

            if (!HasComp <BibleUserComponent>(args.User))
            {
                _popupSystem.PopupEntity(Loc.GetString("bible-sizzle"), args.User, Filter.Entities(args.User));

                SoundSystem.Play(Filter.Pvs(args.User), "/Audio/Effects/lightburn.ogg", args.User);
                _damageableSystem.TryChangeDamage(args.User, component.DamageOnUntrainedUse, true);

                return;
            }

            if (!_invSystem.TryGetSlotEntity(args.Target.Value, "head", out var entityUid))
            {
                if (_random.Prob(component.FailChance))
                {
                    var othersFailMessage = Loc.GetString("bible-heal-fail-others", ("user", args.User), ("target", args.Target), ("bible", uid));
                    _popupSystem.PopupEntity(othersFailMessage, args.User, Filter.Pvs(args.User).RemoveWhereAttachedEntity(puid => puid == args.User));

                    var selfFailMessage = Loc.GetString("bible-heal-fail-self", ("target", args.Target), ("bible", uid));
                    _popupSystem.PopupEntity(selfFailMessage, args.User, Filter.Entities(args.User));

                    SoundSystem.Play(Filter.Pvs(args.Target.Value), "/Audio/Effects/hit_kick.ogg", args.User);
                    _damageableSystem.TryChangeDamage(args.Target.Value, component.DamageOnFail, true);
                    return;
                }
            }

            var othersMessage = Loc.GetString("bible-heal-success-others", ("user", args.User), ("target", args.Target), ("bible", uid));

            _popupSystem.PopupEntity(othersMessage, args.User, Filter.Pvs(args.User).RemoveWhereAttachedEntity(puid => puid == args.User));

            var selfMessage = Loc.GetString("bible-heal-success-self", ("target", args.Target), ("bible", uid));

            _popupSystem.PopupEntity(selfMessage, args.User, Filter.Entities(args.User));

            SoundSystem.Play(Filter.Pvs(args.Target.Value), "/Audio/Effects/holy.ogg", args.User);
            _damageableSystem.TryChangeDamage(args.Target.Value, component.Damage, true);
        }
예제 #12
0
        private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args)
        {
            // cancel any anchor attempt if armed
            if (component.Status == NukeStatus.ARMED)
            {
                var msg = Loc.GetString("nuke-component-cant-anchor");
                _popups.PopupEntity(msg, uid, Filter.Entities(args.User));

                args.Cancel();
            }
        }
예제 #13
0
        private void OnInteractHand(EntityUid uid, KitchenSpikeComponent component, InteractHandEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            if (component.MeatParts > 0)
            {
                _popupSystem.PopupEntity(Loc.GetString("comp-kitchen-spike-knife-needed"), uid, Filter.Entities(args.User));
                args.Handled = true;
            }
        }
        /// <summary>
        ///     Tries to hide item inside secret stash from hands of user.
        /// </summary>
        /// <returns>True if item was hidden inside stash</returns>
        public bool TryHideItem(EntityUid uid, EntityUid userUid, EntityUid itemToHideUid,
                                SecretStashComponent?component = null, ItemComponent?item         = null,
                                MetaDataComponent?itemMeta     = null, SharedHandsComponent?hands = null)
        {
            if (!Resolve(uid, ref component))
            {
                return(false);
            }
            if (!Resolve(itemToHideUid, ref item, ref itemMeta))
            {
                return(false);
            }
            if (!Resolve(userUid, ref hands))
            {
                return(false);
            }

            // check if secret stash is already occupied
            var container = component.ItemContainer;

            if (container.ContainedEntity != null)
            {
                var msg = Loc.GetString("comp-secret-stash-action-hide-container-not-empty");
                _popupSystem.PopupEntity(msg, uid, Filter.Entities(userUid));
                return(false);
            }

            // check if item is too big to fit into secret stash
            var itemName = itemMeta.EntityName;

            if (item.Size > component.MaxItemSize)
            {
                var msg = Loc.GetString("comp-secret-stash-action-hide-item-too-big",
                                        ("item", itemName), ("stash", component.SecretPartName));
                _popupSystem.PopupEntity(msg, uid, Filter.Entities(userUid));
                return(false);
            }

            // try to move item from hands to stash container
            if (!_handsSystem.TryDropIntoContainer(userUid, itemToHideUid, container))
            {
                return(false);
            }

            // all done, show success message
            var successMsg = Loc.GetString("comp-secret-stash-action-hide-success",
                                           ("item", itemName), ("this", component.SecretPartName));

            _popupSystem.PopupEntity(successMsg, uid, Filter.Entities(userUid));
            return(true);
        }
예제 #15
0
    private void OnCrayonAfterInteract(EntityUid uid, CrayonComponent component, AfterInteractEvent args)
    {
        if (args.Handled || !args.CanReach)
        {
            return;
        }

        if (component.Charges <= 0)
        {
            if (component.DeleteEmpty)
            {
                UseUpCrayon(uid, args.User);
            }
            else
            {
                _popup.PopupEntity(Loc.GetString("crayon-interact-not-enough-left-text"), uid, Filter.Entities(args.User));
            }

            args.Handled = true;
            return;
        }

        if (!args.ClickLocation.IsValid(EntityManager))
        {
            _popup.PopupEntity(Loc.GetString("crayon-interact-invalid-location"), uid, Filter.Entities(args.User));
            args.Handled = true;
            return;
        }

        if (!_decals.TryAddDecal(component.SelectedState, args.ClickLocation.Offset(new Vector2(-0.5f, -0.5f)), out _, Color.FromName(component._color), cleanable: true))
        {
            return;
        }

        if (component.UseSound != null)
        {
            SoundSystem.Play(Filter.Pvs(uid), component.UseSound.GetSound(), uid, AudioHelpers.WithVariation(0.125f));
        }

        // Decrease "Ammo"
        component.Charges--;
        Dirty(component);
        _logs.Add(LogType.CrayonDraw, LogImpact.Low, $"{EntityManager.ToPrettyString(args.User):user} drew a {component._color:color} {component.SelectedState}");
        args.Handled = true;

        if (component.DeleteEmpty && component.Charges <= 0)
        {
            UseUpCrayon(uid, args.User);
        }
    }
    private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component, WeldableAttemptEvent args)
    {
        if (component.Open)
        {
            args.Cancel();
            return;
        }

        if (component.Contents.Contains(args.User))
        {
            var msg = Loc.GetString("entity-storage-component-already-contains-user-message");
            _popupSystem.PopupEntity(msg, args.User, Filter.Entities(args.User));
            args.Cancel();
        }
    }
    private void OnAfterInteract(EntityUid uid, FireExtinguisherComponent component, AfterInteractEvent args)
    {
        if (args.Target == null || !args.CanReach)
        {
            return;
        }

        if (args.Handled)
        {
            return;
        }

        args.Handled = true;

        if (component.HasSafety && component.Safety)
        {
            _popupSystem.PopupEntity(Loc.GetString("fire-extinguisher-component-safety-on-message"), uid,
                                     Filter.Entities(args.User));
            return;
        }

        if (args.Target is not {
            Valid : true
        } target ||
            !_solutionContainerSystem.TryGetDrainableSolution(target, out var targetSolution) ||
            !_solutionContainerSystem.TryGetRefillableSolution(uid, out var container))
        {
            return;
        }

        var transfer = container.AvailableVolume;

        if (TryComp <SolutionTransferComponent>(uid, out var solTrans))
        {
            transfer = solTrans.TransferAmount;
        }
        transfer = FixedPoint2.Min(transfer, targetSolution.DrainAvailable);

        if (transfer > 0)
        {
            var drained = _solutionContainerSystem.Drain(target, targetSolution, transfer);
            _solutionContainerSystem.TryAddSolution(uid, container, drained);

            SoundSystem.Play(Filter.Pvs(uid), component.RefillSound.GetSound(), uid);
            _popupSystem.PopupEntity(Loc.GetString("fire-extinguisher-component-after-interact-refilled-message", ("owner", uid)),
                                     uid, Filter.Entities(args.Target.Value));
        }
    }
예제 #18
0
        /// <summary>
        ///     Execute the provided verb.
        /// </summary>
        /// <remarks>
        ///     This will try to call the action delegates and raise the local events for the given verb.
        /// </remarks>
        public override void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bool forced = false)
        {
            // is this verb actually valid?
            if (verb.Disabled)
            {
                // Send an informative pop-up message
                if (!string.IsNullOrWhiteSpace(verb.Message))
                {
                    _popupSystem.PopupEntity(verb.Message, user, Filter.Entities(user));
                }

                return;
            }

            // first, lets log the verb. Just in case it ends up crashing the server or something.
            LogVerb(verb, user, target, forced);

            // then invoke any relevant actions
            verb.Act?.Invoke();

            // Maybe raise a local event
            if (verb.ExecutionEventArgs != null)
            {
                if (verb.EventTarget.IsValid())
                {
                    RaiseLocalEvent(verb.EventTarget, verb.ExecutionEventArgs);
                }
                else
                {
                    RaiseLocalEvent(verb.ExecutionEventArgs);
                }
            }
        }
        private void OnInteractHand(EntityUid uid, PottedPlantHideComponent component, InteractHandEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // standard interaction checks
            if (!_blocker.CanInteract(args.User))
            {
                return;
            }

            Rustle(uid, component);

            var gotItem = _stashSystem.TryGetItem(uid, args.User);

            if (!gotItem)
            {
                var msg = Loc.GetString("potted-plant-hide-component-interact-hand-got-no-item-message");
                _popupSystem.PopupEntity(msg, uid, Filter.Entities(args.User));
            }

            args.Handled = gotItem;
        }
예제 #20
0
        /// <summary>
        ///     Execute actions associated with the given verb.
        /// </summary>
        /// <remarks>
        ///     Unless this is a client-exclusive verb, this will also tell the server to run the same verb.
        /// </remarks>
        public void ExecuteVerb(EntityUid target, Verb verb, VerbType verbType)
        {
            var user = _playerManager.LocalPlayer?.ControlledEntity;

            if (user == null)
            {
                return;
            }

            // is this verb actually valid?
            if (verb.Disabled)
            {
                // maybe send an informative pop-up message.
                if (!string.IsNullOrWhiteSpace(verb.Message))
                {
                    _popupSystem.PopupEntity(verb.Message, user.Value);
                }

                return;
            }

            if (verb.ClientExclusive)
            {
                // is this a client exclusive (gui) verb?
                ExecuteVerb(verb, user.Value, target);
            }
            else
            {
                EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb, verbType));
            }
        }
        private void OnSuicide(EntityUid uid, RecyclerComponent component, SuicideEvent args)
        {
            if (args.Handled)
            {
                return;
            }
            args.SetHandled(SuicideKind.Bloodloss);
            var victim = args.Victim;

            if (TryComp(victim, out ActorComponent? actor) &&
                actor.PlayerSession.ContentData()?.Mind is { } mind)
            {
                _ticker.OnGhostAttempt(mind, false);
                if (mind.OwnedEntity is { Valid : true } entity)
                {
                    _popup.PopupEntity(Loc.GetString("recycler-component-suicide-message"), entity, Filter.Pvs(entity, entityManager : EntityManager));
                }
            }

            _popup.PopupEntity(Loc.GetString("recycler-component-suicide-message-others", ("victim", Identity.Entity(victim, EntityManager))),
                               victim,
                               Filter.Pvs(victim, entityManager: EntityManager).RemoveWhereAttachedEntity(e => e == victim));

            if (TryComp <SharedBodyComponent?>(victim, out var body))
            {
                body.Gib(true);
            }

            Bloodstain(component);
        }
예제 #22
0
        private void AfterInteractOn(EntityUid uid, AirlockPainterComponent component, AfterInteractEvent args)
        {
            if (component.IsSpraying || args.Target is not {
                Valid: true
            } target || !args.CanReach)
            {
                return;
            }

            if (!EntityManager.TryGetComponent <PaintableAirlockComponent>(target, out var airlock))
            {
                return;
            }

            if (!_prototypeManager.TryIndex <AirlockGroupPrototype>(airlock.Group, out var grp))
            {
                Logger.Error("Group not defined: %s", airlock.Group);
                return;
            }

            string style = Styles[component.Index];

            if (!grp.StylePaths.TryGetValue(style, out var sprite))
            {
                string msg = Loc.GetString("airlock-painter-style-not-available");
                _popupSystem.PopupEntity(msg, args.User, Filter.Entities(args.User));
                return;
            }
            component.IsSpraying = true;
            var doAfterEventArgs = new DoAfterEventArgs(args.User, component.SprayTime, default, target)
        public bool IsAuthorized(EntityUid uid, EntityUid?sender, VendingMachineComponent?vendComponent = null)
        {
            if (!Resolve(uid, ref vendComponent) || sender == null)
            {
                return(false);
            }

            if (TryComp <AccessReaderComponent?>(vendComponent.Owner, out var accessReader))
            {
                if (!_accessReader.IsAllowed(sender.Value, accessReader) && !vendComponent.Emagged)
                {
                    _popupSystem.PopupEntity(Loc.GetString("vending-machine-component-try-eject-access-denied"), uid, Filter.Pvs(uid));
                    Deny(uid, vendComponent);
                    return(false);
                }
            }
            return(true);
        }
예제 #24
0
        private void Popup(EntityUid uid, EntityUid player, string message, ServerStorageComponent storageComp)
        {
            if (!storageComp.ShowPopup)
            {
                return;
            }

            _popupSystem.PopupEntity(Loc.GetString(message), player, Filter.Entities(player));
        }
예제 #25
0
        public override void Update(float frameTime)
        {
            base.Update(frameTime);

            foreach (var(respirator, body) in
                     EntityManager.EntityQuery <RespiratorComponent, SharedBodyComponent>())
            {
                var uid = respirator.Owner;
                if (!EntityManager.TryGetComponent <MobStateComponent>(uid, out var state) ||
                    state.IsDead())
                {
                    continue;
                }

                respirator.AccumulatedFrametime += frameTime;

                if (respirator.AccumulatedFrametime < respirator.CycleDelay)
                {
                    continue;
                }
                respirator.AccumulatedFrametime -= respirator.CycleDelay;
                UpdateSaturation(respirator.Owner, -respirator.CycleDelay, respirator);

                if (!state.IsIncapacitated()) // cannot breathe in crit.
                {
                    switch (respirator.Status)
                    {
                    case RespiratorStatus.Inhaling:
                        Inhale(uid, body);
                        respirator.Status = RespiratorStatus.Exhaling;
                        break;

                    case RespiratorStatus.Exhaling:
                        Exhale(uid, body);
                        respirator.Status = RespiratorStatus.Inhaling;
                        break;
                    }
                }

                if (respirator.Saturation < respirator.SuffocationThreshold)
                {
                    if (_gameTiming.CurTime >= respirator.LastGaspPopupTime + respirator.GaspPopupCooldown)
                    {
                        respirator.LastGaspPopupTime = _gameTiming.CurTime;
                        _popupSystem.PopupEntity(Loc.GetString("lung-behavior-gasp"), uid, Filter.Pvs(uid));
                    }

                    TakeSuffocationDamage(uid, respirator);
                    respirator.SuffocationCycles += 1;
                    continue;
                }

                StopSuffocation(uid, respirator);
                respirator.SuffocationCycles = 0;
            }
        }
    private void OnUseInHand(EntityUid uid, MousetrapComponent component, UseInHandEvent args)
    {
        component.IsActive = !component.IsActive;
        _popupSystem.PopupEntity(component.IsActive
            ? Loc.GetString("mousetrap-on-activate")
            : Loc.GetString("mousetrap-on-deactivate"),
                                 uid,
                                 Filter.Entities(args.User));

        UpdateVisuals(uid);
    }
예제 #27
0
        private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args)
        {
            // cancel any anchor attempt without nuke disk
            if (!component.DiskSlot.HasItem)
            {
                var msg = Loc.GetString("nuke-component-cant-anchor");
                _popups.PopupEntity(msg, uid, Filter.Entities(args.User));

                args.Cancel();
            }
        }
예제 #28
0
        private void OnUseInHand(EntityUid uid, PAIComponent component, UseInHandEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // Placeholder PAIs are essentially portable ghost role generators.

            args.Handled = true;

            // Check for pAI activation
            if (EntityManager.TryGetComponent <MindComponent>(uid, out var mind) && mind.HasMind)
            {
                _popupSystem.PopupEntity(Loc.GetString("pai-system-pai-installed"), uid, Filter.Entities(args.User), PopupType.Large);
                return;
            }
            else if (EntityManager.HasComponent <GhostTakeoverAvailableComponent>(uid))
            {
                _popupSystem.PopupEntity(Loc.GetString("pai-system-still-searching"), uid, Filter.Entities(args.User));
                return;
            }

            // Ownership tag
            string val = Loc.GetString("pai-system-pai-name", ("owner", args.User));

            // TODO Identity? People shouldn't dox-themselves by carrying around a PAI.
            // But having the pda's name permanently be "old lady's PAI" is weird.
            // Changing the PAI's identity in a way that ties it to the owner's identity also seems weird.
            // Cause then you could remotely figure out information about the owner's equipped items.

            EntityManager.GetComponent <MetaDataComponent>(component.Owner).EntityName = val;

            var ghostFinder = EntityManager.EnsureComponent <GhostTakeoverAvailableComponent>(uid);

            ghostFinder.RoleName        = Loc.GetString("pai-system-role-name");
            ghostFinder.RoleDescription = Loc.GetString("pai-system-role-description");

            _popupSystem.PopupEntity(Loc.GetString("pai-system-searching"), uid, Filter.Entities(args.User));
            UpdatePAIAppearance(uid, PAIStatus.Searching);
        }
        public override void Update(float frameTime)
        {
            base.Update(frameTime);
            // Queue to track whether mimes can retake vows yet
            foreach (var mime in EntityQuery <MimePowersComponent>())
            {
                if (!mime.VowBroken || mime.ReadyToRepent)
                {
                    continue;
                }

                mime.Accumulator += frameTime;
                if (mime.Accumulator < mime.VowCooldown.TotalSeconds)
                {
                    continue;
                }

                mime.ReadyToRepent = true;
                _popupSystem.PopupEntity(Loc.GetString("mime-ready-to-repent"), mime.Owner, Filter.Entities(mime.Owner));
            }
        }
        private void OnInteractUsing(EntityUid uid, AMEControllerComponent component, InteractUsingEvent args)
        {
            if (!TryComp(args.User, out HandsComponent? hands))
            {
                _popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-no-hands-text"), uid, Filter.Entities(args.User));
                return;
            }

            if (HasComp <AMEFuelContainerComponent?>(args.Used))
            {
                if (component.HasJar)
                {
                    _popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-already-has-jar"), uid, Filter.Entities(args.User));
                }

                else
                {
                    component.JarSlot.Insert(args.Used);
                    _popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-success"), uid, Filter.Entities(args.User));
                    component.UpdateUserInterface();
                }
            }
            else
            {
                _popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-fail"), uid, Filter.Entities(args.User));
            }
        }