Esempio n. 1
0
        /// <summary>
        /// Raise event to attempt to use held item, or surrounding entities to commit suicide
        /// </summary>
        private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
        {
            // Suicide by held item
            if (EntityManager.TryGetComponent(victim, out HandsComponent? handsComponent) &&
                handsComponent.ActiveHandEntity is { } item)
            {
                RaiseLocalEvent(item, suicideEvent, false);

                if (suicideEvent.Handled)
                {
                    return;
                }
            }

            var itemQuery = GetEntityQuery <ItemComponent>();

            // Suicide by nearby entity (ex: Microwave)
            foreach (var entity in _entityLookupSystem.GetEntitiesInRange(victim, 1, LookupFlags.Approximate | LookupFlags.Anchored))
            {
                // Skip any nearby items that can be picked up, we already checked the active held item above
                if (itemQuery.HasComponent(entity))
                {
                    continue;
                }

                RaiseLocalEvent(entity, suicideEvent, false);

                if (suicideEvent.Handled)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        public bool Suicide(EntityUid victim)
        {
            // Checks to see if the CannotSuicide tag exits, ghosts instead.
            if (_tagSystem.HasTag(victim, "CannotSuicide"))
            {
                return(false);
            }

            // Checks to see if the player is dead.
            if (!TryComp <MobStateComponent>(victim, out var mobState) || _mobState.IsDead(victim, mobState))
            {
                return(false);
            }

            _adminLogger.Add(LogType.Suicide,
                             $"{EntityManager.ToPrettyString(victim):player} is committing suicide");

            var suicideEvent = new SuicideEvent(victim);

            // If you are critical, you wouldn't be able to use your surroundings to suicide, so you do the default suicide
            if (!_mobState.IsCritical(victim, mobState))
            {
                EnvironmentSuicideHandler(victim, suicideEvent);
            }
            DefaultSuicideHandler(victim, suicideEvent);

            ApplyDeath(victim, suicideEvent.Kind !.Value);
            return(true);
        }
        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);
            }
        }
        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);
        }
        private void OnSuicide(EntityUid uid, MicrowaveComponent component, SuicideEvent args)
        {
            if (args.Handled)
            {
                return;
            }
            args.SetHandled(SuicideKind.Heat);
            var victim    = args.Victim;
            var headCount = 0;

            if (TryComp <SharedBodyComponent?>(victim, out var body))
            {
                var headSlots = body.GetSlotsOfType(BodyPartType.Head);

                foreach (var slot in headSlots)
                {
                    var part = slot.Part;

                    if (part == null ||
                        !body.TryDropPart(slot, out var dropped))
                    {
                        continue;
                    }

                    foreach (var droppedPart in dropped.Values)
                    {
                        if (droppedPart.PartType != BodyPartType.Head)
                        {
                            continue;
                        }
                        component.Storage.Insert(droppedPart.Owner);
                        headCount++;
                    }
                }
            }

            var othersMessage = headCount > 1
                ? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim))
                : Loc.GetString("microwave-component-suicide-others-message", ("victim", victim));

            victim.PopupMessageOtherClients(othersMessage);

            var selfMessage = headCount > 1
                ? Loc.GetString("microwave-component-suicide-multi-head-message")
                : Loc.GetString("microwave-component-suicide-message");

            victim.PopupMessage(selfMessage);
            component.ClickSound();
            component.SetCookTime(10);
            component.Wzhzhzh();
        }
Esempio n. 6
0
        /// <summary>
        /// If not handled, does the default suicide, which is biting your own tongue
        /// </summary>
        private static void DefaultSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
        {
            if (suicideEvent.Handled)
            {
                return;
            }
            var othersMessage = Loc.GetString("suicide-command-default-text-others", ("name", victim));

            victim.PopupMessageOtherClients(othersMessage);

            var selfMessage = Loc.GetString("suicide-command-default-text-self");

            victim.PopupMessage(selfMessage);
            suicideEvent.SetHandled(SuicideKind.Bloodloss);
        }
        private void OnSuicide(EntityUid uid, KitchenSpikeComponent component, SuicideEvent args)
        {
            if (args.Handled)
            {
                return;
            }
            args.SetHandled(SuicideKind.Piercing);
            var victim        = args.Victim;
            var othersMessage = Loc.GetString("comp-kitchen-spike-suicide-other", ("victim", victim));

            victim.PopupMessageOtherClients(othersMessage);

            var selfMessage = Loc.GetString("comp-kitchen-spike-suicide-self");

            victim.PopupMessage(selfMessage);
        }
Esempio n. 8
0
    private void OnSuicide(EntityUid uid, CrematoriumComponent component, SuicideEvent args)
    {
        if (args.Handled)
        {
            return;
        }
        args.SetHandled(SuicideKind.Heat);

        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("crematorium-entity-storage-component-suicide-message"), entity, Filter.Pvs(entity));
            }
        }

        _popup.PopupEntity(Loc.GetString("crematorium-entity-storage-component-suicide-message-others",
                                         ("victim", Identity.Entity(victim, EntityManager))),
                           victim, Filter.PvsExcept(victim), PopupType.LargeCaution);

        if (_entityStorage.CanInsert(uid))
        {
            _entityStorage.CloseStorage(uid);
            _standing.Down(victim, false);
            _entityStorage.Insert(victim, uid);
        }
        else
        {
            EntityManager.DeleteEntity(victim);
        }
        _entityStorage.CloseStorage(uid);
        Cremate(uid, component);
    }
        private void OnSuicide(EntityUid uid, CrematoriumEntityStorageComponent component, SuicideEvent args)
        {
            if (args.Handled)
            {
                return;
            }
            args.SetHandled(SuicideKind.Heat);
            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("crematorium-entity-storage-component-suicide-message"), entity, Filter.Pvs(entity, entityManager : EntityManager));
                }
            }

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

            if (component.CanInsert(victim))
            {
                component.Insert(victim);
                _stando.Down(victim, false);
            }
            else
            {
                EntityManager.DeleteEntity(victim);
            }

            component.Cremate();
        }