using Content.Shared.GameTicking;
using Content.Shared.Hands.Components;
using Content.Shared.Inventory;
+using Content.Shared.NPC.Prototypes;
using Content.Shared.NPC.Systems;
using Content.Shared.NukeOps;
using Content.Shared.Pinpointer;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Map.Components;
+using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.GameRules;
[TestFixture]
public sealed class NukeOpsTest
{
+ private static readonly ProtoId<NpcFactionPrototype> SyndicateFaction = "Syndicate";
+ private static readonly ProtoId<NpcFactionPrototype> NanotrasenFaction = "NanoTrasen";
+
/// <summary>
/// Check that a nuke ops game mode can start without issue. I.e., that the nuke station and such all get loaded.
/// </summary>
Assert.That(entMan.HasComponent<NukeOperativeComponent>(player));
Assert.That(roleSys.MindIsAntagonist(mind));
Assert.That(roleSys.MindHasRole<NukeopsRoleComponent>(mind));
- Assert.That(factionSys.IsMember(player, "Syndicate"), Is.True);
- Assert.That(factionSys.IsMember(player, "NanoTrasen"), Is.False);
+ Assert.That(factionSys.IsMember(player, SyndicateFaction), Is.True);
+ Assert.That(factionSys.IsMember(player, NanotrasenFaction), Is.False);
var roles = roleSys.MindGetAllRoleInfo(mind);
var cmdRoles = roles.Where(x => x.Prototype == "NukeopsCommander");
Assert.That(cmdRoles.Count(), Is.EqualTo(1));
Assert.That(entMan.HasComponent<NukeOperativeComponent>(dummyEnts[1]));
Assert.That(roleSys.MindIsAntagonist(dummyMind));
Assert.That(roleSys.MindHasRole<NukeopsRoleComponent>(dummyMind));
- Assert.That(factionSys.IsMember(dummyEnts[1], "Syndicate"), Is.True);
- Assert.That(factionSys.IsMember(dummyEnts[1], "NanoTrasen"), Is.False);
+ Assert.That(factionSys.IsMember(dummyEnts[1], SyndicateFaction), Is.True);
+ Assert.That(factionSys.IsMember(dummyEnts[1], NanotrasenFaction), Is.False);
roles = roleSys.MindGetAllRoleInfo(dummyMind);
cmdRoles = roles.Where(x => x.Prototype == "NukeopsMedic");
Assert.That(cmdRoles.Count(), Is.EqualTo(1));
Assert.That(entMan.HasComponent<NukeOperativeComponent>(ent), Is.False);
Assert.That(roleSys.MindIsAntagonist(mindCrew), Is.False);
Assert.That(roleSys.MindHasRole<NukeopsRoleComponent>(mindCrew), Is.False);
- Assert.That(factionSys.IsMember(ent, "Syndicate"), Is.False);
- Assert.That(factionSys.IsMember(ent, "NanoTrasen"), Is.True);
+ Assert.That(factionSys.IsMember(ent, SyndicateFaction), Is.False);
+ Assert.That(factionSys.IsMember(ent, NanotrasenFaction), Is.True);
var nukeroles = new List<string>() { "Nukeops", "NukeopsMedic", "NukeopsCommander" };
Assert.That(roleSys.MindGetAllRoleInfo(mindCrew).Any(x => nukeroles.Contains(x.Prototype)), Is.False);
}
using Content.Shared.GameTicking;
using Content.Shared.GameTicking.Components;
using Content.Shared.Mind;
+using Content.Shared.NPC.Prototypes;
using Content.Shared.NPC.Systems;
using Content.Shared.Objectives.Components;
using Robust.Shared.GameObjects;
{
private const string TraitorGameRuleProtoId = "Traitor";
private const string TraitorAntagRoleName = "Traitor";
+ private static readonly ProtoId<NpcFactionPrototype> SyndicateFaction = "Syndicate";
+ private static readonly ProtoId<NpcFactionPrototype> NanotrasenFaction = "NanoTrasen";
[Test]
public async Task TestTraitorObjectives()
// Make sure the player is a traitor.
var mind = mindSys.GetMind(player)!.Value;
Assert.That(roleSys.MindIsAntagonist(mind));
- Assert.That(factionSys.IsMember(player, "Syndicate"), Is.True);
- Assert.That(factionSys.IsMember(player, "NanoTrasen"), Is.False);
+ Assert.That(factionSys.IsMember(player, SyndicateFaction), Is.True);
+ Assert.That(factionSys.IsMember(player, NanotrasenFaction), Is.False);
Assert.That(traitorRule.TotalTraitors, Is.EqualTo(1));
Assert.That(traitorRule.TraitorMinds[0], Is.EqualTo(mind));
using Content.Shared.Tag;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
+using Content.Shared.NPC.Prototypes;
namespace Content.Server.Zombies;
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
+ private static readonly ProtoId<NpcFactionPrototype> ZombieFaction = "Zombie";
+
/// <summary>
/// Handles an entity turning into a zombie when they die or go into crit
/// </summary>
_mobState.ChangeMobState(target, MobState.Alive);
_faction.ClearFactions(target, dirty: false);
- _faction.AddFaction(target, "Zombie");
+ _faction.AddFaction(target, ZombieFaction);
//gives it the funny "Zombie ___" name.
_nameMod.RefreshNameModifiers(target);
/// <summary>
/// Returns whether an entity is a member of a faction.
/// </summary>
- public bool IsMember(Entity<NpcFactionMemberComponent?> ent, string faction)
+ public bool IsMember(Entity<NpcFactionMemberComponent?> ent, [ForbidLiteral] string faction)
{
if (!Resolve(ent, ref ent.Comp, false))
return false;
/// Returns whether an entity is a member of any listed faction.
/// If the list is empty this returns false.
/// </summary>
- public bool IsMemberOfAny(Entity<NpcFactionMemberComponent?> ent, IEnumerable<ProtoId<NpcFactionPrototype>> factions)
+ public bool IsMemberOfAny(Entity<NpcFactionMemberComponent?> ent, [ForbidLiteral] IEnumerable<ProtoId<NpcFactionPrototype>> factions)
{
if (!Resolve(ent, ref ent.Comp, false))
return false;
/// <summary>
/// Adds this entity to the particular faction.
/// </summary>
- public void AddFaction(Entity<NpcFactionMemberComponent?> ent, string faction, bool dirty = true)
+ public void AddFaction(Entity<NpcFactionMemberComponent?> ent, [ForbidLiteral] string faction, bool dirty = true)
{
if (!_proto.HasIndex<NpcFactionPrototype>(faction))
{
/// <summary>
/// Adds this entity to the particular faction.
/// </summary>
- public void AddFactions(Entity<NpcFactionMemberComponent?> ent, HashSet<ProtoId<NpcFactionPrototype>> factions, bool dirty = true)
+ public void AddFactions(Entity<NpcFactionMemberComponent?> ent, [ForbidLiteral] HashSet<ProtoId<NpcFactionPrototype>> factions, bool dirty = true)
{
ent.Comp ??= EnsureComp<NpcFactionMemberComponent>(ent);
/// <summary>
/// Removes this entity from the particular faction.
/// </summary>
- public void RemoveFaction(Entity<NpcFactionMemberComponent?> ent, string faction, bool dirty = true)
+ public void RemoveFaction(Entity<NpcFactionMemberComponent?> ent, [ForbidLiteral] string faction, bool dirty = true)
{
if (!_proto.HasIndex<NpcFactionPrototype>(faction))
{
return GetNearbyFactions(ent, range, ent.Comp.FriendlyFactions);
}
- private IEnumerable<EntityUid> GetNearbyFactions(EntityUid entity, float range, HashSet<ProtoId<NpcFactionPrototype>> factions)
+ private IEnumerable<EntityUid> GetNearbyFactions(EntityUid entity, float range, [ForbidLiteral] HashSet<ProtoId<NpcFactionPrototype>> factions)
{
var xform = Transform(entity);
foreach (var ent in _lookup.GetEntitiesInRange<NpcFactionMemberComponent>(_xform.GetMapCoordinates((entity, xform)), range))
return ent.Comp.Factions.Overlaps(other.Comp.Factions) || ent.Comp.FriendlyFactions.Overlaps(other.Comp.Factions);
}
- public bool IsFactionFriendly(string target, string with)
+ public bool IsFactionFriendly([ForbidLiteral] string target, [ForbidLiteral] string with)
{
return _factions[target].Friendly.Contains(with) && _factions[with].Friendly.Contains(target);
}
- public bool IsFactionFriendly(string target, Entity<NpcFactionMemberComponent?> with)
+ public bool IsFactionFriendly([ForbidLiteral] string target, Entity<NpcFactionMemberComponent?> with)
{
if (!Resolve(with, ref with.Comp, false))
return false;
with.Comp.FriendlyFactions.Contains(target);
}
- public bool IsFactionHostile(string target, string with)
+ public bool IsFactionHostile([ForbidLiteral] string target, [ForbidLiteral] string with)
{
return _factions[target].Hostile.Contains(with) && _factions[with].Hostile.Contains(target);
}
- public bool IsFactionHostile(string target, Entity<NpcFactionMemberComponent?> with)
+ public bool IsFactionHostile([ForbidLiteral] string target, Entity<NpcFactionMemberComponent?> with)
{
if (!Resolve(with, ref with.Comp, false))
return false;
with.Comp.HostileFactions.Contains(target);
}
- public bool IsFactionNeutral(string target, string with)
+ public bool IsFactionNeutral([ForbidLiteral] string target, [ForbidLiteral] string with)
{
return !IsFactionFriendly(target, with) && !IsFactionHostile(target, with);
}
/// <summary>
/// Makes the source faction friendly to the target faction, 1-way.
/// </summary>
- public void MakeFriendly(string source, string target)
+ public void MakeFriendly([ForbidLiteral] string source, [ForbidLiteral] string target)
{
if (!_factions.TryGetValue(source, out var sourceFaction))
{
/// <summary>
/// Makes the source faction hostile to the target faction, 1-way.
/// </summary>
- public void MakeHostile(string source, string target)
+ public void MakeHostile([ForbidLiteral] string source, [ForbidLiteral] string target)
{
if (!_factions.TryGetValue(source, out var sourceFaction))
{