Add AntagPrototype to TraitorRole and Fix traitors choice logic (#5861)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- type: antag
|
||||
id: SuspicionInnocent
|
||||
name: "innocent"
|
||||
name: "Innocent"
|
||||
antagonist: false
|
||||
setPreference: false
|
||||
objective: "Discover and eliminate all traitors."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- type: antag
|
||||
id: SuspicionTraitor
|
||||
name: "suspect"
|
||||
name: "Suspect"
|
||||
antagonist: true
|
||||
setPreference: true
|
||||
objective: "Kill the innocents."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- type: antag
|
||||
id: Traitor
|
||||
name: "traitor"
|
||||
name: "Syndicate Agent"
|
||||
antagonist: true
|
||||
setPreference: true
|
||||
objective: "Complete your objectives without being caught."
|
||||
|
||||
Reference in New Issue
Block a user