using Robust.Shared.Player;
using Robust.Shared.Utility;
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. May be null if this is a local server-side shell.
/// Whether this is a local or remote shell.
public ConsoleShell(IConsoleHost host, ICommonSession? session, bool isLocal)
{
ConsoleHost = host;
Player = session;
IsLocal = isLocal;
}
///
public IConsoleHost ConsoleHost { get; }
///
public bool IsServer => ConsoleHost.IsServer;
///
public ICommonSession? Player { get; }
///
public bool IsLocal { 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 WriteLine(FormattedMessage message)
{
ConsoleHost.WriteLine(Player, message);
}
///
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();
}
}
}