diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs index c4070cd..06e1402 100644 --- a/Torch.Server/TorchServer.cs +++ b/Torch.Server/TorchServer.cs @@ -45,6 +45,8 @@ namespace Torch.Server private ServerState _state; private Stopwatch _uptime; private Timer _watchdog; + private int _players; + private MultiplayerManagerDedicated _multiplayerManagerDedicated; /// public TorchServer(TorchConfig config = null) @@ -92,6 +94,8 @@ namespace Torch.Server /// public string InstancePath => Config?.InstancePath; + public int OnlinePlayers { get => _players; private set => SetValue(ref _players, value); } + /// public override void Init() { @@ -186,6 +190,7 @@ namespace Torch.Server if (newState == TorchSessionState.Loaded) { + _multiplayerManagerDedicated = CurrentSession.Managers.GetManager(); CurrentSession.Managers.GetManager().RegisterCommandModule(typeof(WhitelistCommands)); ModCommunication.Register(); } @@ -209,6 +214,7 @@ namespace Torch.Server SimulationRatio = Math.Min(Sync.ServerSimulationRatio, 1); var elapsed = TimeSpan.FromSeconds(Math.Floor(_uptime.Elapsed.TotalSeconds)); ElapsedPlayTime = elapsed; + OnlinePlayers = _multiplayerManagerDedicated?.Players.Count ?? 0; if (_watchdog == null && Config.TickTimeout > 0) { diff --git a/Torch.Server/Views/TorchUI.xaml b/Torch.Server/Views/TorchUI.xaml index a198cae..5c7e34f 100644 --- a/Torch.Server/Views/TorchUI.xaml +++ b/Torch.Server/Views/TorchUI.xaml @@ -57,7 +57,7 @@