diff --git a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs index dcb3b5dcad..2dbe908ea4 100644 --- a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs @@ -3,13 +3,11 @@ using Content.Server.Chat.Managers; using Content.Server.Objectives.Interfaces; using Content.Server.Players; using Content.Server.Roles; -using Content.Server.Store.Systems; using Content.Server.Traitor; using Content.Server.Traitor.Uplink; +using Content.Server.MobState; using Content.Shared.CCVar; using Content.Shared.Dataset; -using Content.Shared.Hands.EntitySystems; -using Content.Shared.Inventory; using Content.Shared.Roles; using Robust.Server.Player; using Robust.Shared.Audio; @@ -29,11 +27,10 @@ public sealed class TraitorRuleSystem : GameRuleSystem [Dependency] private readonly IObjectivesManager _objectivesManager = default!; [Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly GameTicker _gameTicker = default!; - [Dependency] private readonly InventorySystem _inventorySystem = default!; - [Dependency] private readonly SharedHandsSystem _hands = default!; - [Dependency] private readonly StoreSystem _store = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly UplinkSystem _uplink = default!; + public override string Prototype => "Traitor"; private readonly SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg"); @@ -322,4 +319,18 @@ public sealed class TraitorRuleSystem : GameRuleSystem } ev.AddLine(result); } + + public IEnumerable GetOtherTraitorsAliveAndConnected(Mind.Mind ourMind) + { + var traitors = Traitors; + List removeList = new(); + + return Traitors // don't want + .Where(t => t.Mind is not null) // no mind + .Where(t => t.Mind.OwnedEntity is not null) // no entity + .Where(t => t.Mind.Session is not null) // player disconnected + .Where(t => t.Mind != ourMind) // ourselves + .Where(t => _mobStateSystem.IsAlive((EntityUid) t.Mind.OwnedEntity!)) // dead + .Where(t => t.Mind.CurrentEntity == t.Mind.OwnedEntity); // not in original body + } } diff --git a/Content.Server/Objectives/Conditions/KillPersonCondition.cs b/Content.Server/Objectives/Conditions/KillPersonCondition.cs index 3e1366b108..86f28feb2f 100644 --- a/Content.Server/Objectives/Conditions/KillPersonCondition.cs +++ b/Content.Server/Objectives/Conditions/KillPersonCondition.cs @@ -18,9 +18,7 @@ namespace Content.Server.Objectives.Conditions if (Target == null) return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); - if (Target.CharacterName != null) - targetName = Target.CharacterName; - else if (Target.OwnedEntity is {Valid: true} owned) + if (Target.OwnedEntity is {Valid: true} owned) targetName = IoCManager.Resolve().GetComponent(owned).EntityName; return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); diff --git a/Content.Server/Objectives/Conditions/RandomTraitorAliveCondition.cs b/Content.Server/Objectives/Conditions/RandomTraitorAliveCondition.cs index 787dfcdd52..8906a2b737 100644 --- a/Content.Server/Objectives/Conditions/RandomTraitorAliveCondition.cs +++ b/Content.Server/Objectives/Conditions/RandomTraitorAliveCondition.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server.Objectives.Interfaces; using Robust.Shared.Random; using Robust.Shared.Utility; @@ -13,27 +14,7 @@ namespace Content.Server.Objectives.Conditions public IObjectiveCondition GetAssigned(Mind.Mind mind) { var entityMgr = IoCManager.Resolve(); - var traitors = EntitySystem.Get().Traitors; - List removeList = new(); - - foreach (var traitor in traitors) - { - if (traitor.Mind == null) - { - removeList.Add(traitor); - continue; - } - if (traitor.Mind == mind) // we have different objectives for defending ourselves. - { - removeList.Add(traitor); - continue; - } - } - - foreach (var traitor in removeList) - { - traitors.Remove(traitor); - } + var traitors = entityMgr.EntitySysManager.GetEntitySystem().GetOtherTraitorsAliveAndConnected(mind).ToList(); if (traitors.Count == 0) return new EscapeShuttleCondition{}; //You were made a traitor by admins, and are the first/only. return new RandomTraitorAliveCondition { _target = IoCManager.Resolve().Pick(traitors).Mind }; @@ -49,9 +30,7 @@ namespace Content.Server.Objectives.Conditions if (_target == null) return Loc.GetString("objective-condition-other-traitor-alive-title", ("targetName", targetName), ("job", jobName)); - if (_target.CharacterName != null) - targetName = _target.CharacterName; - else if (_target.OwnedEntity is {Valid: true} owned) + if (_target.OwnedEntity is {Valid: true} owned) targetName = IoCManager.Resolve().GetComponent(owned).EntityName; return Loc.GetString("objective-condition-other-traitor-alive-title", ("targetName", targetName), ("job", jobName)); diff --git a/Content.Server/Objectives/Conditions/RandomTraitorProgressCondition.cs b/Content.Server/Objectives/Conditions/RandomTraitorProgressCondition.cs index 95a9d11726..e11dba815d 100644 --- a/Content.Server/Objectives/Conditions/RandomTraitorProgressCondition.cs +++ b/Content.Server/Objectives/Conditions/RandomTraitorProgressCondition.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server.Objectives.Interfaces; using Robust.Shared.Random; using Robust.Shared.Utility; @@ -13,21 +14,11 @@ namespace Content.Server.Objectives.Conditions public IObjectiveCondition GetAssigned(Mind.Mind mind) { var entityMgr = IoCManager.Resolve(); - var traitors = EntitySystem.Get().Traitors; + var traitors = entityMgr.EntitySysManager.GetEntitySystem().GetOtherTraitorsAliveAndConnected(mind).ToList(); List removeList = new(); foreach (var traitor in traitors) { - if (traitor.Mind == null) - { - removeList.Add(traitor); - continue; - } - if (traitor.Mind == mind) - { - removeList.Add(traitor); - continue; - } foreach (var objective in traitor.Mind.AllObjectives) { foreach (var condition in objective.Conditions) @@ -59,9 +50,7 @@ namespace Content.Server.Objectives.Conditions if (_target == null) return Loc.GetString("objective-condition-other-traitor-progress-title", ("targetName", targetName), ("job", jobName)); - if (_target.CharacterName != null) - targetName = _target.CharacterName; - else if (_target.OwnedEntity is {Valid: true} owned) + if (_target.OwnedEntity is {Valid: true} owned) targetName = IoCManager.Resolve().GetComponent(owned).EntityName; return Loc.GetString("objective-condition-other-traitor-progress-title", ("targetName", targetName), ("job", jobName));