mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-21 15:38:52 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description the adding AI is now up to y'all because i'm not touching loadout code for name datasets, but it shouldn't be too bad from here --------- Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Signed-off-by: SolStar <44028047+ewokswagger@users.noreply.github.com> Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: themias <89101928+themias@users.noreply.github.com> Co-authored-by: Verm <32827189+Vermidia@users.noreply.github.com> Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: Sphiral <145869023+SphiraI@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: Alzore <140123969+Blackern5000@users.noreply.github.com> Co-authored-by: ravage <142820619+ravage123321@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: Intoxicating-Innocence <188202277+Intoxicating-Innocence@users.noreply.github.com> Co-authored-by: Saphire <lattice@saphi.re> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: CaasGit <87243814+CaasGit@users.noreply.github.com> Co-authored-by: BramvanZijp <56019239+BramvanZijp@users.noreply.github.com> Co-authored-by: Boaz1111 <149967078+Boaz1111@users.noreply.github.com> Co-authored-by: NakataRin <45946146+NakataRin@users.noreply.github.com> Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com> Co-authored-by: Doomsdrayk <robotdoughnut@comcast.net> Co-authored-by: Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com> Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Julian Giebel <juliangiebel@live.de> Co-authored-by: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Co-authored-by: Repo <47093363+Titian3@users.noreply.github.com> Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Co-authored-by: icekot8 <93311212+icekot8@users.noreply.github.com> Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: no <165581243+pissdemon@users.noreply.github.com> Co-authored-by: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com> Co-authored-by: osjarw <62134478+osjarw@users.noreply.github.com> Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> Co-authored-by: TGRCDev <tgrc@tgrc.dev> Co-authored-by: Milon <milonpl.git@proton.me> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: Fildrance <fildrance@gmail.com> Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> Co-authored-by: chavonadelal <156101927+chavonadelal@users.noreply.github.com> Co-authored-by: SolStar <44028047+ewokswagger@users.noreply.github.com> Co-authored-by: K-Dynamic <20566341+K-Dynamic@users.noreply.github.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: ArchRBX <5040911+ArchRBX@users.noreply.github.com> Co-authored-by: archrbx <punk.gear5260@fastmail.com> Co-authored-by: Radezolid <snappednexus@gmail.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com> Co-authored-by: MilenVolf <63782763+MilenVolf@users.noreply.github.com> Co-authored-by: Velcroboy <107660393+IamVelcroboy@users.noreply.github.com> Co-authored-by: Velcroboy <velcroboy333@hotmail.com> Co-authored-by: neuPanda <chriseparton@gmail.com> Co-authored-by: neuPanda <spainman0@yahoo.com> Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com> Co-authored-by: Whatstone <whatston3@gmail.com> Co-authored-by: VideoKompany <135313844+VlaDOS1408@users.noreply.github.com> (cherry picked from commit 93ed70acfeda357133a701f637d3faeec02749bb)
226 lines
11 KiB
C#
226 lines
11 KiB
C#
/* WD edit
|
|
|
|
#nullable enable
|
|
using System.Linq;
|
|
using Content.Server.Body.Components;
|
|
using Content.Server.GameTicking;
|
|
using Content.Server.GameTicking.Presets;
|
|
using Content.Server.GameTicking.Rules.Components;
|
|
using Content.Server.Mind;
|
|
using Content.Server.NPC.Systems;
|
|
using Content.Server.Pinpointer;
|
|
using Content.Server.Roles;
|
|
using Content.Server.Shuttles.Components;
|
|
using Content.Server.Station.Components;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.NPC.Systems;
|
|
using Content.Shared.NukeOps;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.IntegrationTests.Tests.GameRules;
|
|
|
|
[TestFixture]
|
|
public sealed class NukeOpsTest
|
|
{
|
|
/// <summary>
|
|
/// Check that a nuke ops game mode can start without issue. I.e., that the nuke station and such all get loaded.
|
|
/// </summary>
|
|
[Test]
|
|
public async Task TryStopNukeOpsFromConstantlyFailing()
|
|
{
|
|
await using var pair = await PoolManager.GetServerClient(new PoolSettings
|
|
{
|
|
Dirty = true,
|
|
DummyTicker = false,
|
|
Connected = true,
|
|
InLobby = true
|
|
});
|
|
|
|
var server = pair.Server;
|
|
var client = pair.Client;
|
|
var entMan = server.EntMan;
|
|
var mapSys = server.System<MapSystem>();
|
|
var ticker = server.System<GameTicker>();
|
|
var mindSys = server.System<MindSystem>();
|
|
var roleSys = server.System<RoleSystem>();
|
|
var invSys = server.System<InventorySystem>();
|
|
var factionSys = server.System<NpcFactionSystem>();
|
|
|
|
server.CfgMan.SetCVar(CCVars.GridFill, true);
|
|
|
|
// Initially in the lobby
|
|
Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
|
|
Assert.That(client.AttachedEntity, Is.Null);
|
|
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.NotReadyToPlay));
|
|
|
|
// Opt into the nukies role.
|
|
await pair.SetAntagPref("NukeopsCommander", true);
|
|
|
|
// There are no grids or maps
|
|
Assert.That(entMan.Count<MapComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<MapGridComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<StationMapComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<StationMemberComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<StationCentcommComponent>(), Is.Zero);
|
|
|
|
// And no nukie related components
|
|
Assert.That(entMan.Count<NukeopsRuleComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<NukeopsRoleComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<NukeOperativeComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<NukeOpsShuttleComponent>(), Is.Zero);
|
|
Assert.That(entMan.Count<NukeOperativeSpawnerComponent>(), Is.Zero);
|
|
|
|
// Ready up and start nukeops
|
|
await pair.WaitClientCommand("toggleready True");
|
|
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.ReadyToPlay));
|
|
await pair.WaitCommand("forcepreset Nukeops");
|
|
await pair.RunTicksSync(10);
|
|
|
|
// Game should have started
|
|
Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
|
|
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.JoinedGame));
|
|
Assert.That(client.EntMan.EntityExists(client.AttachedEntity));
|
|
var player = pair.Player!.AttachedEntity!.Value;
|
|
Assert.That(entMan.EntityExists(player));
|
|
|
|
// Maps now exist
|
|
Assert.That(entMan.Count<MapComponent>(), Is.GreaterThan(0));
|
|
Assert.That(entMan.Count<MapGridComponent>(), Is.GreaterThan(0));
|
|
Assert.That(entMan.Count<StationDataComponent>(), Is.EqualTo(2)); // The main station & nukie station
|
|
Assert.That(entMan.Count<StationMemberComponent>(), Is.GreaterThan(3)); // Each station has at least 1 grid, plus some shuttles
|
|
Assert.That(entMan.Count<StationCentcommComponent>(), Is.EqualTo(1));
|
|
|
|
// And we now have nukie related components
|
|
Assert.That(entMan.Count<NukeopsRuleComponent>(), Is.EqualTo(1));
|
|
Assert.That(entMan.Count<NukeopsRoleComponent>(), Is.EqualTo(1));
|
|
Assert.That(entMan.Count<NukeOperativeComponent>(), Is.EqualTo(1));
|
|
Assert.That(entMan.Count<NukeOpsShuttleComponent>(), Is.EqualTo(1));
|
|
|
|
// The player entity should be the nukie commander
|
|
var mind = mindSys.GetMind(player)!.Value;
|
|
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);
|
|
|
|
var roles = roleSys.MindGetAllRoles(mind);
|
|
var cmdRoles = roles.Where(x => x.Prototype == "NukeopsCommander" && x.Component is NukeopsRoleComponent);
|
|
Assert.That(cmdRoles.Count(), Is.EqualTo(1));
|
|
|
|
// The game rule exists, and all the stations/shuttles/maps are properly initialized
|
|
var rule = entMan.AllComponents<NukeopsRuleComponent>().Single().Component;
|
|
var mapRule = entMan.AllComponents<LoadMapRuleComponent>().Single().Component;
|
|
foreach (var grid in mapRule.MapGrids)
|
|
{
|
|
Assert.That(entMan.EntityExists(grid));
|
|
Assert.That(entMan.HasComponent<MapGridComponent>(grid));
|
|
Assert.That(entMan.HasComponent<StationMemberComponent>(grid));
|
|
}
|
|
Assert.That(entMan.EntityExists(rule.NukieOutpost));
|
|
Assert.That(entMan.EntityExists(rule.NukieShuttle));
|
|
Assert.That(entMan.EntityExists(rule.TargetStation));
|
|
|
|
Assert.That(entMan.HasComponent<MapGridComponent>(rule.NukieOutpost));
|
|
Assert.That(entMan.HasComponent<MapGridComponent>(rule.NukieShuttle));
|
|
|
|
Assert.That(entMan.HasComponent<StationMemberComponent>(rule.NukieOutpost));
|
|
Assert.That(entMan.HasComponent<StationDataComponent>(rule.TargetStation));
|
|
|
|
var nukieShuttlEnt = entMan.AllComponents<NukeOpsShuttleComponent>().FirstOrDefault().Uid;
|
|
Assert.That(entMan.EntityExists(nukieShuttlEnt));
|
|
|
|
EntityUid? nukieStationEnt = null;
|
|
foreach (var grid in mapRule.MapGrids)
|
|
{
|
|
if (entMan.HasComponent<StationMemberComponent>(grid))
|
|
{
|
|
nukieStationEnt = grid;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Assert.That(entMan.EntityExists(nukieStationEnt));
|
|
var nukieStation = entMan.GetComponent<StationMemberComponent>(nukieStationEnt!.Value);
|
|
|
|
var nukieStation = entMan.GetComponent<StationMemberComponent>(rule.NukieOutpost!.Value);
|
|
Assert.That(entMan.EntityExists(nukieStation.Station));
|
|
Assert.That(nukieStation.Station, Is.Not.EqualTo(rule.TargetStation));
|
|
|
|
Assert.That(server.MapMan.MapExists(mapRule.Map));
|
|
var nukieMap = mapSys.GetMap(mapRule.Map!.Value);
|
|
Assert.That(server.MapMan.MapExists(rule.NukiePlanet));
|
|
var nukieMap = mapSys.GetMap(rule.NukiePlanet!.Value);
|
|
|
|
var targetStation = entMan.GetComponent<StationDataComponent>(rule.TargetStation!.Value);
|
|
var targetGrid = targetStation.Grids.First();
|
|
var targetMap = entMan.GetComponent<TransformComponent>(targetGrid).MapUid!.Value;
|
|
Assert.That(targetMap, Is.Not.EqualTo(nukieMap));
|
|
|
|
Assert.That(entMan.GetComponent<TransformComponent>(player).MapUid, Is.EqualTo(nukieMap));
|
|
Assert.That(entMan.GetComponent<TransformComponent>(nukieStationEnt.Value).MapUid, Is.EqualTo(nukieMap));
|
|
Assert.That(entMan.GetComponent<TransformComponent>(nukieShuttlEnt).MapUid, Is.EqualTo(nukieMap));
|
|
Assert.That(entMan.GetComponent<TransformComponent>(rule.NukieOutpost!.Value).MapUid, Is.EqualTo(nukieMap));
|
|
Assert.That(entMan.GetComponent<TransformComponent>(rule.NukieShuttle!.Value).MapUid, Is.EqualTo(nukieMap));
|
|
|
|
// The maps are all map-initialized, including the player
|
|
// Yes, this is necessary as this has repeatedly been broken somehow.
|
|
Assert.That(mapSys.IsInitialized(nukieMap));
|
|
Assert.That(mapSys.IsInitialized(targetMap));
|
|
Assert.That(mapSys.IsPaused(nukieMap), Is.False);
|
|
Assert.That(mapSys.IsPaused(targetMap), Is.False);
|
|
|
|
EntityLifeStage LifeStage(EntityUid? uid) => entMan.GetComponent<MetaDataComponent>(uid!.Value).EntityLifeStage;
|
|
Assert.That(LifeStage(player), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(nukieMap), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(targetMap), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(nukieStationEnt.Value), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(nukieShuttlEnt), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(rule.NukieOutpost), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(rule.NukieShuttle), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
Assert.That(LifeStage(rule.TargetStation), Is.GreaterThan(EntityLifeStage.Initialized));
|
|
|
|
// Make sure the player has hands. We've had fucking disarmed nukies before.
|
|
Assert.That(entMan.HasComponent<HandsComponent>(player));
|
|
Assert.That(entMan.GetComponent<HandsComponent>(player).Hands.Count, Is.GreaterThan(0));
|
|
|
|
// While we're at it, lets make sure they aren't naked. I don't know how many inventory slots all mobs will be
|
|
// likely to have in the future. But nukies should probably have at least 3 slots with something in them.
|
|
var enumerator = invSys.GetSlotEnumerator(player);
|
|
int total = 0;
|
|
while (enumerator.NextItem(out _))
|
|
{
|
|
total++;
|
|
}
|
|
Assert.That(total, Is.GreaterThan(3));
|
|
|
|
// Finally lets check the nukie commander passed basic training and figured out how to breathe.
|
|
var totalSeconds = 30;
|
|
var totalTicks = (int) Math.Ceiling(totalSeconds / server.Timing.TickPeriod.TotalSeconds);
|
|
int increment = 5;
|
|
var resp = entMan.GetComponent<RespiratorComponent>(player);
|
|
var damage = entMan.GetComponent<DamageableComponent>(player);
|
|
for (var tick = 0; tick < totalTicks; tick += increment)
|
|
{
|
|
await pair.RunTicksSync(increment);
|
|
Assert.That(resp.SuffocationCycles, Is.LessThanOrEqualTo(resp.SuffocationCycleThreshold));
|
|
Assert.That(damage.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
|
}
|
|
|
|
//ticker.SetGamePreset((GamePresetPrototype?)null); WD edit
|
|
server.CfgMan.SetCVar(CCVars.GridFill, false);
|
|
await pair.SetAntagPref("NukeopsCommander", false);
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
}
|
|
|
|
*/
|