diff --git a/Content.Server/Objectives/Systems/HelpProgressConditionSystem.cs b/Content.Server/Objectives/Systems/HelpProgressConditionSystem.cs index e0a56149b3e2..7639e69bfdaa 100644 --- a/Content.Server/Objectives/Systems/HelpProgressConditionSystem.cs +++ b/Content.Server/Objectives/Systems/HelpProgressConditionSystem.cs @@ -45,10 +45,7 @@ private void OnTraitorAssigned(EntityUid uid, RandomTraitorProgressComponent com return; } - var traitors = _traitorRule.GetOtherTraitorMindsAliveAndConnected(args.Mind) - .Select(pair => pair.Item1) - .ToHashSet(); - var removeList = new List(); + var traitors = _traitorRule.GetOtherTraitorMindsAliveAndConnected(args.Mind).ToHashSet(); // cant help anyone who is tasked with helping: // 1. thats boring @@ -56,19 +53,26 @@ private void OnTraitorAssigned(EntityUid uid, RandomTraitorProgressComponent com foreach (var traitor in traitors) { // TODO: replace this with TryComp(traitor) or something when objectives are moved out of mind - if (!TryComp(traitor, out var mind)) + if (!TryComp(traitor.Id, out var mind)) continue; foreach (var objective in mind.Objectives) { if (HasComp(objective)) - removeList.Add(traitor); + traitors.RemoveWhere(x => x.Mind == mind); } } - foreach (var tot in removeList) + // Can't have multiple objectives to help/save the same person + foreach (var objective in args.Mind.Objectives) { - traitors.Remove(tot); + if (HasComp(objective) || HasComp(objective)) + { + if (TryComp(objective, out var help)) + { + traitors.RemoveWhere(x => x.Id == help.Target); + } + } } // no more helpable traitors @@ -78,7 +82,7 @@ private void OnTraitorAssigned(EntityUid uid, RandomTraitorProgressComponent com return; } - _target.SetTarget(uid, _random.Pick(traitors), target); + _target.SetTarget(uid, _random.Pick(traitors).Id, target); } private float GetProgress(EntityUid target) diff --git a/Content.Server/Objectives/Systems/KeepAliveCondition.cs b/Content.Server/Objectives/Systems/KeepAliveCondition.cs index 48df96e74251..fad8aa6d18e1 100644 --- a/Content.Server/Objectives/Systems/KeepAliveCondition.cs +++ b/Content.Server/Objectives/Systems/KeepAliveCondition.cs @@ -44,7 +44,19 @@ private void OnAssigned(EntityUid uid, RandomTraitorAliveComponent comp, ref Obj return; } - var traitors = Enumerable.ToList<(EntityUid Id, MindComponent Mind)>(_traitorRule.GetOtherTraitorMindsAliveAndConnected(args.Mind)); + var traitors = _traitorRule.GetOtherTraitorMindsAliveAndConnected(args.Mind).ToHashSet(); + + // Can't have multiple objectives to help/save the same person + foreach (var objective in args.Mind.Objectives) + { + if (HasComp(objective) || HasComp(objective)) + { + if (TryComp(objective, out var help)) + { + traitors.RemoveWhere(x => x.Id == help.Target); + } + } + } // You are the first/only traitor. if (traitors.Count == 0) diff --git a/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs b/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs index f662d6a578c8..3aa4d606fc3b 100644 --- a/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs +++ b/Content.Server/Objectives/Systems/KillPersonConditionSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Objectives.Components; using Robust.Shared.Configuration; using Robust.Shared.Random; +using System.Linq; namespace Content.Server.Objectives.Systems; @@ -52,8 +53,18 @@ private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref if (target.Target != null) return; - // no other humans to kill var allHumans = _mind.GetAliveHumans(args.MindId); + + // Can't have multiple objectives to kill the same person + foreach (var objective in args.Mind.Objectives) + { + if (HasComp(objective) && TryComp(objective, out var kill)) + { + allHumans.RemoveWhere(x => x.Owner == kill.Target); + } + } + + // no other humans to kill if (allHumans.Count == 0) { args.Cancelled = true;