diff --git a/Content.Server/GameTicking/Commands/SetGamePresetCommand.cs b/Content.Server/GameTicking/Commands/SetGamePresetCommand.cs index 58a77722e9..f3e1d35cad 100644 --- a/Content.Server/GameTicking/Commands/SetGamePresetCommand.cs +++ b/Content.Server/GameTicking/Commands/SetGamePresetCommand.cs @@ -42,7 +42,7 @@ namespace Content.Server.GameTicking.Commands return; } - ticker.SetGamePreset(ticker.CurrentPreset, false, rounds); + ticker.SetGamePreset(ticker.Preset, false, rounds); shell.WriteLine(Loc.GetString("set-game-preset-preset-set-finite", ("preset", preset.ID), ("rounds", rounds.ToString()))); } diff --git a/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs b/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs index d0ade377a7..49b154647f 100644 --- a/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs +++ b/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs @@ -230,6 +230,14 @@ namespace Content.Server.Voting.Managers var presets = GetGamePresets(); // Sunrise-Start + if (presets.Count == 1) + { + var singlePreset = presets.First(); + var ticker = _entityManager.EntitySysManager.GetEntitySystem(); + ticker.SetGamePreset(singlePreset.Key); + return; + } + if (presets.Count < 1) return; // Sunrise-End @@ -635,43 +643,54 @@ namespace Content.Server.Voting.Managers var excluded = ticker.ExcludedPresets.ToHashSet(); var validPresets = new List(); var presetPoolId = _cfg.GetCVar(SunriseCCVars.GamePresetPool); - HashSet? allowedPresets = null; + if (_prototypeManager.TryIndex(presetPoolId, out var presetPoolProto)) - allowedPresets = presetPoolProto.Presets; - foreach (var preset in _prototypeManager.EnumeratePrototypes()) { - if (allowedPresets != null && !allowedPresets.Contains(preset.ID)) - continue; - if (excluded.Contains(preset.ID)) - continue; - if (!preset.ShowInVote) - continue; - if (_playerManager.PlayerCount < (preset.MinPlayers ?? int.MinValue)) - continue; - if (_playerManager.PlayerCount > (preset.MaxPlayers ?? int.MaxValue)) - continue; - validPresets.Add(preset); - } - if (validPresets.Count == 0 && excluded.Count > 0) - { - ticker.ClearExcludedPresets(); - foreach (var preset in _prototypeManager.EnumeratePrototypes()) + foreach (var (presetId, limits) in presetPoolProto.Presets) { - if (allowedPresets != null && !allowedPresets.Contains(preset.ID)) + if (excluded.Contains(presetId)) continue; + + if (!_prototypeManager.TryIndex(presetId, out var preset)) + continue; + if (!preset.ShowInVote) continue; - if (_playerManager.PlayerCount < (preset.MinPlayers ?? int.MinValue)) - continue; - if (_playerManager.PlayerCount > (preset.MaxPlayers ?? int.MaxValue)) + + var minPlayers = limits.Length > 0 ? limits[0] : int.MinValue; + var maxPlayers = limits.Length > 1 ? limits[1] : int.MaxValue; + + if (_playerManager.PlayerCount < minPlayers || _playerManager.PlayerCount > maxPlayers) continue; + validPresets.Add(preset); } + + if (validPresets.Count == 0 && excluded.Count > 0) + { + ticker.ClearExcludedPresets(); + foreach (var (presetId, limits) in presetPoolProto.Presets) + { + if (!_prototypeManager.TryIndex(presetId, out var preset)) + continue; + + if (!preset.ShowInVote) + continue; + + var minPlayers = limits.Length > 0 ? limits[0] : int.MinValue; + var maxPlayers = limits.Length > 1 ? limits[1] : int.MaxValue; + + if (_playerManager.PlayerCount < minPlayers || _playerManager.PlayerCount > maxPlayers) + continue; + + validPresets.Add(preset); + } + } } if (validPresets.Count == 0) { - Logger.Warning("Нет подходящих игровых режимов для текущего количества игроков."); + Logger.Warning("No suitable game modes for the current player count."); return presets; } diff --git a/Content.Server/_Sunrise/Presets/GamePresetPoolPrototype.cs b/Content.Server/_Sunrise/Presets/GamePresetPoolPrototype.cs index 0af68d6222..bbbaf990bf 100644 --- a/Content.Server/_Sunrise/Presets/GamePresetPoolPrototype.cs +++ b/Content.Server/_Sunrise/Presets/GamePresetPoolPrototype.cs @@ -1,7 +1,5 @@ -using Content.Server.GameTicking.Presets; using JetBrains.Annotations; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; namespace Content.Server._Sunrise.Presets; @@ -13,8 +11,8 @@ public sealed partial class GamePresetPoolPrototype : IPrototype public string ID { get; private set; } = default!; /// - /// Which presets are in this pool. + /// Presets with their respective player limits. /// - [DataField("presets", customTypeSerializer:typeof(PrototypeIdHashSetSerializer), required: true)] - public HashSet Presets = new(0); + [DataField("presets", required: true)] + public Dictionary Presets { get; private set; } = new(); } diff --git a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs index aa9aebc264..6c97324bbb 100644 --- a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs +++ b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs @@ -309,7 +309,7 @@ public sealed partial class SunriseCCVars : CVars CVarDef.Create("game.reset_preset_after_restart", false); public static readonly CVarDef GamePresetPool = - CVarDef.Create("game.preset_pool", "DefaultPresetPool", CVar.SERVERONLY); + CVarDef.Create("game.preset_pool", "DefaultHighPopPresetPool", CVar.SERVERONLY); /* * Ban links. diff --git a/Resources/Prototypes/_Sunrise/game_preset_pools.yml b/Resources/Prototypes/_Sunrise/game_preset_pools.yml index 4017097fa8..b57bcb2c30 100644 --- a/Resources/Prototypes/_Sunrise/game_preset_pools.yml +++ b/Resources/Prototypes/_Sunrise/game_preset_pools.yml @@ -1,14 +1,44 @@ -# НЕ ТРОГАТЬ БЕЗ МОЕГО РАЗРЕШЕНИЯ!!! SplikZerys +- type: gamePresetPool + id: DefaultLowPopPresetPool + presets: + Greenshift: [0, 200] + Secret: [30, 200] - type: gamePresetPool - id: DefaultPresetPool + id: DefaultHighPopPresetPool presets: - - Greenshift - - Secret + Greenshift: [0, 200] + Secret: [2, 200] - type: gamePresetPool - id: MiddlePresetPool + id: DynamicPresetPool presets: - - Greenshift - - Secret - - Extra + Nukeops: [30, 200] + Traitor: [5, 200] + Zombie: [30, 200] + Survival: [5, 200] + Revolutionary: [30, 200] + Wizard: [30, 200] + BloodCult: [30, 200] + AssaultOps: [10, 200] + FleshCult: [30, 200] + +- type: gamePresetPool + id: PeacePresetPool + presets: + Greenshift: [50, 100] + Extra: [50, 100] + +- type: gamePresetPool + id: MiddleLowPopPresetPool + presets: + Greenshift: [0, 200] + Secret: [30, 200] + Extra: [30, 200] + +- type: gamePresetPool + id: MiddleHighPopPresetPool + presets: + Greenshift: [0, 200] + Secret: [50, 200] + Extra: [50, 100]