fix several traitor objective bugs (#12212)
This commit is contained in:
@@ -3,13 +3,11 @@ using Content.Server.Chat.Managers;
|
|||||||
using Content.Server.Objectives.Interfaces;
|
using Content.Server.Objectives.Interfaces;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Server.Roles;
|
using Content.Server.Roles;
|
||||||
using Content.Server.Store.Systems;
|
|
||||||
using Content.Server.Traitor;
|
using Content.Server.Traitor;
|
||||||
using Content.Server.Traitor.Uplink;
|
using Content.Server.Traitor.Uplink;
|
||||||
|
using Content.Server.MobState;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Dataset;
|
using Content.Shared.Dataset;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
|
||||||
using Content.Shared.Inventory;
|
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -29,11 +27,10 @@ public sealed class TraitorRuleSystem : GameRuleSystem
|
|||||||
[Dependency] private readonly IObjectivesManager _objectivesManager = default!;
|
[Dependency] private readonly IObjectivesManager _objectivesManager = default!;
|
||||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
|
||||||
[Dependency] private readonly StoreSystem _store = default!;
|
|
||||||
[Dependency] private readonly UplinkSystem _uplink = default!;
|
[Dependency] private readonly UplinkSystem _uplink = default!;
|
||||||
|
|
||||||
|
|
||||||
public override string Prototype => "Traitor";
|
public override string Prototype => "Traitor";
|
||||||
|
|
||||||
private readonly SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
|
private readonly SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
|
||||||
@@ -322,4 +319,18 @@ public sealed class TraitorRuleSystem : GameRuleSystem
|
|||||||
}
|
}
|
||||||
ev.AddLine(result);
|
ev.AddLine(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Traitor.TraitorRole> GetOtherTraitorsAliveAndConnected(Mind.Mind ourMind)
|
||||||
|
{
|
||||||
|
var traitors = Traitors;
|
||||||
|
List<Traitor.TraitorRole> 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
if (Target == null)
|
if (Target == null)
|
||||||
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
|
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
|
||||||
|
|
||||||
if (Target.CharacterName != null)
|
if (Target.OwnedEntity is {Valid: true} owned)
|
||||||
targetName = Target.CharacterName;
|
|
||||||
else if (Target.OwnedEntity is {Valid: true} owned)
|
|
||||||
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
||||||
|
|
||||||
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
|
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using Content.Server.Objectives.Interfaces;
|
using Content.Server.Objectives.Interfaces;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -13,27 +14,7 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||||
{
|
{
|
||||||
var entityMgr = IoCManager.Resolve<IEntityManager>();
|
var entityMgr = IoCManager.Resolve<IEntityManager>();
|
||||||
var traitors = EntitySystem.Get<TraitorRuleSystem>().Traitors;
|
var traitors = entityMgr.EntitySysManager.GetEntitySystem<TraitorRuleSystem>().GetOtherTraitorsAliveAndConnected(mind).ToList();
|
||||||
List<Traitor.TraitorRole> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (traitors.Count == 0) return new EscapeShuttleCondition{}; //You were made a traitor by admins, and are the first/only.
|
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<IRobustRandom>().Pick(traitors).Mind };
|
return new RandomTraitorAliveCondition { _target = IoCManager.Resolve<IRobustRandom>().Pick(traitors).Mind };
|
||||||
@@ -49,9 +30,7 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
if (_target == null)
|
if (_target == null)
|
||||||
return Loc.GetString("objective-condition-other-traitor-alive-title", ("targetName", targetName), ("job", jobName));
|
return Loc.GetString("objective-condition-other-traitor-alive-title", ("targetName", targetName), ("job", jobName));
|
||||||
|
|
||||||
if (_target.CharacterName != null)
|
if (_target.OwnedEntity is {Valid: true} owned)
|
||||||
targetName = _target.CharacterName;
|
|
||||||
else if (_target.OwnedEntity is {Valid: true} owned)
|
|
||||||
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
||||||
|
|
||||||
return Loc.GetString("objective-condition-other-traitor-alive-title", ("targetName", targetName), ("job", jobName));
|
return Loc.GetString("objective-condition-other-traitor-alive-title", ("targetName", targetName), ("job", jobName));
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using Content.Server.Objectives.Interfaces;
|
using Content.Server.Objectives.Interfaces;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -13,21 +14,11 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||||
{
|
{
|
||||||
var entityMgr = IoCManager.Resolve<IEntityManager>();
|
var entityMgr = IoCManager.Resolve<IEntityManager>();
|
||||||
var traitors = EntitySystem.Get<TraitorRuleSystem>().Traitors;
|
var traitors = entityMgr.EntitySysManager.GetEntitySystem<TraitorRuleSystem>().GetOtherTraitorsAliveAndConnected(mind).ToList();
|
||||||
List<Traitor.TraitorRole> removeList = new();
|
List<Traitor.TraitorRole> removeList = new();
|
||||||
|
|
||||||
foreach (var traitor in traitors)
|
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 objective in traitor.Mind.AllObjectives)
|
||||||
{
|
{
|
||||||
foreach (var condition in objective.Conditions)
|
foreach (var condition in objective.Conditions)
|
||||||
@@ -59,9 +50,7 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
if (_target == null)
|
if (_target == null)
|
||||||
return Loc.GetString("objective-condition-other-traitor-progress-title", ("targetName", targetName), ("job", jobName));
|
return Loc.GetString("objective-condition-other-traitor-progress-title", ("targetName", targetName), ("job", jobName));
|
||||||
|
|
||||||
if (_target.CharacterName != null)
|
if (_target.OwnedEntity is {Valid: true} owned)
|
||||||
targetName = _target.CharacterName;
|
|
||||||
else if (_target.OwnedEntity is {Valid: true} owned)
|
|
||||||
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
||||||
|
|
||||||
return Loc.GetString("objective-condition-other-traitor-progress-title", ("targetName", targetName), ("job", jobName));
|
return Loc.GetString("objective-condition-other-traitor-progress-title", ("targetName", targetName), ("job", jobName));
|
||||||
|
|||||||
Reference in New Issue
Block a user