diff --git a/Content.IntegrationTests/Tests/GameRules/FailAndStartPresetTest.cs b/Content.IntegrationTests/Tests/GameRules/FailAndStartPresetTest.cs index 09a27c1bae..f660eccf30 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.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 320f9d197a..8608f250d4 100644 --- a/Content.Server/GameTicking/Rules/SecretRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/SecretRuleSystem.cs @@ -164,7 +164,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/Prototypes/GameRules/meteorswarms.yml b/Resources/Prototypes/GameRules/meteorswarms.yml index 70dd5265b0..b85032f056 100644 --- a/Resources/Prototypes/GameRules/meteorswarms.yml +++ b/Resources/Prototypes/GameRules/meteorswarms.yml @@ -4,6 +4,7 @@ components: - type: GameRule minPlayers: 25 + cancelPresetOnTooFewPlayers: false - type: MeteorScheduler - type: weightedRandomEntity diff --git a/Resources/Prototypes/game_presets.yml b/Resources/Prototypes/game_presets.yml index 8876468bbd..39523a1a37 100644 --- a/Resources/Prototypes/game_presets.yml +++ b/Resources/Prototypes/game_presets.yml @@ -7,6 +7,7 @@ description: survival-description rules: - RampingStationEventScheduler + - GameRuleMeteorScheduler - BasicRoundstartVariation - type: gamePreset @@ -20,6 +21,7 @@ - Revolutionary - Zombie - RampingStationEventScheduler + - GameRuleMeteorScheduler - type: gamePreset id: Extended @@ -44,6 +46,7 @@ description: greenshift-description rules: - BasicRoundstartVariation + - GameRuleMeteorScheduler - type: gamePreset id: Secret