using Robust.Shared.Console;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
namespace Robust.Client.Console
{
///
/// Tracks the console group of the client and which commands they can use.
/// Receives up to date permissions from the server whenever they change.
///
public class ClientConGroupController : IClientConGroupController
{
#pragma warning disable 649
[Dependency] private readonly IClientNetManager _netManager;
#pragma warning restore 649
///
/// The console group this client is in. Determines which commands the client can use and if they can use vv.
///
private ConGroup _clientConGroup;
public void Initialize()
{
_netManager.RegisterNetMessage(MsgConGroupUpdate.Name, _onConGroupUpdate);
}
public bool CanCommand(string cmdName)
{
if (_clientConGroup == null)
return false;
return _clientConGroup.Commands.Contains(cmdName);
}
public bool CanViewVar()
{
if (_clientConGroup == null)
return false;
return _clientConGroup.CanViewVar;
}
///
/// Update client console group data with message from the server.
///
/// Server message listing what commands this client can use.
private void _onConGroupUpdate(MsgConGroupUpdate msg)
{
_clientConGroup = msg.ClientConGroup;
}
}
}