From a03413b5b47112652d291eff6e7ed52e707fda9c Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Wed, 14 Aug 2024 15:09:20 +0000 Subject: [PATCH] Fix test ops real (#1626) * update engine * update tests * Missing meteor presets (#29044) * add meteors into missing game presets * changes for real * implement code * this too * love 4 copy paste tests making sure /suicide kills you * remote rotation from mapped artifact analyzers * fix syndie survival boxes * dedup portafib yml and fix * untroll arena * fix edge --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> --- .../Tests/Commands/SuicideCommandTests.cs | 16 ++++----- .../Tests/GameRules/FailAndStartPresetTest.cs | 2 ++ .../Tests/GameRules/RuleMaxTimeRestartTest.cs | 13 ++++---- .../Tests/GameRules/TraitorRuleTest.cs | 17 +++++----- .../InteractionTest.EntitySpecifier.cs | 2 +- .../Interaction/InteractionTest.Helpers.cs | 2 +- .../GameTicking/Rules/GameRuleSystem.cs | 17 +++++++--- .../GameTicking/Rules/SecretRuleSystem.cs | 2 +- .../Components/GameRuleComponent.cs | 7 ++++ Resources/Maps/arena.yml | 2 -- Resources/Maps/edge.yml | 2 -- .../Catalog/Fills/Boxes/emergency.yml | 6 ++-- .../Objects/Devices/Medical/portafib.yml | 33 +------------------ Resources/Prototypes/game_presets.yml | 3 ++ RobustToolbox | 2 +- 15 files changed, 55 insertions(+), 71 deletions(-) diff --git a/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs b/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs index 540e86c650..af599fa2e8 100644 --- a/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs +++ b/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs @@ -95,7 +95,7 @@ public sealed class SuicideCommandTests consoleHost.GetSessionShell(playerMan.Sessions.First()).ExecuteCommand("suicide"); Assert.Multiple(() => { - Assert.That(mobStateSystem.IsDead(player, mobStateComp)); + //Assert.That(mobStateSystem.IsDead(player, mobStateComp)); // DeltaV - /suicide is the same as /ghost Assert.That(entManager.TryGetComponent(mindComponent.CurrentEntity, out var ghostComp) && !ghostComp.CanReturnToBody); }); @@ -158,10 +158,10 @@ public sealed class SuicideCommandTests Assert.Multiple(() => { - Assert.That(mobStateSystem.IsDead(player, mobStateComp)); + //Assert.That(mobStateSystem.IsDead(player, mobStateComp)); // DeltaV - /suicide is the same as /ghost Assert.That(entManager.TryGetComponent(mindComponent.CurrentEntity, out var ghostComp) && !ghostComp.CanReturnToBody); - Assert.That(damageableComp.Damage.GetTotal(), Is.EqualTo(lethalDamageThreshold)); + //Assert.That(damageableComp.Damage.GetTotal(), Is.EqualTo(lethalDamageThreshold)); // DeltaV - /suicide is the same as /ghost }); }); @@ -210,7 +210,7 @@ public sealed class SuicideCommandTests consoleHost.GetSessionShell(playerMan.Sessions.First()).ExecuteCommand("suicide"); Assert.Multiple(() => { - Assert.That(mobStateSystem.IsAlive(player, mobStateComp)); + //Assert.That(mobStateSystem.IsAlive(player, mobStateComp)); // DeltaV: Assert.That(entManager.TryGetComponent(mindComponent.CurrentEntity, out var ghostComp) && !ghostComp.CanReturnToBody); }); @@ -281,10 +281,10 @@ public sealed class SuicideCommandTests Assert.Multiple(() => { - Assert.That(mobStateSystem.IsDead(player, mobStateComp)); + //Assert.That(mobStateSystem.IsDead(player, mobStateComp)); // DeltaV Assert.That(entManager.TryGetComponent(mindComponent.CurrentEntity, out var ghostComp) && !ghostComp.CanReturnToBody); - Assert.That(damageableComp.Damage.DamageDict["Slash"], Is.EqualTo(lethalDamageThreshold)); + //Assert.That(damageableComp.Damage.DamageDict["Slash"], Is.EqualTo(lethalDamageThreshold)); // DeltaV }); }); @@ -353,10 +353,10 @@ public sealed class SuicideCommandTests Assert.Multiple(() => { - Assert.That(mobStateSystem.IsDead(player, mobStateComp)); + //Assert.That(mobStateSystem.IsDead(player, mobStateComp)); // DeltaV Assert.That(entManager.TryGetComponent(mindComponent.CurrentEntity, out var ghostComp) && !ghostComp.CanReturnToBody); - Assert.That(damageableComp.Damage.DamageDict["Slash"], Is.EqualTo(lethalDamageThreshold / 2)); + //Assert.That(damageableComp.Damage.DamageDict["Slash"], Is.EqualTo(lethalDamageThreshold / 2)); // DeltaV }); }); diff --git a/Content.IntegrationTests/Tests/GameRules/FailAndStartPresetTest.cs b/Content.IntegrationTests/Tests/GameRules/FailAndStartPresetTest.cs index 185316adf3..3109df890a 100644 --- a/Content.IntegrationTests/Tests/GameRules/FailAndStartPresetTest.cs +++ b/Content.IntegrationTests/Tests/GameRules/FailAndStartPresetTest.cs @@ -140,6 +140,8 @@ public sealed class TestRuleSystem : EntitySystem while (query.MoveNext(out _, out _, out var gameRule)) { var minPlayers = gameRule.MinPlayers; + if (!gameRule.CancelPresetOnTooFewPlayers) + continue; if (args.Players.Length >= minPlayers) continue; diff --git a/Content.IntegrationTests/Tests/GameRules/RuleMaxTimeRestartTest.cs b/Content.IntegrationTests/Tests/GameRules/RuleMaxTimeRestartTest.cs index 4708bd10c0..c805d04a71 100644 --- a/Content.IntegrationTests/Tests/GameRules/RuleMaxTimeRestartTest.cs +++ b/Content.IntegrationTests/Tests/GameRules/RuleMaxTimeRestartTest.cs @@ -1,10 +1,7 @@ -using Content.Server.GameTicking; -using Content.Server.GameTicking.Commands; +using Content.Server.GameTicking; using Content.Server.GameTicking.Rules; using Content.Server.GameTicking.Rules.Components; -using Content.Shared.CCVar; using Content.Shared.GameTicking.Components; -using Robust.Shared.Configuration; using Robust.Shared.GameObjects; using Robust.Shared.Timing; @@ -27,8 +24,12 @@ namespace Content.IntegrationTests.Tests.GameRules var sGameTicker = server.ResolveDependency().GetEntitySystem(); var sGameTiming = server.ResolveDependency(); - sGameTicker.StartGameRule("MaxTimeRestart", out var ruleEntity); - Assert.That(entityManager.TryGetComponent(ruleEntity, out var maxTime)); + MaxTimeRestartRuleComponent maxTime = null; + await server.WaitPost(() => + { + sGameTicker.StartGameRule("MaxTimeRestart", out var ruleEntity); + Assert.That(entityManager.TryGetComponent(ruleEntity, out maxTime)); + }); Assert.That(server.EntMan.Count(), Is.EqualTo(1)); Assert.That(server.EntMan.Count(), Is.EqualTo(1)); diff --git a/Content.IntegrationTests/Tests/GameRules/TraitorRuleTest.cs b/Content.IntegrationTests/Tests/GameRules/TraitorRuleTest.cs index 31d33ba617..d2717521b2 100644 --- a/Content.IntegrationTests/Tests/GameRules/TraitorRuleTest.cs +++ b/Content.IntegrationTests/Tests/GameRules/TraitorRuleTest.cs @@ -77,16 +77,17 @@ public sealed class TraitorRuleTest await pair.SetAntagPreference(TraitorAntagRoleName, true); // Add the game rule - var gameRuleEnt = ticker.AddGameRule(TraitorGameRuleProtoId); - Assert.That(entMan.TryGetComponent(gameRuleEnt, out var traitorRule)); - - // Ready up - ticker.ToggleReadyAll(true); - Assert.That(ticker.PlayerGameStatuses.Values.All(x => x == PlayerGameStatus.ReadyToPlay)); - - // Start the round + TraitorRuleComponent traitorRule = null; await server.WaitPost(() => { + var gameRuleEnt = ticker.AddGameRule(TraitorGameRuleProtoId); + Assert.That(entMan.TryGetComponent(gameRuleEnt, out traitorRule)); + + // Ready up + ticker.ToggleReadyAll(true); + Assert.That(ticker.PlayerGameStatuses.Values.All(x => x == PlayerGameStatus.ReadyToPlay)); + + // Start the round ticker.StartRound(); // Force traitor mode to start (skip the delay) ticker.StartGameRule(gameRuleEnt); diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.EntitySpecifier.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.EntitySpecifier.cs index 053152dbe1..194bc54fba 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.EntitySpecifier.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.EntitySpecifier.cs @@ -114,7 +114,7 @@ public abstract partial class InteractionTest return await SpawnEntity((stack.StackTypeId, spec.Quantity), coords); Assert.That(spec.Quantity, Is.EqualTo(1), "SpawnEntity only supports returning a singular entity"); - await Server.WaitPost(() => uid = SEntMan.SpawnEntity(spec.Prototype, coords)); + await Server.WaitPost(() => uid = SEntMan.SpawnAtPosition(spec.Prototype, coords)); return uid; } diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs index 5483d4ab2a..d431c440a2 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs @@ -91,7 +91,7 @@ public abstract partial class InteractionTest Target = NetEntity.Invalid; await Server.WaitPost(() => { - Target = SEntMan.GetNetEntity(SEntMan.SpawnEntity(prototype, SEntMan.GetCoordinates(TargetCoords))); + Target = SEntMan.GetNetEntity(SEntMan.SpawnAtPosition(prototype, SEntMan.GetCoordinates(TargetCoords))); }); await RunTicks(5); diff --git a/Content.Server/GameTicking/Rules/GameRuleSystem.cs b/Content.Server/GameTicking/Rules/GameRuleSystem.cs index 730748ce6b..cb5b117549 100644 --- a/Content.Server/GameTicking/Rules/GameRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/GameRuleSystem.cs @@ -41,11 +41,18 @@ public abstract partial class GameRuleSystem : EntitySystem where T : ICompon if (args.Players.Length >= minPlayers) continue; - ChatManager.SendAdminAnnouncement(Loc.GetString("preset-not-enough-ready-players", - ("readyPlayersCount", args.Players.Length), - ("minimumPlayers", minPlayers), - ("presetName", ToPrettyString(uid)))); - args.Cancel(); + if (gameRule.CancelPresetOnTooFewPlayers) + { + ChatManager.SendAdminAnnouncement(Loc.GetString("preset-not-enough-ready-players", + ("readyPlayersCount", args.Players.Length), + ("minimumPlayers", minPlayers), + ("presetName", ToPrettyString(uid)))); + args.Cancel(); + } + else + { + ForceEndSelf(uid, gameRule); + } } } diff --git a/Content.Server/GameTicking/Rules/SecretRuleSystem.cs b/Content.Server/GameTicking/Rules/SecretRuleSystem.cs index b86d8de9b9..e82cecde36 100644 --- a/Content.Server/GameTicking/Rules/SecretRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/SecretRuleSystem.cs @@ -163,7 +163,7 @@ public sealed class SecretRuleSystem : GameRuleSystem return false; } - if (ruleComp.MinPlayers > players) + if (ruleComp.MinPlayers > players && ruleComp.CancelPresetOnTooFewPlayers) return false; } diff --git a/Content.Shared/GameTicking/Components/GameRuleComponent.cs b/Content.Shared/GameTicking/Components/GameRuleComponent.cs index 4e93c2b003..87a5822d47 100644 --- a/Content.Shared/GameTicking/Components/GameRuleComponent.cs +++ b/Content.Shared/GameTicking/Components/GameRuleComponent.cs @@ -23,6 +23,13 @@ public sealed partial class GameRuleComponent : Component [DataField] public int MinPlayers; + /// + /// If true, this rule not having enough players will cancel the preset selection. + /// If false, it will simply not run silently. + /// + [DataField] + public bool CancelPresetOnTooFewPlayers = true; + /// /// A delay for when the rule the is started and when the starting logic actually runs. /// diff --git a/Resources/Maps/arena.yml b/Resources/Maps/arena.yml index f4090e26fa..fff8c8a9c3 100644 --- a/Resources/Maps/arena.yml +++ b/Resources/Maps/arena.yml @@ -122253,13 +122253,11 @@ entities: - uid: 4884 components: - type: Transform - rot: 3.141592653589793 rad pos: -5.5,-87.5 parent: 6747 - uid: 4914 components: - type: Transform - rot: 3.141592653589793 rad pos: -9.5,-87.5 parent: 6747 - proto: MachineCentrifuge diff --git a/Resources/Maps/edge.yml b/Resources/Maps/edge.yml index 7929f1f5dc..e51931ddda 100644 --- a/Resources/Maps/edge.yml +++ b/Resources/Maps/edge.yml @@ -86834,7 +86834,6 @@ entities: - uid: 7691 components: - type: Transform - rot: 1.5707963267948966 rad pos: -61.5,36.5 parent: 2 - type: DeviceLinkSink @@ -86843,7 +86842,6 @@ entities: - uid: 7983 components: - type: Transform - rot: 1.5707963267948966 rad pos: -61.5,32.5 parent: 2 - type: DeviceLinkSink diff --git a/Resources/Prototypes/Catalog/Fills/Boxes/emergency.yml b/Resources/Prototypes/Catalog/Fills/Boxes/emergency.yml index 2cb46255f9..5288890dc3 100644 --- a/Resources/Prototypes/Catalog/Fills/Boxes/emergency.yml +++ b/Resources/Prototypes/Catalog/Fills/Boxes/emergency.yml @@ -209,8 +209,7 @@ - id: ClothingMaskGasSyndicate - id: ExtendedEmergencyOxygenTankFilled - id: EmergencyMedipen - - id: SpaceMedipen # DeltaV - keep spacepen - - id: Flare + - id: SpaceMedipen # DeltaV - keep spacepen, replaces flare for space - id: FoodPSB # DeltaV - replace nutribrick with PSB - id: DrinkWaterBottleFull # DeltaV - why didnt they get water??? - type: Sprite @@ -228,8 +227,7 @@ - id: ClothingMaskGasSyndicate - id: ExtendedEmergencyNitrogenTankFilled - id: EmergencyMedipen - - id: SpaceMedipen # DeltaV - keep spacepen - - id: Flare + - id: SpaceMedipen # DeltaV - keep spacepen, replaces flare for space - id: FoodPSB # DeltaV - replace nutribrick with PSB - id: DrinkWaterBottleFull # DeltaV - why didnt they get water??? # Intentionally wrong picture on the box to mimic the NT one diff --git a/Resources/Prototypes/DeltaV/Entities/Objects/Devices/Medical/portafib.yml b/Resources/Prototypes/DeltaV/Entities/Objects/Devices/Medical/portafib.yml index a02023f4a8..cb9e81c34c 100644 --- a/Resources/Prototypes/DeltaV/Entities/Objects/Devices/Medical/portafib.yml +++ b/Resources/Prototypes/DeltaV/Entities/Objects/Devices/Medical/portafib.yml @@ -1,48 +1,17 @@ - type: entity + parent: Defibrillator id: Portafib - parent: [ BaseItem, PowerCellSlotSmallItem ] name: portafib description: Less weight, same great ZZZAP! components: - type: Sprite sprite: DeltaV/Objects/Medical/portafib.rsi - layers: - - state: icon - - state: screen - map: [ "enum.ToggleVisuals.Layer" ] - visible: false - shader: unshaded - - state: ready - map: ["enum.PowerDeviceVisualLayers.Powered"] - shader: unshaded - - type: GenericVisualizer - visuals: - enum.ToggleVisuals.Toggled: - enum.ToggleVisuals.Layer: - True: { visible: true } - False: { visible: false } - enum.DefibrillatorVisuals.Ready: - enum.PowerDeviceVisualLayers.Powered: - True: { visible: true } - False: { visible: false } - type: Item size: Normal - - type: MultiHandedItem - - type: Speech - - type: Defibrillator - zapHeal: - types: - Asphyxiation: -40 - type: PowerCellDraw useRate: 140 - - type: Appearance - - type: DoAfter - - type: UseDelay - type: StaticPrice price: 100 - - type: GuideHelp - guides: - - Medical Doctor - type: entity id: PortafibEmpty diff --git a/Resources/Prototypes/game_presets.yml b/Resources/Prototypes/game_presets.yml index 3ebc336832..a329130b5d 100644 --- a/Resources/Prototypes/game_presets.yml +++ b/Resources/Prototypes/game_presets.yml @@ -7,6 +7,7 @@ description: survival-description rules: - RampingStationEventScheduler + #- GameRuleMeteorScheduler # DeltaV: old meteor event - BasicRoundstartVariation - type: gamePreset @@ -20,6 +21,7 @@ - Revolutionary - Zombie - RampingStationEventScheduler + #- GameRuleMeteorScheduler # DeltaV: old meteor event - type: gamePreset id: Extended @@ -43,6 +45,7 @@ description: greenshift-description rules: - BasicRoundstartVariation + #- GameRuleMeteorScheduler # DeltaV: old meteor event - type: gamePreset id: Secret diff --git a/RobustToolbox b/RobustToolbox index 49c831b48d..2178707937 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 49c831b48d1449e90a65acdb0c276d2deea4ce2c +Subproject commit 217870793771c008327fe0a7d3be965b2f4880c3