From f4081b90fed8f6857ea3532c56506a129962ea47 Mon Sep 17 00:00:00 2001 From: VigersRay Date: Thu, 25 Jul 2024 00:48:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D0=B2=D0=B8=D0=B5?= =?UTF-8?q?=20=D1=86=D0=B5=D0=BB=D0=B5=D0=B9=20=D0=BD=D0=B0=20=D1=83=D0=B1?= =?UTF-8?q?=D0=B8=D0=B9=D1=81=D1=82=D0=B2=D0=B0=20=D1=83=20=D0=B0=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Systems/KillPersonConditionSystem.cs | 44 ++++++++++++------- Resources/Changelog/ChangelogSunrise.yml | 9 ++++ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs b/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs index fe66cd6452b..6937f5c25c4 100644 --- a/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs +++ b/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs @@ -3,7 +3,11 @@ using Content.Server.Objectives.Components; using Content.Server.Shuttles.Systems; using Content.Shared.CCVar; +using Content.Shared.Humanoid; using Content.Shared.Mind; +using Content.Shared.Mind.Components; +using Content.Shared.Mobs.Components; +using Content.Shared.Mobs.Systems; using Content.Shared.Objectives.Components; using Content.Shared.Roles.Jobs; using Robust.Shared.Configuration; @@ -22,6 +26,7 @@ public sealed class KillPersonConditionSystem : EntitySystem [Dependency] private readonly SharedJobSystem _job = default!; [Dependency] private readonly SharedMindSystem _mind = default!; [Dependency] private readonly TargetObjectiveSystem _target = default!; + [Dependency] private readonly MobStateSystem _mobState = default!; public override void Initialize() { @@ -56,15 +61,7 @@ private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref return; // no other humans to kill - var allHumans = _mind.GetAliveHumansExcept(args.MindId); - - // Sunrise-Start - foreach (var entityUid in allHumans.ToList()) - { - if (!HasComp(entityUid)) - allHumans.Remove(entityUid); - } - // Sunrise-End + var allHumans = GetAliveTargetsExcept(args.MindId); if (allHumans.Count == 0) { @@ -89,13 +86,7 @@ private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref Obj return; // no other humans to kill - var allHumans = _mind.GetAliveHumansExcept(args.MindId); - - foreach (var entityUid in allHumans.ToList()) - { - if (!HasComp(entityUid)) - allHumans.Remove(entityUid); - } + var allHumans = GetAliveTargetsExcept(args.MindId); if (allHumans.Count == 0) { @@ -146,4 +137,25 @@ private float GetProgress(EntityUid target, bool requireDead) // if evac is still here and target hasn't boarded, show 50% to give you an indicator that you are doing good return _emergencyShuttle.EmergencyShuttleArrived ? 0.5f : 0f; } + + public List GetAliveTargetsExcept(EntityUid exclude) + { + var mindQuery = EntityQuery(); + + var allTargets = new List(); + // HumanoidAppearanceComponent is used to prevent mice, pAIs, etc from being chosen + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var mc, out var mobState, out _, out _)) + { + // the player needs to have a mind and not be the excluded one + if (mc.Mind == null || mc.Mind == exclude) + continue; + + // the player has to be alive + if (_mobState.IsAlive(uid, mobState)) + allTargets.Add(mc.Mind.Value); + } + + return allTargets; + } } diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index 73e9cd32ad2..450d475a19e 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -1936,3 +1936,12 @@ type: Fix id: 145 time: '2024-07-24T18:45:34.906534+00:00' +- author: VigersRay + changes: + - message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E \u043E\u0442\ + \u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0446\u0435\u043B\u0435\u0439\ + \ \u043D\u0430 \u0443\u0431\u0438\u0439\u0441\u0442\u0432\u043E \u0443 \u0430\ + \u0433\u0435\u043D\u0442\u043E\u0432." + type: Fix + id: 146 + time: '2024-07-24T21:47:55.955101+00:00'