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

@@ -20,6 +20,7 @@ using Content.Shared.Damage.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.MobState.Components;
using Content.Shared.PDA;
using Content.Shared.Roles;
using Content.Shared.Traitor.Uplink;
using Robust.Server.Player;
using Robust.Shared.Configuration;
@@ -52,6 +53,8 @@ public class TraitorDeathMatchRuleSystem : GameRuleSystem
private readonly Dictionary<UplinkAccount, string> _allOriginalNames = new();
private const string TraitorPrototypeID = "Traitor";
public override void Initialize()
{
base.Initialize();
@@ -77,7 +80,8 @@ public class TraitorDeathMatchRuleSystem : GameRuleSystem
return;
}
var traitorRole = new TraitorRole(mind);
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);
var traitorRole = new TraitorRole(mind, antagPrototype);
mind.AddRole(traitorRole);
// Delete anything that may contain "dangerous" role-specific items.

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);
}

View File

@@ -1,5 +1,6 @@
using Content.Server.Chat.Managers;
using Content.Server.Roles;
using Content.Shared.Roles;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -7,12 +8,17 @@ namespace Content.Server.Traitor
{
public class TraitorRole : Role
{
public TraitorRole(Mind.Mind mind) : base(mind)
public AntagPrototype Prototype { get; }
public TraitorRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
{
Prototype = antagPrototype;
Name = antagPrototype.Name;
Antagonist = antagPrototype.Antagonist;
}
public override string Name => Loc.GetString("traitor-role-name");
public override bool Antagonist => true;
public override string Name { get; }
public override bool Antagonist { get; }
public void GreetTraitor(string[] codewords)
{

View File

@@ -39,6 +39,5 @@ traitor-death-match-end-round-description-entry = {$originalName}'s PDA, with {$
## TraitorRole
# TraitorRole
traitor-role-name = Syndicate Agent
traitor-role-greeting = Hello Agent
traitor-role-codewords = Your codewords are: {$codewords}

View File

@@ -1,6 +1,6 @@
- type: antag
id: SuspicionInnocent
name: "innocent"
name: "Innocent"
antagonist: false
setPreference: false
objective: "Discover and eliminate all traitors."

View File

@@ -1,6 +1,6 @@
- type: antag
id: SuspicionTraitor
name: "suspect"
name: "Suspect"
antagonist: true
setPreference: true
objective: "Kill the innocents."

View File

@@ -1,6 +1,6 @@
- type: antag
id: Traitor
name: "traitor"
name: "Syndicate Agent"
antagonist: true
setPreference: true
objective: "Complete your objectives without being caught."