Add AntagPrototype to TraitorRole and Fix traitors choice logic (#5861)

This commit is contained in:
Morbo
2021-12-26 06:13:37 +03:00
committed by GitHub
parent 651c11888f
commit 7d28108572
7 changed files with 24 additions and 11 deletions

View File

@@ -10,6 +10,7 @@ using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Shared.CCVar;
using Content.Shared.Dataset;
using Content.Shared.Roles;
using Content.Shared.Sound;
using Content.Shared.Traitor.Uplink;
using Robust.Server.Player;
@@ -39,6 +40,8 @@ public class TraitorRuleSystem : GameRuleSystem
private readonly SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
private readonly List<TraitorRole> _traitors = new ();
private const string TraitorPrototypeID = "Traitor";
public override void Initialize()
{
base.Initialize();
@@ -105,7 +108,7 @@ public class TraitorRuleSystem : GameRuleSystem
continue;
}
var profile = ev.Profiles[player.UserId];
if (profile.AntagPreferences.Contains("Traitor"))
if (profile.AntagPreferences.Contains(TraitorPrototypeID))
{
prefList.Add(player);
}
@@ -117,7 +120,7 @@ public class TraitorRuleSystem : GameRuleSystem
for (var i = 0; i < numTraitors; i++)
{
IPlayerSession traitor;
if(prefList.Count < numTraitors)
if(prefList.Count == 0)
{
if (list.Count == 0)
{
@@ -153,7 +156,8 @@ public class TraitorRuleSystem : GameRuleSystem
.AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
continue;
var traitorRole = new TraitorRole(mind);
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);
var traitorRole = new TraitorRole(mind, antagPrototype);
mind.AddRole(traitorRole);
_traitors.Add(traitorRole);
}