using Robust.Shared.Players;
namespace Robust.Shared.Console
{
///
public sealed class ConsoleShell : IConsoleShell
{
///
/// Constructs a new instance of .
///
/// Console Host that owns this shell.
/// Player Session that this shell represents. If this is null, then
/// the shell is representing the local console.
public ConsoleShell(IConsoleHost host, ICommonSession? session)
{
ConsoleHost = host;
Player = session;
}
///
public IConsoleHost ConsoleHost { get; }
///
public bool IsServer => ConsoleHost.IsServer;
///
public ICommonSession? Player { get; }
///
public void ExecuteCommand(string command)
{
ConsoleHost.ExecuteCommand(Player, command);
}
///
public void RemoteExecuteCommand(string command)
{
ConsoleHost.RemoteExecuteCommand(Player, command);
}
///
public void WriteLine(string text)
{
ConsoleHost.WriteLine(Player, text);
}
///
public void WriteError(string text)
{
ConsoleHost.WriteError(Player, text);
}
///
public void Clear()
{
// Only the local shell can clear the console
if (Player is not null)
return;
ConsoleHost.ClearLocalConsole();
}
}
}