Skip to content

Commit

Permalink
Не запускать ДО если на может быть меньше 3 глав
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay committed Jan 1, 2025
1 parent 3071f35 commit 59befcd
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
57 changes: 57 additions & 0 deletions Content.Server/GameTicking/Rules/GameRuleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Chat.Managers;
using Content.Server.Jobs;
using Content.Server.Preferences.Managers;
using Content.Server.Revolutionary.Components;
using Content.Shared.GameTicking.Components;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;

Expand All @@ -13,6 +19,8 @@ public abstract partial class GameRuleSystem<T> : EntitySystem where T : ICompon
[Dependency] protected readonly IChatManager ChatManager = default!;
[Dependency] protected readonly GameTicker GameTicker = default!;
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] protected readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;

// Not protected, just to be used in utility methods
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
Expand All @@ -37,6 +45,55 @@ private void OnStartAttempt(RoundStartAttemptEvent args)
var query = QueryAllRules();
while (query.MoveNext(out var uid, out _, out var gameRule))
{
// Sunrise-Start
if (gameRule.MinCommandStaff > 0)
{
var availableHeads = new List<string>();

foreach (var playerSession in args.Players)
{
var userId = playerSession.UserId;
var preferencesManager = IoCManager.Resolve<IServerPreferencesManager>();
var prefs = preferencesManager.GetPreferences(userId);
var profile = prefs.SelectedCharacter as HumanoidCharacterProfile;
if (profile == null)
continue;
foreach (var profileJobPriority in profile.JobPriorities)
{
if (profileJobPriority.Value == JobPriority.Never)
continue;
if (!_prototype.TryIndex<JobPrototype>(profileJobPriority.Key.Id, out var job))
continue;
foreach (var special in job.Special)
{
if (special is not AddComponentSpecial componentSpecial)
continue;

foreach (var componentSpecialComponent in componentSpecial.Components)
{
var copy = _componentFactory.GetComponent(componentSpecialComponent.Value);
if (copy is CommandStaffComponent)
{
if (availableHeads.Contains(profileJobPriority.Key))
continue;
availableHeads.Add(profileJobPriority.Key);
}
}
}
}
}

if (gameRule.CancelPresetOnTooFewPlayers && availableHeads.Count < gameRule.MinCommandStaff)
{
ChatManager.SendAdminAnnouncement(Loc.GetString("preset-not-enough-ready-command-staff",
("readyCommandStaffCount", args.Players.Length),
("minimumCommandStaff", gameRule.MinCommandStaff),
("presetName", ToPrettyString(uid))));
args.Cancel();
}
}
// Sunrise-Edit

var minPlayers = gameRule.MinPlayers;
if (args.Players.Length >= minPlayers)
continue;
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/GameTicking/Components/GameRuleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public sealed partial class GameRuleComponent : Component
[DataField]
public int MinPlayers;

[DataField]
public int MinCommandStaff;

/// <summary>
/// If true, this rule not having enough players will cancel the preset selection.
/// If false, it will simply not run silently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ latejoin-arrivals-direction-time = Шаттл, который доставит
latejoin-arrivals-dumped-from-shuttle = Таинственная сила не позволяет вам улететь на шаттле прибытия.
latejoin-arrivals-teleport-to-spawn = Таинственная сила телепортирует вас с шаттла прибытия. Удачной смены!
preset-not-enough-ready-players = Не удалось запустить пресет { $presetName }. Требуется { $minimumPlayers } игроков, но готовы только { $readyPlayersCount }.
preset-not-enough-ready-command-staff = Не удалось запустить пресет { $presetName }. Требуется { $minimumCommandStaff } членов командного состава, но может быть только { $readyCommandStaffCount }.
preset-no-one-ready = Не удалось запустить режим { $presetName }. Нет готовых игроков.
game-run-level-PreRoundLobby = Лобби до начала раунда
game-run-level-InRound = В раунде
Expand Down
5 changes: 3 additions & 2 deletions Resources/Prototypes/_Sunrise/AssaultOps/roundstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
parent: BaseGameRule
components:
- type: GameRule
minPlayers: 0 # 20
minPlayers: 20
minCommandStaff: 3
- type: AssaultOpsRule
faction: Syndicate
- type: LoadMapRule
Expand Down Expand Up @@ -46,7 +47,7 @@
fallbackRoles: [ AssaultCommander ]
spawnerPrototype: SpawnPointAssaultOpsOperative
max: 5
playerRatio: 1 # 20
playerRatio: 15
startingGear: AssaultOperativeGear
roleLoadout:
- RoleSurvivalAssaultOps
Expand Down

0 comments on commit 59befcd

Please sign in to comment.