Traitor can no longer get multiple objectives to save/help/kill the same person (#33704)
* Deduplicate traitor objectives * Remove redundant check
This commit is contained in:
@@ -45,10 +45,7 @@ public sealed class HelpProgressConditionSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var traitors = _traitorRule.GetOtherTraitorMindsAliveAndConnected(args.Mind)
|
var traitors = _traitorRule.GetOtherTraitorMindsAliveAndConnected(args.Mind).ToHashSet();
|
||||||
.Select(pair => pair.Item1)
|
|
||||||
.ToHashSet();
|
|
||||||
var removeList = new List<EntityUid>();
|
|
||||||
|
|
||||||
// cant help anyone who is tasked with helping:
|
// cant help anyone who is tasked with helping:
|
||||||
// 1. thats boring
|
// 1. thats boring
|
||||||
@@ -56,19 +53,26 @@ public sealed class HelpProgressConditionSystem : EntitySystem
|
|||||||
foreach (var traitor in traitors)
|
foreach (var traitor in traitors)
|
||||||
{
|
{
|
||||||
// TODO: replace this with TryComp<ObjectivesComponent>(traitor) or something when objectives are moved out of mind
|
// TODO: replace this with TryComp<ObjectivesComponent>(traitor) or something when objectives are moved out of mind
|
||||||
if (!TryComp<MindComponent>(traitor, out var mind))
|
if (!TryComp<MindComponent>(traitor.Id, out var mind))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (var objective in mind.Objectives)
|
foreach (var objective in mind.Objectives)
|
||||||
{
|
{
|
||||||
if (HasComp<HelpProgressConditionComponent>(objective))
|
if (HasComp<HelpProgressConditionComponent>(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<RandomTraitorAliveComponent>(objective) || HasComp<RandomTraitorProgressComponent>(objective))
|
||||||
|
{
|
||||||
|
if (TryComp<TargetObjectiveComponent>(objective, out var help))
|
||||||
|
{
|
||||||
|
traitors.RemoveWhere(x => x.Id == help.Target);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no more helpable traitors
|
// no more helpable traitors
|
||||||
@@ -78,7 +82,7 @@ public sealed class HelpProgressConditionSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_target.SetTarget(uid, _random.Pick(traitors), target);
|
_target.SetTarget(uid, _random.Pick(traitors).Id, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetProgress(EntityUid target)
|
private float GetProgress(EntityUid target)
|
||||||
|
|||||||
@@ -44,7 +44,19 @@ public sealed class KeepAliveConditionSystem : EntitySystem
|
|||||||
return;
|
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<RandomTraitorAliveComponent>(objective) || HasComp<RandomTraitorProgressComponent>(objective))
|
||||||
|
{
|
||||||
|
if (TryComp<TargetObjectiveComponent>(objective, out var help))
|
||||||
|
{
|
||||||
|
traitors.RemoveWhere(x => x.Id == help.Target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// You are the first/only traitor.
|
// You are the first/only traitor.
|
||||||
if (traitors.Count == 0)
|
if (traitors.Count == 0)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Shared.Mind;
|
|||||||
using Content.Shared.Objectives.Components;
|
using Content.Shared.Objectives.Components;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Content.Server.Objectives.Systems;
|
namespace Content.Server.Objectives.Systems;
|
||||||
|
|
||||||
@@ -52,8 +53,18 @@ public sealed class KillPersonConditionSystem : EntitySystem
|
|||||||
if (target.Target != null)
|
if (target.Target != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// no other humans to kill
|
|
||||||
var allHumans = _mind.GetAliveHumans(args.MindId);
|
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<KillPersonConditionComponent>(objective) && TryComp<TargetObjectiveComponent>(objective, out var kill))
|
||||||
|
{
|
||||||
|
allHumans.RemoveWhere(x => x.Owner == kill.Target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no other humans to kill
|
||||||
if (allHumans.Count == 0)
|
if (allHumans.Count == 0)
|
||||||
{
|
{
|
||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user