Files
RobustToolbox/Robust.Shared/Toolshed/ToolshedManager.Permissions.cs
Leon Friedrich 9af119f57a Toolshed Rejig (#5455)
* Toolshed Rejig

* shorten hint string

* Try fix conflicts. Ill make with work later

* bodge

* Fix ProtoIdTypeParser assert

* comment

* AllEntities

* Remove more linq from WhereCommand

* better help strings

* Add ContainsCommand

* loc strings

* Add contains command description

* Add $self variable

* Errors for writing to readonly variables

* A
2024-12-21 17:49:11 +11:00

47 lines
1.4 KiB
C#

using Robust.Shared.Player;
using Robust.Shared.Toolshed.Errors;
#if !CLIENT_SCRIPTING
using System;
#endif
namespace Robust.Shared.Toolshed;
public sealed partial class ToolshedManager
{
private ToolshedEnvironment? _defaultEnvironment = default!;
/// <summary>
/// The active permission controller, if any.
/// </summary>
/// <remarks>
/// Invocation contexts can entirely ignore this, though it's bad form to do so if they have a session on hand.
/// </remarks>
public IPermissionController? ActivePermissionController { get; set; }
/// <summary>
/// Check whether a command can be invoked by the given session/user.
/// A null session implies that the command is being run by the server.
/// </summary>
public bool CheckInvokable(CommandSpec command, ICommonSession? session, out IConError? error)
{
if (ActivePermissionController is { } controller)
return controller.CheckInvokable(command, session, out error);
error = null;
return true;
}
public ToolshedEnvironment DefaultEnvironment
{
get
{
#if !CLIENT_SCRIPTING
if (_net.IsClient)
throw new NotImplementedException("Toolshed is not yet ready for client-side use.");
#endif
_defaultEnvironment ??= new();
return _defaultEnvironment;
}
}
}