[feat] Stalin manager
# Conflicts: # Content.Client/Entry/EntryPoint.cs # Content.Server/Entry/EntryPoint.cs # Content.Server/GameTicking/Commands/JoinGameCommand.cs # Content.Server/GameTicking/GameTicker.Lobby.cs # Content.Server/GameTicking/GameTicker.RoundFlow.cs # Content.Server/GameTicking/GameTicker.Spawning.cs
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server.White.Stalin;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.White;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -12,6 +18,8 @@ namespace Content.Server.GameTicking.Commands
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly StalinManager _stalinManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
|
||||
public string Command => "joingame";
|
||||
public string Description => "";
|
||||
@@ -21,7 +29,7 @@ namespace Content.Server.GameTicking.Commands
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
@@ -46,6 +54,19 @@ namespace Content.Server.GameTicking.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var chatManager = IoCManager.Resolve<IChatManager>();
|
||||
|
||||
if (_configurationManager.GetCVar(WhiteCVars.StalinEnabled))
|
||||
{
|
||||
var allowEnterRequest = await _stalinManager.AllowEnter(player);
|
||||
|
||||
if (!allowEnterRequest.allow)
|
||||
{
|
||||
chatManager.DispatchServerMessage(player, allowEnterRequest.errorMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.WriteLine("Round has not started.");
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.Station.Components;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using System.Text;
|
||||
using Content.Shared.White;
|
||||
|
||||
namespace Content.Server.GameTicking
|
||||
{
|
||||
@@ -168,6 +169,11 @@ namespace Content.Server.GameTicking
|
||||
return;
|
||||
}
|
||||
|
||||
if (_configurationManager.GetCVar(WhiteCVars.StalinEnabled))
|
||||
{
|
||||
_chatManager.DispatchServerMessage(player, "Внимание, на сервере включен бункер. Если ваш аккаунт не был привязан к дискорду, то вы не сможете зайти в раунд. Для того чтобы привязать аккаунт - нажмите на кнопку ПРИВЯЗАТЬ АККАУНТ");
|
||||
}
|
||||
|
||||
var status = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
||||
_playerGameStatuses[player.UserId] = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
||||
RaiseNetworkEvent(GetStatusMsg(player), player.ConnectedClient);
|
||||
|
||||
@@ -22,6 +22,10 @@ using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Server.UtkaIntegration;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.White.Stalin;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.White;
|
||||
using Robust.Shared.Asynchronous;
|
||||
|
||||
namespace Content.Server.GameTicking
|
||||
{
|
||||
@@ -32,6 +36,7 @@ namespace Content.Server.GameTicking
|
||||
|
||||
//WD-EDIT
|
||||
[Dependency] private readonly UtkaTCPWrapper _utkaSocketWrapper = default!;
|
||||
[Dependency] private readonly StalinManager _stalinManager = default!;
|
||||
//WD-EDIT
|
||||
|
||||
private static readonly Counter RoundNumberMetric = Metrics.CreateCounter(
|
||||
@@ -178,7 +183,7 @@ namespace Content.Server.GameTicking
|
||||
return gridUids;
|
||||
}
|
||||
|
||||
public void StartRound(bool force = false)
|
||||
public async void StartRound(bool force = false)
|
||||
{
|
||||
#if EXCEPTION_TOLERANCE
|
||||
try
|
||||
@@ -215,11 +220,25 @@ namespace Content.Server.GameTicking
|
||||
RaiseLocalEvent(startingEvent);
|
||||
var readyPlayers = new List<ICommonSession>();
|
||||
var readyPlayerProfiles = new Dictionary<NetUserId, HumanoidCharacterProfile>();
|
||||
var stalinBunkerEnabled = _configurationManager.GetCVar(WhiteCVars.StalinEnabled);
|
||||
|
||||
await _stalinManager.RefreshUsersData();
|
||||
|
||||
foreach (var (userId, status) in _playerGameStatuses)
|
||||
{
|
||||
if (LobbyEnabled && status != PlayerGameStatus.ReadyToPlay) continue;
|
||||
if (!_playerManager.TryGetSessionById(userId, out var session)) continue;
|
||||
|
||||
if (stalinBunkerEnabled)
|
||||
{
|
||||
var playerData = await _stalinManager.AllowEnter(session, false);
|
||||
|
||||
if (!playerData.allow)
|
||||
{
|
||||
_chatManager.DispatchServerMessage(session, $"{playerData.errorMessage}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
DebugTools.Assert(_userDb.IsLoadComplete(session), $"Player was readied up but didn't have user DB data loaded yet??");
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,7 @@ using Content.Shared.Players;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
using Content.Shared.White;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
@@ -307,12 +308,22 @@ namespace Content.Server.GameTicking
|
||||
/// <summary>
|
||||
/// Causes the given player to join the current game as observer ghost. See also <see cref="SpawnObserver"/>
|
||||
/// </summary>
|
||||
public void JoinAsObserver(ICommonSession player)
|
||||
public async void JoinAsObserver(ICommonSession player)
|
||||
{
|
||||
// Can't spawn players with a dummy ticker!
|
||||
if (DummyTicker)
|
||||
return;
|
||||
|
||||
if (_configurationManager.GetCVar(WhiteCVars.StalinEnabled))
|
||||
{
|
||||
var allowEnterData = await _stalinManager.AllowEnter(player);
|
||||
if (!allowEnterData.allow)
|
||||
{
|
||||
_chatManager.DispatchServerMessage(player, $"Вход в игру запрещен: {allowEnterData.errorMessage}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerJoinGame(player);
|
||||
SpawnObserver(player);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user