# Conflicts: # Content.Client/Options/UI/Tabs/AudioTab.xaml.cs # Content.Client/Preferences/UI/HumanoidProfileEditor.xaml # Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs # Content.Server/Database/ServerDbBase.cs # Content.Server/Entry/EntryPoint.cs # Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs # Content.Server/IoC/ServerContentIoC.cs # Content.Server/VoiceMask/VoiceMaskSystem.cs # Resources/Prototypes/Entities/Mobs/Species/base.yml
86 lines
2.7 KiB
C#
86 lines
2.7 KiB
C#
using System.Linq;
|
|
using System.Net;
|
|
using Content.Server.Administration.Managers;
|
|
using Content.Server.AlertLevel;
|
|
using Content.Server.GameTicking;
|
|
using Content.Server.Maps;
|
|
using Content.Server.RoundEnd;
|
|
using Content.Server.Station.Systems;
|
|
using Content.Server.UtkaIntegration.TCP;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.UtkaIntegration;
|
|
|
|
public sealed class UtkaStatusCommand : IUtkaCommand
|
|
{
|
|
public string Name => "status";
|
|
public Type RequestMessageType => typeof(UtkaStatusRequsets);
|
|
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly UtkaTCPWrapper _utkaSocketWrapper = default!;
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
|
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
|
|
|
|
public void Execute(UtkaTCPSession session, UtkaBaseMessage baseMessage)
|
|
{
|
|
if(baseMessage is not UtkaStatusRequsets message) return;
|
|
var _gameTicker = EntitySystem.Get<GameTicker>();
|
|
var _roundEndSystem = EntitySystem.Get<RoundEndSystem>();
|
|
var _station = EntitySystem.Get<StationSystem>();
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
|
var players = Filter.GetAllPlayers().ToList().Count;
|
|
|
|
var admins = _adminManager.ActiveAdmins.Select(x => x.Name).ToList().Count;
|
|
|
|
string shuttleData = string.Empty;
|
|
|
|
if (_roundEndSystem.ExpectedCountdownEnd == null)
|
|
{
|
|
shuttleData = "idle";
|
|
}
|
|
else
|
|
{
|
|
shuttleData = "called";
|
|
}
|
|
|
|
var roundDuration = _gameTicker.RoundDuration().TotalSeconds;
|
|
|
|
string? gameMap = null;
|
|
string? stationCode = null;
|
|
foreach (var station in _station.GetStations())
|
|
{
|
|
if (!_entMan.TryGetComponent(station, out AlertLevelComponent? alert) || stationCode != null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (alert is { CurrentLevel: { } })
|
|
{
|
|
stationCode = alert.CurrentLevel;
|
|
|
|
var map = _gameMapManager.GetSelectedMap();
|
|
gameMap = map?.MapName ?? Loc.GetString("discord-round-unknown-map");
|
|
}
|
|
}
|
|
|
|
var toUtkaMessage = new UtkaStatusResponse()
|
|
{
|
|
Players = players,
|
|
Admins = admins,
|
|
Map = gameMap,
|
|
ShuttleStatus = shuttleData,
|
|
RoundDuration = roundDuration,
|
|
StationCode = stationCode
|
|
};
|
|
|
|
_utkaSocketWrapper.SendMessageToAll(toUtkaMessage);
|
|
}
|
|
}
|